Skip to content

Commit 9b142c3

Browse files
authored
Merge 3bcf191 into 9eca851
2 parents 9eca851 + 3bcf191 commit 9b142c3

File tree

9 files changed

+72
-29
lines changed

9 files changed

+72
-29
lines changed

.coderabbit.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ reviews:
3737
Also consider readability and clarity of contents.
3838
Ensure that changes follow the style of one sentence per line, suggest changes if this is not met.
3939
"
40+
- path: "user_docs/en/changes.md"
41+
instructions: "
42+
Ensure each change log entry references an issue or pull request number.
43+
Change log entries can also include a reference to a GitHub author.
44+
Examples of valid change log entries:
45+
* Item with sub-items (#123, @username):
46+
* sub-item
47+
* bar (#342)
48+
* Item with.
49+
Multiple lines. (#143)
50+
"
4051
tools:
4152
github-checks:
4253
enabled: true

.pre-commit-config.yaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
repos:
2+
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.6.0
5+
hooks:
6+
# Checks python syntax
7+
- id: check-ast
8+
- id: check-case-conflict
9+
- id: check-merge-conflict
10+
- id: end-of-file-fixer
11+
- id: trailing-whitespace
12+
213
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
# Ruff version.
4-
rev: v0.4.10
14+
# Matches Ruff version in requirements.
15+
rev: v0.5.0
516
hooks:
6-
# Run the linter.
717
- id: ruff
18+
name: lint with ruff
819
args: [ --fix ]
9-
# Run the formatter.
1020
- id: ruff-format
21+
name: format with ruff
1122

1223
- repo: local
1324
hooks:
25+
- id: checkPot
26+
name: translation string check
27+
entry: cmd.exe /c "scons checkPot -j 4"
28+
language: system
29+
pass_filenames: false
30+
types: [python, pofile]
31+
- id: unitTest
32+
name: unit tests
33+
entry: ./rununittests.bat
34+
language: script
35+
pass_filenames: false
36+
types: [python, c, c++, batch]
1437
- id: licenseCheck
1538
name: Check license compatibility of pip dependencies
1639
files: requirements.txt

appveyor/scripts/tests/lintCheck.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
$lintOutput = (Resolve-Path .\testOutput\lint\)
2-
$lintOutput = "$lintOutput\PR-lint.xml"
32
.\runlint.bat "$lintOutput"
43
if ($LastExitCode -ne 0) {
54
Set-AppveyorBuildVariable "testFailExitCode" $LastExitCode

appveyor/scripts/tests/unitTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
$outDir = (Resolve-Path .\testOutput\unit\)
22
$unitTestsXml = "$outDir\unitTests.xml"
3-
.\rununittests.bat --output-file "$unitTestsXml"
3+
.\rununittests.bat --output-file "$unitTestsXml" -v
44
if($LastExitCode -ne 0) {
55
Set-AppveyorBuildVariable "testFailExitCode" $LastExitCode
66
Add-AppveyorMessage "FAIL: Unit tests. See test results for more information."

projectDocs/dev/lint.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,3 @@ Our linting process involves running [Ruff](https://docs.astral.sh/ruff) to pick
77
## Lint integration
88

99
For faster lint results, or greater integration with your tools you may want to set up Ruff with your IDE.
10-
11-
## Pre-commit hooks
12-
13-
[Pre-commit hooks](https://pre-commit.com/) can be used to automatically run linting on files staged for commit.
14-
This will automatically apply lint fixes where possible, otherwise cancelling the commit on lint issues.
15-
16-
From a shell, set up pre-commit scripts for your NVDA python environment:
17-
18-
1. `venvUtils\ensureAndActivate.bat`
19-
1. `pre-commit install`
20-
21-
Alternatively, set up pre-commit scripts globally:
22-
23-
1. `pip install pre-commit`
24-
1. `pre-commit install --allow-missing-config`

projectDocs/testing/automated.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
## Running Automated Tests
2+
23
If you make a change to the NVDA code, you should run NVDA's automated tests.
34
These tests help to ensure that code changes do not unintentionally break functionality that was previously working.
45

6+
### Pre-commit hooks
7+
8+
[Pre-commit hooks](https://pre-commit.com/) can be used to automatically run linting, translatable string checks and unit tests on files staged for commit.
9+
This will automatically apply lint fixes where possible, and will cancel the commit on lint issues and other test failures.
10+
11+
From a shell, set up pre-commit scripts for your NVDA python environment:
12+
13+
1. `venvUtils\ensureAndActivate.bat`
14+
1. `pre-commit install`
15+
16+
Alternatively, set up pre-commit scripts globally:
17+
18+
1. `pip install pre-commit`
19+
1. `pre-commit install --allow-missing-config`
20+
21+
To skip pre-commit hooks from triggering, use the `--no-verify` CLI option.
22+
Example: `git commit -m "message" --no-verify`.
23+
524
### Translatable string checks
25+
626
To run the translatable string checks (which check that all translatable strings have translator comments), run:
727

828
```cmd

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ builtins = [
1616
"npgettext",
1717
]
1818

19-
logger-objects = ["logHandler.log"]
20-
2119
include = [
2220
"*.py",
2321
"*.pyw",
22+
"sconstruct",
23+
"*sconscript",
2424
]
2525

2626
exclude = [
@@ -51,6 +51,7 @@ ignore = [
5151
# indentation contains tabs
5252
"W191",
5353
]
54+
logger-objects = ["logHandler.log"]
5455

5556
[tool.licensecheck]
5657
using = "requirements:requirements.txt"
@@ -79,4 +80,3 @@ ignore_packages = [
7980
"wxPython", # wxWindows Library License
8081
"pillow", # PIL Software License
8182
]
82-

runlint.bat

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
@echo off
2-
rem runlint [<output file>]
3-
rem Lints the entire repository
2+
rem runlint [<output dir>]
3+
rem Lints and formats all python files
44
set hereOrig=%~dp0
55
set here=%hereOrig%
66
if #%hereOrig:~-1%# == #\# set here=%hereOrig:~0,-1%
77
set scriptsDir=%here%\venvUtils
88

9-
if "%1" NEQ "" set ruffArgs=--output-file=%1 --output-format=junit
10-
call "%scriptsDir%\venvCmd.bat" ruff check --fix %ruffArgs%
9+
set ruffCheckArgs=
10+
set ruffFormatArgs=
11+
if "%1" NEQ "" set ruffCheckArgs=--output-file=%1/PR-lint.xml --output-format=junit
12+
if "%1" NEQ "" set ruffFormatArgs=--diff > %1/lint-diff.diff
13+
call "%scriptsDir%\venvCmd.bat" ruff check --fix %ruffCheckArgs%
14+
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
15+
call "%scriptsDir%\venvCmd.bat" ruff format %ruffFormatArgs%
1116
if ERRORLEVEL 1 exit /b %ERRORLEVEL%

rununittests.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ set unitTestsPath=%here%\tests\unit
77
set testOutput=%here%\testOutput\unit
88
md %testOutput%
99

10-
call "%scriptsDir%\venvCmd.bat" py -m xmlrunner discover -v -s "%unitTestsPath%" -t "%here%" --output-file "%testOutput%\unitTests.xml" %*
10+
call "%scriptsDir%\venvCmd.bat" py -m xmlrunner discover -b -s "%unitTestsPath%" -t "%here%" --output-file "%testOutput%\unitTests.xml" %*

0 commit comments

Comments
 (0)