-
-
Notifications
You must be signed in to change notification settings - Fork 766
726 lines (704 loc) · 28.8 KB
/
testAndPublish.yml
File metadata and controls
726 lines (704 loc) · 28.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
name: CI/CD
on:
push:
branches:
- master
- beta
- rc
- 'try-**'
tags:
- 'release-**'
pull_request:
branches:
- master
- beta
- rc
- 'try-**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
START_BUILD_NUMBER: ${{ vars.BUILD_NUMBER_OFFSET || 0 }}
pullRequestNumber: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
scons_publisher: ${{ vars.PUBLISHER_NAME || github.repository_owner }}
# Don't send telemetry to Microsoft when using MSVC tooling, avoiding an unnecessary PowerShell script invocation.
VSCMD_SKIP_SENDTELEMETRY: 1
# Cache details about available MSVC tooling for subsequent SCons invocations to the provided file.
SCONS_CACHE_MSVC_CONFIG: ".scons_msvc_cache.json"
defaultRunner: 'windows-2025'
supportedRunners: '["windows-2022", "windows-2025"]'
defaultArch: x64
supportedArchitectures: '["x64"]'
defaultPythonVersion: '3.13.9'
supportedPythonVersions: '["3.13.9"]'
jobs:
matrix:
name: Set up matrix
runs-on: ubuntu-latest
outputs:
defaultRunner: ${{ steps.setMatrix.outputs.defaultRunner }}
supportedRunners: ${{ steps.setMatrix.outputs.supportedRunners }}
supportedArchitectures: ${{ steps.setMatrix.outputs.supportedArchitectures }}
supportedPythonVersions: ${{ steps.setMatrix.outputs.supportedPythonVersions }}
steps:
- name: Set architecture and python version
id: setMatrix
run: |
echo "defaultRunner=${{ env.defaultRunner }}" >> "$GITHUB_OUTPUT"
echo "supportedRunners=$(jq -c <<< '${{ env.supportedRunners }}')" >> "$GITHUB_OUTPUT"
echo "supportedArchitectures=$(jq -c <<< '${{ env.supportedArchitectures }}')" >> "$GITHUB_OUTPUT"
echo "supportedPythonVersions=$(jq -c <<< '${{ env.supportedPythonVersions }}')" >> "$GITHUB_OUTPUT"
buildNVDA:
name: Build NVDA
needs: matrix
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
strategy:
fail-fast: false
matrix:
arch: ${{ fromJson(needs.matrix.outputs.supportedArchitectures) }}
pythonVersion: ${{ fromJson(needs.matrix.outputs.supportedPythonVersions) }}
env:
uv-arch: ${{ matrix.arch == 'x64' && 'x86_64' || 'x86' }}
outputs:
# Note: each output variable is overwritten by the last job in the matrix.
# This is not a problem for these variables as they should be the same across jobs.
version: ${{ steps.releaseInfo.outputs.VERSION }}
versionType: ${{ steps.releaseInfo.outputs.VERSION_TYPE }}
APIVersion: ${{ steps.releaseInfo.outputs.NVDA_API_VERSION }}
APIBackCompat: ${{ steps.releaseInfo.outputs.NVDA_API_COMPAT_TO }}
steps:
- name: Checkout NVDA
uses: actions/checkout@v5
with:
submodules: recursive
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pythonVersion }}
architecture: ${{ matrix.arch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
with:
python-version: cpython-${{ matrix.pythonVersion }}-windows-${{ env.uv-arch }}-none
- name: Set version variables
run: ci/scripts/setBuildVersionVars.ps1
- name: Set scons args
run: ci/scripts/setSconsArgs.ps1
- name: Set cache key for SCons MSVC Cache
shell: bash
run: echo "SCONS_CACHE_KEY=${RUNNER_OS}-${ImageVersion}" >> $GITHUB_ENV
# On Github Actions, it can take more than two minutes for SCons to collect information about MSVC tooling, majorly impacting build performance.
# This information is static for the current Github Actions runner image.
# Therefore, cache this information with a key scoped to the current image version, ensuring that subsequent workflow runs will be much faster.
- name: SCons MSVC Cache
uses: actions/cache@v4
with:
path: ${{ env.SCONS_CACHE_MSVC_CONFIG }}
key: ${{ env.SCONS_CACHE_KEY }}
- name: Prepare source code
shell: cmd
run: scons source %sconsArgs% %sconsCores%
- name: Prepare for tests
run: ci/scripts/tests/beforeTests.ps1
- name: Cache scons build
uses: actions/cache/save@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ matrix.pythonVersion }}-${{ matrix.arch }}
- name: Store release metadata information
id: releaseInfo
run: |
Write-Output VERSION=$env:version >> $env:GITHUB_OUTPUT
Write-Output VERSION_TYPE=$env:versionType >> $env:GITHUB_OUTPUT
Write-Output NVDA_API_VERSION=$(python -c "import sys; sys.path.append('source'); from addonAPIVersion import CURRENT; print('{}.{}.{}'.format(*CURRENT))") >> $env:GITHUB_OUTPUT
Write-Output NVDA_API_COMPAT_TO=$(python -c "import sys; sys.path.append('source'); from addonAPIVersion import BACK_COMPAT_TO; print('{}.{}.{}'.format(*BACK_COMPAT_TO))") >> $env:GITHUB_OUTPUT
typeCheck:
name: Check types with Pyright
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: [matrix, buildNVDA]
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ env.defaultPythonVersion }}-${{ env.defaultArch }}
fail-on-cache-miss: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.defaultPythonVersion }}
architecture: ${{ env.defaultArch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
- name: Static type analysis
run: ci/scripts/tests/typeCheck.ps1
checkPo:
name: Check po files for errors
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: matrix
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
# Include gettext
submodules: true
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: ${{ env.defaultPythonVersion }}
architecture: ${{ env.defaultArch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
- name: Run pre-commit
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
- name: Add job summary
if: ${{ failure() }}
shell: bash
run: |
echo "PO files contain errors. Please fix them before merging." >> $GITHUB_STEP_SUMMARY
checkPot:
name: Check translator comments
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: [matrix, buildNVDA]
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ env.defaultPythonVersion }}-${{ env.defaultArch }}
fail-on-cache-miss: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.defaultPythonVersion }}
architecture: ${{ env.defaultArch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
- name: Check comments for translators
run: ci/scripts/tests/translationCheck.ps1
- name: Upload artifact
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: makePot results
path: |
output/nvda.pot
output/potSourceFileList.txt
licenseCheck:
name: Check license compatibility of dependencies
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: [matrix, buildNVDA]
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ env.defaultPythonVersion }}-${{ env.defaultArch }}
fail-on-cache-miss: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.defaultPythonVersion }}
architecture: ${{ env.defaultArch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
- name: License check
run: ci/scripts/tests/licenseCheck.ps1
unitTests:
name: Run unit tests
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: [matrix, buildNVDA]
strategy:
fail-fast: false
matrix:
arch: ${{ fromJson(needs.matrix.outputs.supportedArchitectures) }}
pythonVersion: ${{ fromJson(needs.matrix.outputs.supportedPythonVersions) }}
env:
uv-arch: ${{ matrix.arch == 'x64' && 'x86_64' || 'x86' }}
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ matrix.pythonVersion }}-${{ matrix.arch }}
fail-on-cache-miss: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pythonVersion }}
architecture: ${{ matrix.arch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
with:
python-version: cpython-${{ matrix.pythonVersion }}-windows-${{ env.uv-arch }}-none
- name: Run unit tests
run: ci/scripts/tests/unitTests.ps1
- name: Replace relative paths in unit test results
if: ${{ failure() }}
# Junit reports fail on these
shell: bash
run: sed -i 's|file="..\\|file="|g' testOutput/unit/unitTests.xml
- name: Upload artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: Unit tests results (${{ matrix.pythonVersion }}, ${{ matrix.arch }})
path: testOutput/unit/unitTests.xml
- name: Publish unit test report
uses: mikepenz/action-junit-report@v5
if: ${{ failure() }}
with:
check_name: Unit tests (${{ matrix.pythonVersion }}, ${{ matrix.arch }})
detailed_summary: true
annotate_only: true
report_paths: testOutput/unit/unitTests.xml
crowdinUpload:
name: Upload translations to Crowdin
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: [matrix, buildNVDA, checkPot]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/beta' && vars.CROWDIN_PROJECT_ID }}
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ env.defaultPythonVersion }}-${{ env.defaultArch }}
fail-on-cache-miss: true
- name: Get makePot results
uses: actions/download-artifact@v4
with:
name: makePot results
path: output
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.defaultPythonVersion }}
architecture: ${{ env.defaultArch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
- name: Upload translations to Crowdin
env:
crowdinProjectID: ${{ vars.CROWDIN_PROJECT_ID }}
crowdinAuthToken: ${{ secrets.CROWDIN_AUTH_TOKEN }}
run: uv run --with requests --directory ${{ github.workspace }} ci\scripts\crowdinSync.py uploadSourceFile 2 output\nvda.pot 2>&1
createLauncher:
name: Create launcher
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: [matrix, buildNVDA]
strategy:
fail-fast: false
matrix:
arch: ${{ fromJson(needs.matrix.outputs.supportedArchitectures) }}
pythonVersion: ${{ fromJson(needs.matrix.outputs.supportedPythonVersions) }}
env:
uv-arch: ${{ matrix.arch == 'x64' && 'x86_64' || 'x86' }}
outputs:
# Note: each output variable is overwritten by the last job in the matrix.
# So we only set the output variables for the default architecture.
launcherArtifactId: ${{ steps.addJobSummary.outputs.artifactId }}
launcherSha256: ${{ steps.addJobSummary.outputs.SHA256 }}
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ matrix.pythonVersion }}-${{ matrix.arch }}
fail-on-cache-miss: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pythonVersion }}
architecture: ${{ matrix.arch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
with:
python-version: cpython-${{ matrix.pythonVersion }}-windows-${{ env.uv-arch }}-none
- name: Set version variables
run: ci/scripts/setBuildVersionVars.ps1
- name: Set scons args
run: ci/scripts/setSconsArgs.ps1
env:
apiSigningToken: ${{ github.event_name == 'push' && secrets.API_SIGNING_TOKEN || '' }}
- name: Build scons docs targets
shell: cmd
run: scons %sconsDocsOutTargets% %sconsArgs% %sconsCores%
# Run launcher separately as we can't safely generate that in parallel to docs scons targets (#18867)
- name: Create launcher and controller client
shell: cmd
run: |
PowerShell -Command "Set-ExecutionPolicy Bypass"
PowerShell -Command "Set-PSRepository PSGallery -InstallationPolicy Trusted"
PowerShell -Command "Install-Module -Name SignPath -Force"
scons %sconsLauncherOutTargets% %sconsArgs% %sconsCores%
- name: Upload launcher
id: uploadLauncher
uses: actions/upload-artifact@v4
with:
name: NVDA launcher (${{ matrix.pythonVersion }}, ${{ matrix.arch }})
path: |
output/nvda*.exe
output/nvda*controllerClient.zip
- name: Upload documentation artifacts
uses: actions/upload-artifact@v4
id: uploadBuildArtifacts
with:
name: Documentation files and packaging metadata (${{ matrix.pythonVersion }}, ${{ matrix.arch }})
path: |
output/*.html
output/*.css
output/library_modules.txt
output/installed_python_packages.txt
- name: Add job summary
id: addJobSummary
shell: bash
run: |
NVDA_EXE_NAME=$(ls output/nvda*.exe | head -n 1)
SHA256=$(sha256sum "$NVDA_EXE_NAME" | cut -d ' ' -f 1)
# If architecture is default we save the build details to the output variable
if [ "${{ matrix.arch == env.defaultArch && matrix.pythonVersion == env.defaultPythonVersion }}" == "true" ]; then
echo SHA256=$SHA256 >> $GITHUB_OUTPUT
echo artifactId=${{ steps.uploadLauncher.outputs.artifact-id }} >> $GITHUB_OUTPUT
fi
echo "* [Download the NVDA launcher (${{ matrix.pythonVersion }}, ${{ matrix.arch }})](${{ steps.uploadLauncher.outputs.artifact-url }})" >> $GITHUB_STEP_SUMMARY
echo " * SHA256 of launcher exe file: \`$SHA256\`" >> $GITHUB_STEP_SUMMARY
echo "* [Download the documentation and other build artifacts](${{ steps.uploadBuildArtifacts.outputs.artifact-url }})" >> $GITHUB_STEP_SUMMARY
echo " * User guide, change log, developer guide" >> $GITHUB_STEP_SUMMARY
echo " * Packaging metadata: library modules, installed python packages" >> $GITHUB_STEP_SUMMARY
systemTests:
name: Run system tests
runs-on: ${{ matrix.runner }}
needs: [matrix, createLauncher]
strategy:
fail-fast: false
matrix:
# To skip tests, and just run install, replace with [excluded_from_build]
testSuite: [chrome, installer, startupShutdown, symbols, vscode, imageDescriptions]
runner: ${{ fromJson(needs.matrix.outputs.supportedRunners) }}
arch: ${{ fromJson(needs.matrix.outputs.supportedArchitectures) }}
pythonVersion: ${{ fromJson(needs.matrix.outputs.supportedPythonVersions) }}
# A bug exists with Windows 2022 notepad that prevents NVDA from focusing it.
# This causes our symbol pronunciation tests to fail on this runner.
exclude:
- runner: windows-2022
testSuite: symbols
env:
uv-arch: ${{ matrix.arch == 'x64' && 'x86_64' || 'x86' }}
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ matrix.pythonVersion }}-${{ matrix.arch }}
fail-on-cache-miss: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pythonVersion }}
architecture: ${{ matrix.arch }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
with:
python-version: cpython-${{ matrix.pythonVersion }}-windows-${{ env.uv-arch }}-none
- name: Get NVDA launcher
id: getLauncher
uses: actions/download-artifact@v4
with:
name: NVDA launcher (${{ matrix.pythonVersion }}, ${{ matrix.arch }})
path: output
- name: Install NVDA
run: ci/scripts/installNVDA.ps1
env:
nvdaLauncherDir: ${{ steps.getLauncher.outputs.download-path }}
- name: Download and install Visual Studio Code
if: ${{ matrix.testSuite == 'vscode' }}
run: choco install -y vscode
- name: Run system tests
run: ci/scripts/tests/systemTests.ps1
env:
nvdaLauncherDir: ${{ steps.getLauncher.outputs.download-path }}
INCLUDE_SYSTEM_TEST_TAGS: ${{ matrix.testSuite }}
- name: Upload system tests results
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: "System tests results (${{ matrix.testSuite }}) (${{ matrix.runner }}, ${{ matrix.pythonVersion }}, ${{ matrix.arch }})"
path: |
testOutput/system
testOutput/install
!testOutput/install/nvda_install_temp.log
- name: Publish system test report
uses: mikepenz/action-junit-report@v5
if: ${{ failure() }}
with:
check_name: "System tests (${{ matrix.testSuite }}) (${{ matrix.runner }}, ${{ matrix.pythonVersion }}, ${{ matrix.arch }})"
detailed_summary: true
annotate_only: true
report_paths: testOutput/system/systemTests.xml
createSymbols:
name: Create symbols
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: [matrix, buildNVDA]
strategy:
fail-fast: false
matrix:
arch: ${{ fromJson(needs.matrix.outputs.supportedArchitectures) }}
pythonVersion: ${{ fromJson(needs.matrix.outputs.supportedPythonVersions) }}
outputs:
# Note: each output variable is overwritten by the last job in the matrix.
# So we only set the output variables for the default architecture.
symbolsArtifactId: ${{ steps.defaultArtifact.outputs.artifactId }}
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ matrix.pythonVersion }}-${{ matrix.arch }}
fail-on-cache-miss: true
- name: Install Windows SDK
# Installs symstore.exe to expected location.
run: choco install -y windows-sdk-10.1
- name: Create build symbols
env:
symStore: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\symstore.exe
run: ci/scripts/buildSymbolStore.ps1
- name: Upload symbols artifact
id: uploadArtifact
uses: actions/upload-artifact@v4
with:
name: Symbols (${{ matrix.pythonVersion }}, ${{ matrix.arch }})
path: output/symbols.zip
- name: Save artifact metadata
shell: bash
id: defaultArtifact
if: ${{ matrix.arch == env.defaultArch && matrix.pythonVersion == env.defaultPythonVersion }}
run: echo artifactId=${{ steps.uploadArtifact.outputs.artifact-id }} >> $GITHUB_OUTPUT
allTestsPass:
# Is a no-op action.
# Rulesets require specifying every job you wish to block a PR/push.
# Used to protect branches/tags as a general status check so we can check a single job for all rulesets.
name: Check if all tests pass
runs-on: ubuntu-latest
if: always()
needs: [buildNVDA, typeCheck, checkPo, checkPot, licenseCheck, unitTests, createLauncher, systemTests, createSymbols]
steps:
- name: Check if all tests pass
uses: re-actors/alls-green@v1.2.2
with:
jobs: ${{ toJSON(needs) }}
uploadSymbols:
name: Upload symbols
runs-on: ${{ needs.matrix.outputs.defaultRunner }}
needs: [matrix, buildNvda]
if: ${{ github.event_name == 'push' && vars.feature_uploadSymbolsToMozilla }}
steps:
- name: Checkout cached build
uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.ref }}-${{ github.run_id }}-${{ env.defaultPythonVersion }}-${{ env.defaultArch }}
fail-on-cache-miss: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.defaultPythonVersion }}
architecture: ${{ env.defaultArch }}
- name: Download and extract dump_syms
shell: bash
run: |
curl -L -o dump_syms.zip https://github.com/mozilla/dump_syms/releases/download/v2.3.5/dump_syms-x86_64-pc-windows-msvc.zip
7z x dump_syms.zip dump_syms.exe
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
- name: Upload symbols to Mozilla
continue-on-error: true
run: uv run --with requests --directory ${{ github.workspace }} ci\scripts\mozillaSyms.py
env:
mozillaSymsAuthToken: ${{ secrets.MOZILLA_SYMS_TOKEN }}
- name: Warn on failure
if: ${{ failure() }}
shell: bash
run: |
echo "Warning: Uploading symbols to Mozilla failed." >> $GITHUB_STEP_SUMMARY
cleanupCache:
# Cache deletion on pull_request events cannot occur on PRs from forks
# as PRs from forks do not get write permissions from pull_request events.
# Alternatively, we can change the event trigger to pull_request_target,
# however that might introduce security risks as it grants fork PRs greater permissions.
# In these cases we can always let GitHub handle cache deletion:
# auto deletion after 7 days or limits are hit
name: Cleanup cache
permissions:
actions: write
needs: [matrix, allTestsPass, crowdinUpload, uploadSymbols]
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.owner == github.repository_owner }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: ${{ fromJson(needs.matrix.outputs.supportedArchitectures) }}
pythonVersion: ${{ fromJson(needs.matrix.outputs.supportedPythonVersions) }}
steps:
- name: Cleanup cache
shell: bash
run: gh cache delete ${{ github.ref }}-${{ github.run_id }}-${{ matrix.pythonVersion }}-${{ matrix.arch }}
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
deploySnapshot:
name: Deploy NVDA snapshot
permissions:
contents: write
deployments: write
runs-on: ubuntu-latest
needs: [buildNVDA, createLauncher, createSymbols, allTestsPass]
if: ${{ github.event_name == 'push' && !startsWith(github.ref_name, 'release-') }}
concurrency:
group: snapshot-${{ github.ref_name }}
cancel-in-progress: true
environment:
name: snapshot
steps:
- name: Get NVDA launcher
uses: actions/download-artifact@v4
with:
name: NVDA launcher (${{ env.defaultPythonVersion }}, ${{ env.defaultArch }})
path: output
- name: Deploy snapshot
shell: bash
id: deploySnapshot
env:
GH_TOKEN: ${{ github.token }}
run: |
NVDA_EXE_NAME=$(ls output/nvda*.exe | head -n 1)
NVDA_HASH=$(sha1sum "$NVDA_EXE_NAME" | cut -d ' ' -f 1)
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/deployments \
-f "task=release" \
-f "description=Release of $NVDA_EXE_NAME" \
-f "ref=${{ github.ref_name }}" \
-F "auto_merge=false" \
-f "environment=snapshot" \
-f "required_contexts[]" \
-f "payload[NVDA_HASH]=$NVDA_HASH" \
-f "payload[NVDA_ARTIFACT_ID]=${{ needs.createLauncher.outputs.launcherArtifactId }}" \
-f "payload[SYMBOLS_ARTIFACT_ID]=${{ needs.createSymbols.outputs.symbolsArtifactId }}" \
-f "payload[NVDA_VERSION]=${{ needs.buildNVDA.outputs.version }}" \
-f "payload[NVDA_VERSION_TYPE]=${{ needs.buildNVDA.outputs.versionType }}" \
-f "payload[NVDA_API_VERSION]=${{ needs.buildNVDA.outputs.APIVersion }}" \
-f "payload[NVDA_API_COMPAT_TO]=${{ needs.buildNVDA.outputs.APIBackCompat }}"
release:
name: Release NVDA
permissions:
contents: write
deployments: write
discussions: write
runs-on: ubuntu-latest
needs: [buildNVDA, createLauncher, createSymbols, allTestsPass]
if: startsWith(github.ref_name, 'release-')
concurrency:
group: release
cancel-in-progress: true
environment:
name: production
steps:
- name: Get normalized tag names
id: getReleaseNotes
shell: bash
run: |
echo RELEASE_NAME=$GITHUB_REF_NAME | sed 's/release-//g' >> $GITHUB_OUTPUT
echo NORMALIZED_TAG_NAME=$GITHUB_REF_NAME | sed 's/\./-/g' | sed 's/release-//g' >> $GITHUB_OUTPUT
- name: Get NVDA launcher
uses: actions/download-artifact@v4
with:
name: NVDA launcher (${{ env.defaultPythonVersion }}, ${{ env.defaultArch }})
path: output
- name: VirusTotal Scan
id: virusTotal
uses: crazy-max/ghaction-virustotal@v4
with:
vt_api_key: ${{ secrets.VT_API_KEY }}
files: output/nvda*.exe
- name: Get normalized VT url
id: getVTUrl
shell: bash
run: |
vtUrl=$(echo ${{ steps.virusTotal.outputs.analysis }} | sed -E 's/([^=]*)=([^,]*).*/\2/')
echo VT_URL=$vtUrl >> $GITHUB_OUTPUT
- name: Deploy release
shell: bash
id: deployRelease
env:
GH_TOKEN: ${{ github.token }}
run: |
NVDA_EXE_NAME=$(ls output/nvda*.exe | head -n 1)
NVDA_HASH=$(sha1sum "$NVDA_EXE_NAME" | cut -d ' ' -f 1)
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/deployments \
-f "task=release" \
-f "description=Release of $NVDA_EXE_NAME" \
-f "ref=${{ github.ref_name }}" \
-F "auto_merge=false" \
-f "environment=production" \
-f "required_contexts[]" \
-f "payload[NVDA_HASH]=$NVDA_HASH" \
-f "payload[NVDA_ARTIFACT_ID]=${{ needs.createLauncher.outputs.launcherArtifactId }}" \
-f "payload[SYMBOLS_ARTIFACT_ID]=${{ needs.createSymbols.outputs.symbolsArtifactId }}" \
-f "payload[NVDA_VERSION]=${{ needs.buildNVDA.outputs.version }}" \
-f "payload[NVDA_VERSION_TYPE]=${{ needs.buildNVDA.outputs.versionType }}" \
-f "payload[NVDA_API_VERSION]=${{ needs.buildNVDA.outputs.APIVersion }}" \
-f "payload[NVDA_API_COMPAT_TO]=${{ needs.buildNVDA.outputs.APIBackCompat }}"
- name: Create release notes
id: createReleaseNotes
shell: bash
run: |
echo "* Highlights can be found in the [release blog post](https://www.nvaccess.org/post/nvda-${{ steps.getReleaseNotes.outputs.NORMALIZED_TAG_NAME }}/)." >> /tmp/releaseNotes.md
echo "* [VirusTotal scan results](${{ steps.getVTUrl.outputs.VT_URL }})" >> /tmp/releaseNotes.md
echo "* SHA256 sum: \`${{ needs.createLauncher.outputs.launcherSha256 }}\`" >> /tmp/releaseNotes.md
- name: Publish pre-release
if: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{github.ref_name }} \
--repo ${{ github.repository }} \
--prerelease \
--title "${{ steps.getReleaseNotes.outputs.RELEASE_NAME }}" \
--notes-file /tmp/releaseNotes.md \
--verify-tag \
--discussion-category Releases
- name: Publish stable release
if: ${{ !contains(github.ref_name, 'rc') && !contains(github.ref_name, 'beta') }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{github.ref_name }} \
--repo ${{ github.repository }} \
--title "${{ steps.getReleaseNotes.outputs.RELEASE_NAME }}" \
--notes-file /tmp/releaseNotes.md \
--verify-tag \
--discussion-category Releases
- name: Upload exe to release assets
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
NVDA_EXE_NAME=$(ls output/nvda*.exe | head -n 1)
gh release upload ${{ github.ref_name }} \
--repo ${{ github.repository }} \
--clobber \
$NVDA_EXE_NAME#Installer