-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-commit configuration and workflow
Add a pre-commit [1] configuration in `.pre-commit-config.yaml` and a corresponding GitHub workflow to run the checks on pull requests. The pre-commit checks use ruff [2] for both linting and formatting. Developers should integrate these checks into their local workflow by installing pre-commit and running `pre-commit install` to enable the local pre-commit hook. Note that we have removed `tox -e pep8` from the existing test workflow, since there's no reason to run the linting as part of the Python version matrix. [1]: https://pre-commit.com/ [2]: https://docs.astral.sh/ruff/
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,31 @@ | ||
name: Run pre-commit checks | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
run-linters: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Configure caching | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: precommit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} | ||
|
||
- name: Install pre-commit | ||
run: | | ||
pip install pre-commit | ||
- name: Run linters | ||
run: | | ||
pre-commit run --all-files |
This file contains 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 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,24 @@ | ||
repos: | ||
- repo: https://github.com/Lucas-C/pre-commit-hooks | ||
rev: v1.5.5 | ||
hooks: | ||
- id: remove-tabs | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer | ||
- id: check-added-large-files | ||
- id: check-case-conflict | ||
- id: detect-private-key | ||
- id: check-yaml | ||
args: [--allow-multiple-documents] | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.5.1 | ||
hooks: | ||
- id: ruff | ||
args: [ --fix ] | ||
- id: ruff-format |