Skip to content

Commit ea4bef1

Browse files
committed
Run pre-commit in CI on a lint-only environment
pre-commit has never run in GitHub Actions; only the external pre-commit.ci service ran it. Now that the formatting hooks are skipped there, because they need an environment that service does not build, this job runs them. It installs the "lint" extra alone, read out of pyproject.toml at run time so the versions are not restated in the workflow. That needs neither torch nor the optional dependencies, unlike static-checks, which installs .[all,testing] before running formatters. static-checks is left unchanged. Running both routes keeps the copyright and pyrefly coverage it provides, and makes CI fail if pre-commit and runtests.sh ever disagree about the same files. Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>
1 parent 1a5d6c8 commit ea4bef1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

.github/workflows/cicd_tests.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ env:
5252
# When support is dropped for a version it is important to update these as appropriate.
5353

5454
jobs:
55+
pre-commit: # Run the hooks pre-commit.ci skips, using the tools pyproject.toml pins
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v7
59+
- name: Set up Python ${{ env.PYTHON_VER1 }}
60+
uses: actions/setup-python@v6
61+
with:
62+
python-version: ${{ env.PYTHON_VER1 }}
63+
cache: 'pip'
64+
- name: Install lint tools
65+
run: |
66+
# the lint extra alone, so this job needs neither torch nor the optional dependencies
67+
python -m pip install --upgrade pip
68+
python -c "import tomllib; print('\n'.join(tomllib.load(open('pyproject.toml','rb'))['project']['optional-dependencies']['lint']))" > lint-requirements.txt
69+
cat lint-requirements.txt
70+
python -m pip install -r lint-requirements.txt
71+
rm lint-requirements.txt
72+
- name: Run pre-commit
73+
run: python -m pre_commit run --all-files --show-diff-on-failure
74+
5575
static-checks: # Perform static type and other checks using runtests.sh
5676
runs-on: ubuntu-latest
5777
strategy:

0 commit comments

Comments
 (0)