-
Notifications
You must be signed in to change notification settings - Fork 722
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
Add pre-commit plus a GItHub Action to run it #776
Conversation
Signed-off-by: Christian Clauss <[email protected]>
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.
This really boils down to maintainer (@PierreF) preference. #770 already set up running Ruff with tox
, which is also fine. Left a comment about https://github.com/pre-commit/action in case you weren't aware of it.
.github/workflows/precommit.yml
Outdated
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
- run: pip install pre-commit | ||
- run: pre-commit --version | ||
- run: pre-commit install | ||
- run: pre-commit run --all-files |
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.
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- run: pip install pre-commit | |
- run: pre-commit --version | |
- run: pre-commit install | |
- run: pre-commit run --all-files | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3 | |
- uses: pre-commit/[email protected] |
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.
https://github.com/pre-commit/action is in maintenance-only mode and will not be accepting new features so I tend not to use it. pre-commit.ci is awesome.
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 know it's in maintenance-only mode, but it works – it's also just, well, 20 lines.
I don't prefer pre-commit.ci because it's a third-party dependency and (AFAIU) an one-man project (and for projects where "auto-fix PRs" is enabled, they tend to mess with my workflow).
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.
pre-commit.ci is run by the same person who led the development of pre-commit.
If auto-fix PRs are messing up your workflow then you do not have pre-commit properly installed locally.
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.
@cclauss Well, for a repo like this where every commit should have a --signoff
to adhere to a CLA, the pre-commit commit wouldn't be appropriate, etc. 😁
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.
This add another tools for checking code, but I think it's okay:
- tox -e py (or just tox / tox -e py38): is here to run Python tests. And might took some time
- tox -e lint will be kept for slow linter
- pre-commit will be used for faster linter
Those linters/tests could still run locally and in Github actions. Which fit the needs of everyone:
- the one that want to run it locally (like me) before pushing to Github
- all PRs and master is also automatically checked by Github
Co-authored-by: Pierre Fersing <[email protected]>
Co-authored-by: Pierre Fersing <[email protected]>
The error isn't added by the PR but already present on master. I will fix it once merged. |
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.
Weak review comment, can be addressed later as well: If this is adopted (and I'm for it, in general), tox -e lint
should just run pre-commit run --all-files
to avoid drift between multiple lint styles.
As discussed at #718 (comment)
@akx Your review, please.
Using https://pre-commit.ci is even better than using GitHub Actions for pre-commit.
%
pre-commit run --all-files