-
-
Notifications
You must be signed in to change notification settings - Fork 801
Swap pre-commit for prek (#20305) #20314
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
LeonarddeR
wants to merge
30
commits into
nvaccess:master
Choose a base branch
from
LeonarddeR:prek
base: master
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.
+201
−108
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
b10884d
Swap pre-commit for prek (#20305)
LeonarddeR 3a3944e
Convert to native prek.toml, drop pre-commit.ci config
LeonarddeR d14b822
Add autofix-or-fail GitHub Actions workflow
LeonarddeR 213d8ce
Settle uv env before prek gate and cross-reference python version in …
LeonarddeR 48c1aec
Add scheduled prek auto-update workflow
LeonarddeR 313f715
Use consistent "Prek auto-update" title for auto-update PR
LeonarddeR 4c22e96
Docs and workflows: complete pre-commit.ci to prek + GitHub Actions m…
LeonarddeR 723f63a
Run prek via uvx instead of uv run in autofix workflow
LeonarddeR 8e0b7c4
Drop redundant prek hook install from add-new-language workflow
LeonarddeR 8716980
Add NVDA license headers to the new prek workflows
LeonarddeR 34a64e7
One sentence per line in the prek hooks doc
LeonarddeR 4b26a96
Don't activate uv venv
LeonarddeR e35c974
Run autofix on windows
LeonarddeR dc817a3
Definitely need submodules
LeonarddeR d01ee9a
Create a linter error on purpose so autofix will pick it up on fork
LeonarddeR 360e523
Auto-fix: apply prek fixes
invalid-email-address 5c2768e
Use prek-action for lint gate and standalone prek for auto-update
LeonarddeR b2aa55c
Update docs
LeonarddeR fa7beab
Guard prek auto-update to the upstream repo
LeonarddeR 0d24efa
Merge remote-tracking branch 'origin/master' into prek
LeonarddeR 4f97e6d
Review actions
LeonarddeR 9ef3c90
Bump action deps
LeonarddeR 320725b
Merge remote-tracking branch 'origin/master' into prek
LeonarddeR 6af4c05
Back to .pre-commit-config.yaml
LeonarddeR 433dcce
Remove stale mentions of prek.toml
LeonarddeR 20a40ea
Review actions
LeonarddeR 10a28c7
Update .github/workflows/autofix.yml
LeonarddeR 5004afa
Update job
LeonarddeR 42f85da
Merge branch 'master' into prek
seanbudd f73b431
Merge remote-tracking branch 'origin/master' into prek
LeonarddeR 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
Some comments aren't visible on the classic Files Changed page.
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,87 @@ | ||
| # A part of NonVisual Desktop Access (NVDA) | ||
| # Copyright (C) 2026 NV Access Limited, Leonard de Ruijter | ||
| # This file may be used under the terms of the GNU General Public License, version 2 or later, as modified by the NVDA license. | ||
| # For full terms and any additional permissions, see the NVDA license file: https://github.com/nvaccess/nvda/blob/master/copying.txt | ||
|
|
||
| name: Autofix or fail | ||
|
|
||
| on: | ||
|
LeonarddeR marked this conversation as resolved.
|
||
| push: | ||
| # Never auto-fix the protected branches; PRs to them use pull_request below. | ||
| branches-ignore: | ||
| - master | ||
| - beta | ||
| - rc | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| - beta | ||
| - rc | ||
|
seanbudd marked this conversation as resolved.
|
||
| - 'try-**' | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| autofix: | ||
| name: Auto-fix and lint gate | ||
| # On the base repo the pull_request run is the gate; skip its push run on non-Fork pushes to | ||
| # avoid a duplicate. Fork pushes still run for autofix. | ||
| if: github.event_name != 'push' || github.repository != 'nvaccess/nvda' | ||
| runs-on: windows-2025-vs2026 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| submodules: true | ||
| - name: Set up python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| # Keep in sync with defaultPythonVersion in testAndPublish.yml. | ||
| python-version: '3.13.13' | ||
| - name: Install the latest version of uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| activate-environment: "false" | ||
| # Autofix role: run the fixer hooks (the "autofix" group) and push the fixes. | ||
| - name: Apply prek auto-fixes | ||
| if: github.event_name == 'push' | ||
| shell: bash | ||
| env: | ||
| REF_NAME: ${{ github.ref_name }} | ||
| run: | | ||
| # Fixers exit non-zero when they change files. Some fixers' output feeds | ||
| # another fixer, so a single pass may not reach a stable tree. | ||
| # Re-run on the fixed tree until prek exits clean or we hit the cap. | ||
| for attempt in 1 2 3; do | ||
| if uvx prek run --group autofix --all-files; then | ||
| break | ||
| fi | ||
| done | ||
| if ! git diff --quiet; then | ||
| git config user.name "github-actions" | ||
| git config user.email "github-actions@github.com" | ||
| git add -A | ||
| git commit -m "Auto-fix: apply prek fixes" | ||
| # Push via an explicit refspec so this works even if checkout left us | ||
| # in a detached HEAD state. | ||
| git push origin HEAD:"$REF_NAME" | ||
| fi | ||
| # Gate role: the merge-required blocking check (non-zero exit fails the job). | ||
| # The 6 skipped hooks are the heavy/env-bound ones with dedicated jobs in | ||
| # testAndPublish.yml. | ||
| - name: Lint gate | ||
| uses: j178/prek-action@v2 | ||
| with: | ||
| extra-args: >- | ||
| --all-files | ||
| --skip checkPo | ||
| --skip scons-source | ||
| --skip checkPot | ||
| --skip unitTest | ||
| --skip licenseCheck | ||
| --skip pyright | ||
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,51 @@ | ||||||
| # A part of NonVisual Desktop Access (NVDA) | ||||||
| # Copyright (C) 2026 NV Access Limited, Leonard de Ruijter | ||||||
| # This file may be used under the terms of the GNU General Public License, version 2 or later, as modified by the NVDA license. | ||||||
| # For full terms and any additional permissions, see the NVDA license file: https://github.com/nvaccess/nvda/blob/master/copying.txt | ||||||
|
|
||||||
| name: Prek auto-update | ||||||
|
|
||||||
| on: | ||||||
| schedule: | ||||||
| # Monthly, at midnight on the first day of the month. | ||||||
| - cron: '0 0 1 * *' | ||||||
|
Member
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. @SaschaCowley - thoughts on keeping this manual only for now?
Suggested change
|
||||||
| workflow_dispatch: | ||||||
|
|
||||||
| permissions: | ||||||
| contents: write | ||||||
| pull-requests: write | ||||||
|
|
||||||
| jobs: | ||||||
| prekAutoUpdate: | ||||||
| name: Prek auto-update | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v7 | ||||||
| # Install prek as a standalone binary | ||||||
| - name: Install prek | ||||||
| run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/latest/download/prek-installer.sh | sh | ||||||
| # --cooldown-days skips releases younger than 3 days, avoiding pinning to | ||||||
| # a freshly published (and potentially yanked/broken) hook revision. | ||||||
| - name: Run prek auto-update | ||||||
| run: prek auto-update --cooldown-days 3 | ||||||
|
Member
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. @SaschaCowley thoughts on changing this to 7? higher?
Suggested change
|
||||||
| - name: Create pull request | ||||||
| shell: bash | ||||||
| env: | ||||||
| GITHUB_TOKEN: ${{ github.token }} | ||||||
| run: | | ||||||
| if git diff --quiet; then | ||||||
| echo "No hook updates available." | ||||||
| exit 0 | ||||||
| fi | ||||||
| git config --local user.name "github-actions" | ||||||
| git config --local user.email "github-actions@github.com" | ||||||
| git checkout -b prek-autoupdate | ||||||
| git commit -am "Prek auto-update" | ||||||
| # Force push so a re-run replaces a stale auto-update branch. | ||||||
| git push --force --set-upstream origin prek-autoupdate | ||||||
| # Reuse the existing PR if one is already open from a previous run. | ||||||
| gh pr create --base master --head prek-autoupdate \ | ||||||
| --title "Prek auto-update" \ | ||||||
| --body "Automated update of prek hook revisions." \ | ||||||
| || echo "A pull request for prek-autoupdate already exists." | ||||||
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
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.