Skip to content
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b10884d
Swap pre-commit for prek (#20305)
LeonarddeR Jun 10, 2026
3a3944e
Convert to native prek.toml, drop pre-commit.ci config
LeonarddeR Jun 11, 2026
d14b822
Add autofix-or-fail GitHub Actions workflow
LeonarddeR Jun 11, 2026
213d8ce
Settle uv env before prek gate and cross-reference python version in …
LeonarddeR Jun 11, 2026
48c1aec
Add scheduled prek auto-update workflow
LeonarddeR Jun 11, 2026
313f715
Use consistent "Prek auto-update" title for auto-update PR
LeonarddeR Jun 11, 2026
4c22e96
Docs and workflows: complete pre-commit.ci to prek + GitHub Actions m…
LeonarddeR Jun 11, 2026
723f63a
Run prek via uvx instead of uv run in autofix workflow
LeonarddeR Jun 11, 2026
8e0b7c4
Drop redundant prek hook install from add-new-language workflow
LeonarddeR Jun 11, 2026
8716980
Add NVDA license headers to the new prek workflows
LeonarddeR Jun 11, 2026
34a64e7
One sentence per line in the prek hooks doc
LeonarddeR Jun 11, 2026
4b26a96
Don't activate uv venv
LeonarddeR Jun 11, 2026
e35c974
Run autofix on windows
LeonarddeR Jun 11, 2026
dc817a3
Definitely need submodules
LeonarddeR Jun 11, 2026
d01ee9a
Create a linter error on purpose so autofix will pick it up on fork
LeonarddeR Jun 11, 2026
360e523
Auto-fix: apply prek fixes
invalid-email-address Jun 11, 2026
5c2768e
Use prek-action for lint gate and standalone prek for auto-update
LeonarddeR Jun 11, 2026
b2aa55c
Update docs
LeonarddeR Jun 11, 2026
fa7beab
Guard prek auto-update to the upstream repo
LeonarddeR Jun 11, 2026
0d24efa
Merge remote-tracking branch 'origin/master' into prek
LeonarddeR Jun 22, 2026
4f97e6d
Review actions
LeonarddeR Jun 22, 2026
9ef3c90
Bump action deps
LeonarddeR Jun 22, 2026
320725b
Merge remote-tracking branch 'origin/master' into prek
LeonarddeR Jun 23, 2026
6af4c05
Back to .pre-commit-config.yaml
LeonarddeR Jun 23, 2026
433dcce
Remove stale mentions of prek.toml
LeonarddeR Jun 24, 2026
20a40ea
Review actions
LeonarddeR Jun 25, 2026
10a28c7
Update .github/workflows/autofix.yml
LeonarddeR Jun 26, 2026
5004afa
Update job
LeonarddeR Jun 29, 2026
42f85da
Merge branch 'master' into prek
seanbudd Jun 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/add-new-language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ jobs:
crowdinProjectID: ${{ vars.CROWDIN_PROJECT_ID }}
crowdinAuthToken: ${{ secrets.CROWDIN_AUTH_TOKEN }}

- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
pre-commit install

# Job will fail if pre-commit checks fail
Comment thread
LeonarddeR marked this conversation as resolved.
# Linting is handled by the autofix-or-fail workflow, which runs on the push
# of the addLanguage branch below (a non-protected branch); no local hook is
# installed here.
- name: Commit language files only
id: commit
shell: bash
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# 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

# This flow has a single job with two roles:
# - Autofix: on push events, run the fixer hooks (the "autofix" group), commit
# any fixes back to the branch, and push them.
# - Gate: on every event, run all hooks (minus the heavy/env-bound ones that
# have their own dedicated jobs in testAndPublish.yml) as a blocking check.
#
# The autofix step needs write access. On fork `pull_request` events GitHub
# downgrades the token to read-only, so autofix is guarded to push events only
# (it runs in a contributor's fork when they enable Actions, and on NV Access
# branches). On a fork PR with Actions disabled nothing gets fixed, so
# any lint issue fails the gate, forcing a manual fix or enabling fork Actions.

name: Autofix or fail

on:
Comment thread
LeonarddeR marked this conversation as resolved.
push:
# Never auto-fix or push to the protected branches; PRs targeting them are
# handled by the pull_request trigger below.
branches-ignore:
- master
- beta
- rc
pull_request:
branches:
- master
- beta
- rc
Comment thread
seanbudd marked this conversation as resolved.
Comment thread
seanbudd marked this conversation as resolved.
permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
autofix:
name: Auto-fix and lint gate
runs-on: windows-2025-vs2026
steps:
- name: Checkout repository
uses: actions/checkout@v6
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"
# prek is run via `uvx` (an ephemeral, isolated tool run) rather than
# `uv run`. `uv run` would sync the project environment and could silently
# regenerate uv.lock as a side effect, masking a genuinely stale lock and
# causing spurious mid-run failures. `uvx` touches no project state, so the
# uv-lock hook itself is what gates lock staleness.
# Autofix only on push events (write token), and never react to the bot's
# own auto-fix commit. A commit pushed with this repo's GITHUB_TOKEN does
# not re-trigger this repo's own push workflow, so the fix commit cannot
# loop back into another autofix run here; the actor guard below just
# covers the rare manual re-run case too. (Note: on a fork PR the fix
# commit DOES start a fresh pull_request run on the base repo, since that
# is a different repository - but it lands as "action required" pending
# maintainer approval because the bot is the triggering actor.)
- name: Apply prek auto-fixes
if: github.event_name == 'push' && github.actor != 'github-actions[bot]'
Comment thread
LeonarddeR marked this conversation as resolved.
Outdated
shell: bash
env:
REF_NAME: ${{ github.ref_name }}
run: |
# Fixers exit non-zero when they change files; that is expected here, so
# do not let it fail the job.
uvx prek run --group autofix --all-files || true
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
# Blocking lint gate: runs on every event. The 6 skipped hooks are the
# heavy / environment-bound checks that have their own dedicated jobs in
# testAndPublish.yml. A non-zero exit here fails the job.
# Run via prek-action (not `uvx prek`) so prek's hook environments are
# cached across runs. The action installs prek standalone, so it does not
# touch uv.lock; on push events the gate runs against the tree already
# fixed by the autofix step above.
- 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
49 changes: 49 additions & 0 deletions .github/workflows/prekAutoUpdate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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 * *'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SaschaCowley - thoughts on keeping this manual only for now?

Suggested change
- cron: '0 0 1 * *'
# - cron: '0 0 1 * *'

workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
prekAutoUpdate:
name: Prek auto-update
# Upstream-only maintenance task. Forks enable Actions for the autofix
# workflow; without this guard they would also run this schedule and open
# spurious auto-update PRs against their own fork.
if: github.repository == 'nvaccess/nvda'
Comment thread
LeonarddeR marked this conversation as resolved.
Outdated
runs-on: ubuntu-latest
steps:
# Auto-update only rewrites hook revisions in prek.toml,
# so submodule content is not needed.
- name: Checkout code
uses: actions/checkout@v6
# Install prek as a standalone binary; auto-update only rewrites hook
# revisions in prek.toml, so neither uv nor the project environment is
# needed. The cargo-dist installer adds prek to $GITHUB_PATH.
- 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SaschaCowley thoughts on changing this to 7? higher?

Suggested change
run: prek auto-update --cooldown-days 3
run: prek auto-update --cooldown-days 7

- name: Create pull request
uses: peter-evans/create-pull-request@v7
Comment thread
LeonarddeR marked this conversation as resolved.
Outdated
with:
branch: prek-autoupdate
delete-branch: true
title: Prek auto-update
commit-message: Prek auto-update
author: github-actions <github-actions@github.com>
body: |
Automated update of prek hook revisions in `prek.toml`.
12 changes: 6 additions & 6 deletions .github/workflows/testAndPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ jobs:
architecture: ${{ env.defaultArch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
- name: Run pre-commit
- name: Run prek
run: |
# Ensure uv environment is up to date.
# If the uv environment is outdated, running pre-commit will trigger uv to generate a uv.lock file,
# which causes checkPo to fail without clear errors because pre-commit fails when files are changed during its run.
uv run pre-commit run uv-lock --all-files
# Run pre-commit on the translations
uv run pre-commit run checkPo --all-files
# If the uv environment is outdated, running prek will trigger uv to generate a uv.lock file,
# which causes checkPo to fail without clear errors because prek fails when files are changed during its run.
uv run prek run uv-lock --all-files
# Run prek on the translations
uv run prek run checkPo --all-files
Comment thread
LeonarddeR marked this conversation as resolved.
- name: Add job summary
if: ${{ failure() }}
shell: bash
Expand Down
172 changes: 0 additions & 172 deletions .pre-commit-config.yaml

This file was deleted.

Loading
Loading