-
Notifications
You must be signed in to change notification settings - Fork 97
Add pre-commit including config and GitHub workflow #563
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: pre-commit | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| pre-commit: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.12" | ||
| - uses: pre-commit/action@v3.0.1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| fail_fast: false | ||
| minimum_pre_commit_version: 4.0.0 | ||
| default_stages: [pre-commit] | ||
|
|
||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: check-added-large-files | ||
| - id: check-case-conflict | ||
| - id: check-merge-conflict | ||
| - id: check-json | ||
| - id: check-toml | ||
| - id: check-yaml | ||
| - id: detect-private-key | ||
| - id: end-of-file-fixer | ||
| - id: trailing-whitespace | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: "v0.13.0" | ||
| hooks: | ||
| - id: ruff-check | ||
| args: [--exit-non-zero-on-fix] | ||
| - id: ruff-format | ||
| args: [--exit-non-zero-on-fix] | ||
|
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't exit-non-zero the default? And/or, when pre-commit runs, if a delta is detected, doesn't the delta itself cause pre-commit to trip a failure anyways?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. But Ruff can also auto-magically fix some formatting and linting issues. In which case, it exits with a zero status code from what I've seen. We don't have the |
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've rolled without using the dedicated pre-commit action before, but something I've added in my own CI is the
--show-diff-on-failureflag. It will show a git diff on a failure so you can see the issue in the CI readout. Unsure if the dedicated pre-commit CI action is already doing that under the hood (should be easy enough to check source for that action and confirm if they're using it or not; they likely also have a way to pass arbitrary flags).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does use
-show-diff-on-failure: https://github.com/pre-commit/action/blob/main/action.yml#L19