Skip to content

Commit 31b369b

Browse files
authored
Merge bf9c936 into 7a42d8e
2 parents 7a42d8e + bf9c936 commit 31b369b

File tree

18 files changed

+529
-30
lines changed

18 files changed

+529
-30
lines changed
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
name: Run tests and publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- beta
8+
- rc
9+
- 'try-**'
10+
tags:
11+
- 'release-**'
12+
13+
pull_request:
14+
branches:
15+
- master
16+
- beta
17+
- rc
18+
19+
workflow_dispatch:
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
env:
26+
START_BUILD_NUMBER: 50000
27+
pullRequestNumber: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
28+
scons_publisher: NV Access
29+
# Comment out any of the feature_* variables to disable the respective build feature.
30+
# They are checked for existence of content, not specific value.
31+
# feature_buildSymbols: configured
32+
# feature_uploadSymbolsToMozilla: configured
33+
# feature_buildAppx: configured
34+
# feature_crowdinSync: configured
35+
# feature_signing: configured
36+
37+
jobs:
38+
buildNVDA:
39+
name: Build NVDA
40+
runs-on: windows-latest
41+
steps:
42+
- name: Checkout NVDA
43+
uses: actions/checkout@v4
44+
with:
45+
submodules: true
46+
- name: Install dependencies
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: '3.11'
50+
architecture: x86
51+
- name: Set version variables
52+
run: ci/scripts/setBuildVersionVars.ps1
53+
- name: Set scons args
54+
run: ci/scripts/setSconsArgs.ps1
55+
- name: Prepare source code
56+
shell: cmd
57+
run: scons source %sconsArgs% ${{ !runner.debug && '--all-cores' || '-j1' }}
58+
- name: Prepare for tests
59+
run: ci/scripts/tests/beforeTests.ps1
60+
- name: Cache scons build
61+
uses: actions/cache/save@v4
62+
with:
63+
path: ${{ github.workspace }}
64+
key: ${{ github.ref }}-${{ github.run_id }}
65+
66+
checkPot:
67+
name: Check translator comments
68+
runs-on: windows-latest
69+
needs: buildNVDA
70+
steps:
71+
- name: Checkout cached build
72+
uses: actions/cache/restore@v4
73+
with:
74+
path: ${{ github.workspace }}
75+
key: ${{ github.ref }}-${{ github.run_id }}
76+
fail-on-cache-miss: true
77+
- name: Check comments for translators
78+
run: ci/scripts/tests/translationCheck.ps1
79+
- name: Upload artifact
80+
if: ${{ success() || failure() }}
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: makePot results
84+
path: |
85+
output/nvda.pot
86+
output/potSourceFileList.txt
87+
88+
licenseCheck:
89+
name: Check license compatibility of dependencies
90+
runs-on: windows-latest
91+
needs: buildNVDA
92+
steps:
93+
- name: Checkout cached build
94+
uses: actions/cache/restore@v4
95+
with:
96+
path: ${{ github.workspace }}
97+
key: ${{ github.ref }}-${{ github.run_id }}
98+
fail-on-cache-miss: true
99+
- name: License check
100+
run: ci/scripts/tests/licenseCheck.ps1
101+
102+
unitTests:
103+
name: Run unit tests
104+
runs-on: windows-latest
105+
needs: buildNVDA
106+
steps:
107+
- name: Checkout cached build
108+
uses: actions/cache/restore@v4
109+
with:
110+
path: ${{ github.workspace }}
111+
key: ${{ github.ref }}-${{ github.run_id }}
112+
fail-on-cache-miss: true
113+
- name: Run unit tests
114+
run: ci/scripts/tests/unitTests.ps1
115+
- name: Replace relative paths in unit test results
116+
if: ${{ success() || failure() }}
117+
# Junit reports fail on these
118+
shell: bash
119+
run: sed -i 's|file="..\\|file="|g' testOutput/unit/unitTests.xml
120+
- name: Upload artifact
121+
if: ${{ success() || failure() }}
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: Unit tests results
125+
path: testOutput/unit/unitTests.xml
126+
- name: Publish unit test report
127+
uses: mikepenz/action-junit-report@v5
128+
if: ${{ success() || failure() }}
129+
with:
130+
check_name: Unit tests
131+
detailed_summary: true
132+
annotate_only: true
133+
report_paths: testOutput/unit/unitTests.xml
134+
135+
createLauncher:
136+
name: Create launcher
137+
runs-on: windows-latest
138+
needs: buildNVDA
139+
steps:
140+
- name: Checkout cached build
141+
uses: actions/cache/restore@v4
142+
with:
143+
path: ${{ github.workspace }}
144+
key: ${{ github.ref }}-${{ github.run_id }}
145+
fail-on-cache-miss: true
146+
- name: Set version variables
147+
run: ci/scripts/setBuildVersionVars.ps1
148+
- name: Set scons args
149+
run: ci/scripts/setSconsArgs.ps1
150+
- name: Prepare source code for launcher
151+
shell: cmd
152+
run: scons %sconsOutTargets% %sconsArgs% ${{ !runner.debug && '--all-cores' || '-j1'}}
153+
- name: Build launcher
154+
shell: cmd
155+
run: scons launcher %sconsArgs% ${{ !runner.debug && '--all-cores' || '-j1'}}
156+
- name: Export package list
157+
shell: cmd
158+
run: .\venvUtils\exportPackageList.bat output\installed_python_packages.txt
159+
- name: Upload launcher
160+
id: uploadLauncher
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: NVDA launcher
164+
path: output/nvda*.exe
165+
- name: Upload documentation artifacts
166+
uses: actions/upload-artifact@v4
167+
id: uploadDocsArtifacts
168+
with:
169+
name: Documentation files
170+
path: |
171+
output/devDocs
172+
output/*.html
173+
output/*.css
174+
- name: Upload build artifacts
175+
uses: actions/upload-artifact@v4
176+
id: uploadBuildArtifacts
177+
with:
178+
name: Controller client and packaging metadata
179+
path: |
180+
output/nvda*controllerClient.zip
181+
output/library_modules.txt
182+
output/installed_python_packages.txt
183+
- name: Add job summary
184+
shell: bash
185+
run: |
186+
echo "* [Download the NVDA launcher](${{ steps.uploadLauncher.outputs.artifact-url }}) (${{ steps.uploadLauncher.outputs.artifact-digest }})" >> $GITHUB_STEP_SUMMARY
187+
echo "* [Download the documentation](${{ steps.uploadDocsArtifacts.outputs.artifact-url }})" >> $GITHUB_STEP_SUMMARY
188+
echo "* [Download the other build artifacts](${{ steps.uploadBuildArtifacts.outputs.artifact-url }})" >> $GITHUB_STEP_SUMMARY
189+
echo " * Controller client" >> $GITHUB_STEP_SUMMARY
190+
echo " * Packaging metadata (library modules, installed python packages)" >> $GITHUB_STEP_SUMMARY
191+
192+
systemTests:
193+
name: Run system tests
194+
runs-on: windows-latest
195+
needs: createLauncher
196+
steps:
197+
- name: Checkout cached build
198+
uses: actions/cache/restore@v4
199+
with:
200+
path: ${{ github.workspace }}
201+
key: ${{ github.ref }}-${{ github.run_id }}
202+
fail-on-cache-miss: true
203+
- name: Get NVDA launcher
204+
id: getLauncher
205+
uses: actions/download-artifact@v4
206+
with:
207+
name: NVDA launcher
208+
path: output
209+
- name: Install NVDA
210+
run: ci/scripts/installNVDA.ps1
211+
env:
212+
nvdaLauncherDir: ${{ steps.getLauncher.outputs.download-path }}
213+
- name: Upload install log
214+
if: ${{ success() || failure() }}
215+
uses: actions/upload-artifact@v4
216+
with:
217+
name: Install log
218+
path: |
219+
testOutput/install
220+
!testOutput/install/nvda_install_temp.log
221+
- name: Run system tests
222+
run: ci/scripts/tests/systemTests.ps1
223+
env:
224+
nvdaLauncherDir: ${{ steps.getLauncher.outputs.download-path }}
225+
- name: Upload system tests results
226+
if: ${{ success() || failure() }}
227+
uses: actions/upload-artifact@v4
228+
with:
229+
name: System tests results
230+
path: testOutput/system
231+
- name: Publish system test report
232+
uses: mikepenz/action-junit-report@v5
233+
if: ${{ success() || failure() }}
234+
with:
235+
check_name: System tests
236+
detailed_summary: true
237+
annotate_only: true
238+
report_paths: testOutput/system/systemTests.xml
239+
240+
cleanupCache:
241+
# Cache deletion on pull_request events cannot occur on PRs from forks
242+
# as PRs from forks do not get write permissions from pull_request events.
243+
# Alternatively, we can change the event trigger to pull_request_target,
244+
# however that might introduce security risks as it grants fork PRs greater permissions.
245+
# In these cases we can always let GitHub handle cache deletion:
246+
# auto deletion after 7 days or limits are hit
247+
name: Cleanup cache
248+
permissions:
249+
actions: write
250+
needs: [checkPot, licenseCheck, unitTests, systemTests]
251+
if: ${{ always() && (github.event.push || github.event.pull_request.head.repo.owner == github.repository_owner) }}
252+
runs-on: ubuntu-latest
253+
steps:
254+
- name: Cleanup cache
255+
shell: bash
256+
run: gh cache delete ${{ github.ref }}-${{ github.run_id }}
257+
env:
258+
GH_TOKEN: ${{ github.token }}
259+
GH_REPO: ${{ github.repository }}
260+
261+
release:
262+
name: Release NVDA
263+
permissions:
264+
contents: write
265+
runs-on: ubuntu-latest
266+
needs: [checkPot, licenseCheck, unitTests, systemTests]
267+
if: startsWith(github.ref_name, 'release-') && !contains(github.ref_name, 'beta')
268+
steps:
269+
- name: Get normalized tag names
270+
id: getReleaseNotes
271+
shell: bash
272+
run: |
273+
echo RELEASE_NAME=$GITHUB_REF_NAME | sed 's/release-//g' >> $GITHUB_OUTPUT
274+
echo NORMALIZED_TAG_NAME=$GITHUB_REF_NAME | sed 's/\./-/g' | sed 's/release-//g' >> $GITHUB_OUTPUT
275+
- name: Get NVDA launcher
276+
uses: actions/download-artifact@v4
277+
with:
278+
name: NVDA launcher
279+
path: output
280+
- name: Publish release
281+
uses: softprops/action-gh-release@v2
282+
with:
283+
prerelease: ${{ contains(github.ref_name, 'rc') }}
284+
make_latest: ${{ !contains(github.ref_name, 'rc') }}
285+
discussion_category_name: ${{ !contains(github.ref_name, 'rc') && 'Releases' || '' }}
286+
name: ${{ steps.getReleaseNotes.outputs.RELEASE_NAME }}
287+
files: output/nvda*.exe
288+
body: Highlights and download links can be found in the [release blog post](https://www.nvaccess.org/post/nvda-${{ steps.getReleaseNotes.outputs.NORMALIZED_TAG_NAME }}/)

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ repos:
147147
types_or: [python, c, c++, batch]
148148
- id: licenseCheck
149149
name: Check license compatibility of pip dependencies
150-
files: ^(requirements\.txt|runlicensecheck\.bat)$
150+
files: ^(requirements\.txt|runlicensecheck\.bat|pyproject.toml)$
151151
entry: ./runlicensecheck.bat
152152
language: script
153153
pass_filenames: false

ci/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Continuous Integration with GitHub Actions
2+
3+
[Documentation about GitHub Actions](https://docs.github.com/en/actions)
4+
5+
## Builds
6+
7+
Builds will fail if any command has a non-zero exit code.
8+
PowerShell scripts continue on non-terminating errors unless the file is prefixed with `$ErrorActionPreference = "Stop";`.
9+
10+
### Build process
11+
12+
1. Checkout NVDA repository with submodules.
13+
1. Install dependencies (or use cache).
14+
1. Set version and scons variables.
15+
1. Prepare source code.
16+
1. Build launcher.
17+
1. Install NVDA.
18+
1. Prepare for tests.
19+
1. Run tests.
20+
1. Clean up build cache.
21+
1. Release NVDA if this is a tagged release.
22+
23+
## Testing
24+
25+
Before testing we:
26+
27+
* Create directories to store results.
28+
* Install NVDA for system tests
29+
30+
The tests we perform are:
31+
32+
* check translation comments
33+
* license checks
34+
* unit tests
35+
* system tests
36+
37+
## Artifacts
38+
39+
* NVDA launcher.
40+
* Test results.

ci/scripts/installNVDA.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
$errorCode=0
2+
$nvdaLauncherFile=$(Resolve-Path "$env:nvdaLauncherDir\nvda*.exe")
3+
$nvdaInstallerLogDir=$(Resolve-Path ".\testOutput\install")
4+
$installerLogFilePath="$nvdaInstallerLogDir\nvda_install_temp.log"
5+
$installerCrashDumpPath="$nvdaInstallerLogDir\nvda_crash.dmp"
6+
$installerProcess=Start-Process -FilePath "$nvdaLauncherFile" -ArgumentList "--install-silent --debug-logging --log-file $installerLogFilePath" -passthru
7+
try {
8+
$installerProcess | Wait-Process -Timeout 180 -ErrorAction Stop
9+
$errorCode=$installerProcess.ExitCode
10+
} catch {
11+
Write-Output "NVDA installer process timed out.`n" >> $env:GITHUB_STEP_SUMMARY
12+
$errorCode=1
13+
}
14+
# If the installer failed to exit the log file is still in use.
15+
# We can't/shouldn't upload a file which is locked,
16+
# as a work around create a copy of the log and upload that instead.
17+
Copy-Item -Path $installerLogFilePath -Destination "$nvdaInstallerLogDir\nvda_install.log"
18+
if (Test-Path -Path $installerCrashDumpPath){
19+
Write-Output "NVDA installer process crashed.`n" >> $env:GITHUB_STEP_SUMMARY
20+
$errorCode=1
21+
}
22+
exit $errorCode

0 commit comments

Comments
 (0)