-
Notifications
You must be signed in to change notification settings - Fork 35
ci: add pre-commit hooks and workflow #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dannf
wants to merge
14
commits into
chainguard-dev:main
Choose a base branch
from
dannf:dev/pre-commit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ff4b1e5
fix: add missing final newlines to Makefiles
dannf cdf3276
fix: add missing final newlines to text files
dannf de6ae93
fix: format dependabot.yml with yam
dannf 27ec6bc
chore: add pre-commit configuration
dannf 907ad5b
ci: add pre-commit GitHub Actions workflow
dannf 11fa93b
chore: add markdownlint-cli2 configuration
dannf ffa7682
chore: add markdownlint-cli2 pre-commit hook
dannf c858d37
docs: fix auto-fixable markdownlint errors across README files
dannf b84c2cf
docs: fix MD040 errors by adding language specifiers to code blocks
dannf 32c631b
docs: fix MD046 errors by standardizing on fenced code blocks
dannf 95ee8db
docs: fix MD060 table formatting errors
dannf 8459141
docs: convert GNU flags table to compact style
dannf 8d7145a
fix(docs): fix MD013 line-length errors across all markdown files
dannf f7c4d58
Simplify dependabot config to use go.work workspace support
dannf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: pre-commit | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - "main" # required to create a usable cache for other PRs | ||
| pull_request: | ||
| branches: | ||
| - "main" | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: pre-commit checks | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Harden Runner | ||
| uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3 | ||
| with: | ||
| egress-policy: audit | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| fetch-depth: 0 # required for --from-ref and --to-ref | ||
| persist-credentials: false | ||
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | ||
| - run: | | ||
| python -m pip install pre-commit | ||
| python -m pip freeze --local | ||
| - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | ||
| id: cache | ||
| with: | ||
| path: ~/.cache/pre-commit | ||
| key: ${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} | ||
| # A cache miss means that the pre-commit config changed and we should check everything | ||
| # Otherwise, we can just check modified files which will be much faster | ||
| - if: steps.cache.outputs.cache-hit != 'true' | ||
| run: pre-commit run --show-diff-on-failure --color=always --all-files | ||
| - if: steps.cache.outputs.cache-hit == 'true' | ||
| run: pre-commit run --show-diff-on-failure --color=always --from-ref HEAD^^^ --to-ref HEAD | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| config: | ||
| MD013: | ||
| line_length: 120 | ||
| MD046: | ||
| style: fenced | ||
| MD060: | ||
| style: compact |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Pre-commit configuration for tw repository | ||
| # Install: pip install pre-commit | ||
| # Setup: pre-commit install | ||
| # Run manually: pre-commit run --all-files | ||
| repos: | ||
| - repo: https://github.com/chainguard-dev/yam | ||
| rev: d05ffb50d1a8f8e7047a77e57280147ff19809d4 # frozen: v0.2.54 | ||
| hooks: | ||
| - id: yam | ||
| files: '\.ya?ml$' | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0 | ||
| hooks: | ||
| - id: check-yaml | ||
| files: '\.ya?ml$' | ||
| - id: check-merge-conflict | ||
| - id: check-added-large-files | ||
| - id: check-case-conflict | ||
| - id: detect-private-key | ||
| - id: end-of-file-fixer | ||
| - id: trailing-whitespace | ||
| # Ensure markdown files pass stereo's markdownlint checks when synced | ||
| - repo: https://github.com/DavidAnson/markdownlint-cli2 | ||
| rev: 3766ad839ad3a74558031510b3bc9872bb1d9980 # frozen: v0.22.0 | ||
| hooks: | ||
| - id: markdownlint-cli2 | ||
| files: '\.md$' | ||
| - repo: local | ||
| hooks: | ||
| - id: shellcheck | ||
| name: shellcheck | ||
| entry: make shellcheck | ||
| language: system | ||
| pass_filenames: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.