Skip to content

Commit b152353

Browse files
authored
Merge d51f84b into d75a3fb
2 parents d75a3fb + d51f84b commit b152353

File tree

13 files changed

+326
-3
lines changed

13 files changed

+326
-3
lines changed

.github/workflows/runChecks.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Run checks and build NVDA
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- beta
8+
- rc
9+
- try-**
10+
- release-**
11+
- githubActions # To be removed
12+
13+
pull_request:
14+
branches:
15+
- master
16+
- beta
17+
- rc
18+
- try-**
19+
- release-**
20+
21+
workflow_dispatch:
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}
24+
cancel-in-progress: true
25+
env:
26+
if: $GITHUB_EVENT_NAME == 'pull_request'
27+
pullRequestNumber: ${{ github.event.number }}
28+
jobs:
29+
build:
30+
runs-on: windows-latest
31+
defaults:
32+
run:
33+
shell: cmd
34+
permissions:
35+
contents: write
36+
pull-requests: write
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
submodules: true
41+
- name: Install dependencies
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: '3.11'
45+
architecture: x86
46+
- name: Set version variables
47+
run: powershell.exe ci/scripts/setBuildVersionVars.ps1
48+
- name: Set scons args
49+
run: powershell.exe ci/scripts/setSconsArgs.ps1
50+
- name: Prepare source code
51+
run: scons source %sconsArgs% --all-cores
52+
- name: Run launcher
53+
run: scons launcher version=%version% --all-cores
54+
- name: Prepare for tests
55+
run: powershell.exe ci/scripts/tests/beforeTests.ps1
56+
- name: Install NVDA
57+
run: powershell.exe ci/scripts/installNVDA.ps1
58+
- name: Check comments for translators
59+
run: powershell.exe ci/scripts/tests/translationCheck.ps1
60+
- name: License check
61+
run: powershell.exe ci/scripts/tests/licenseCheck.ps1
62+
- name: Run unit tests
63+
run: powershell.exe ci/scripts/tests/unitTests.ps1
64+
- name: Run system tests
65+
run: powershell.exe ci/scripts/tests/systemTests.ps1
66+
- name: Upload NVDA
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: NVDA
70+
path: output/*.exe
71+
compression-level: 0
72+
overwrite: true
73+
- name: Upload test results
74+
id: testResults
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: Test Results
78+
path: testOutput
79+
overwrite: true
80+
- name: Check tests failure
81+
run: powershell.exe ci/scripts/tests/checkTestFailure.ps1
82+
- name: Get summary
83+
id: getSummary
84+
if: ${{ failure() && github.event_name == 'pull_request' }}
85+
uses: austenstone/job-summary@v2.0
86+
with:
87+
create-pdf: false
88+
create-pdf-artifact: false
89+
create-md-artifact: true
90+
- name: Comment on failure
91+
if: ${{ failure() && github.event_name == 'pull_request' }}
92+
uses: peter-evans/create-or-update-comment@v4
93+
with:
94+
issue-number: ${{ github.event.number }}
95+
body: |
96+
${{ steps.getSummary.outputs.job-summary }}
97+
[Download test results](${{ steps.testResults.artifact-url }})

ci/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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. PowerShell scripts continue on non-terminating errors unless the file is prefixed with `$ErrorActionPreference = "Stop";`.
8+
9+
### Build process
10+
1. Checkout NVDA repository with submodules.
11+
1. Install dependencies.
12+
1. Set version and scons variables.
13+
1. Prepare source code.
14+
1. Build launcher.
15+
1. Install NVDA.
16+
1. Prepare for tests.
17+
18+
## Testing
19+
20+
Unlike the rest of the build, tests do not exit early if they fail or raise an error. If any test fails, `testFailExitCode` is set to 1. The `after_test` build phase will exit the build if any tests fail so that all test failures can be recorded where possible.
21+
22+
Before testing we:
23+
24+
* Create directories to store results.
25+
* Install NVDA for system tests
26+
27+
The tests we perform are:
28+
29+
* check translation comments
30+
* license checks
31+
* unit tests
32+
* system tests
33+
34+
## Artifacts
35+
36+
* NVDA launcher.
37+
* Test results.
38+
* If tests fail on a pull request, the job summary of GitHub Actions.
39+
* A comment will be created with the job summary, indicating success or failure for each group of tests, and a link to download test results.

ci/scripts/installNVDA.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
$errorCode=0
2+
$nvdaLauncherFile=".\output\nvda"
3+
if(!$env:release) {
4+
$nvdaLauncherFile+="_snapshot"
5+
}
6+
$nvdaLauncherFile+="_${env:version}.exe"
7+
echo NVDALauncherFile: $NVDALauncherFile
8+
$outputDir=$(resolve-path .\testOutput)
9+
$installerLogFilePath="$outputDir\nvda_install.log"
10+
$installerProcess=start-process -FilePath "$nvdaLauncherFile" -ArgumentList "--install-silent --debug-logging --log-file $installerLogFilePath" -passthru
11+
try {
12+
$installerProcess | wait-process -Timeout 180 -ErrorAction Stop
13+
$errorCode=$installerProcess.ExitCode
14+
} catch {
15+
echo "NVDA installer process timed out"
16+
$errorCode=1
17+
# Since installer failed to exit in the specified timeout the log file is still in use.
18+
# Unfortunately `Push-AppveyorArtifact` is unable to upload a file which is locked
19+
# as a work around create a copy of the log and upload that instead.
20+
$installerLogFileCopiedPath = "nvda_install_copy.log"
21+
Copy-Item $installerLogFilePath $installerLogFileCopiedPath
22+
}
23+
$crashDump = "$outputDir\nvda_crash.dmp"
24+
if (Test-Path -Path $crashDump){
25+
$errorCode=1
26+
}
27+
if($errorCode -ne 0) { $host.SetShouldExit($errorCode) }
28+
echo "nvdaLauncherFile=$nvdaLauncherFile" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append

ci/scripts/setBuildVersionVars.ps1

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
$ErrorActionPreference = "Stop";
2+
3+
# Accessing Windows build worker via Remote Desktop (RDP)
4+
# To enable:
5+
# Set an RDP password (before triggering the build), ensure password requirements are met.
6+
# Remove the password after the RDP connection params are shown in the build output.
7+
# For passwords requirements and instructions for setting, see the appveyor docs:
8+
# https://www.appveyor.com/docs/how-to/rdp-to-build-worker/
9+
10+
$pythonVersion = (py --version)
11+
echo $pythonVersion
12+
if ($env:GITHUB_REF_TYPE -eq "tag" -and $env:GITHUB_REF_NAME.StartsWith("release-")) {
13+
# Strip "release-" prefix.
14+
$version = $env:GITHUB_REF_NAME.Substring(8)
15+
echo "release=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
16+
if ($env:GITHUB_REF_TYPE -eq "tag" -and ($env:GITHUB_REF_NAME.Contains("rc") -or $env:GITHUB_REF_NAME.Contains("beta"))) {
17+
$versionType = "beta"
18+
} else {
19+
$versionType = "stable"
20+
}
21+
} else {
22+
$commitVersion = $env:GITHUB_SHA.Substring(0, 8)
23+
if($env:pullRequestNumber) {
24+
$version = "pr$env:pullRequestNumber-$env:GITHUB_RUN_ID," + $commitVersion
25+
} elseif($env:GITHUB_REF_NAME -eq "master") {
26+
$version = "alpha-$env:GITHUB_RUN_ID," + $commitVersion
27+
} else {
28+
$version = "$env:GITHUB_REF_NAME-$env:GITHUB_RUN_ID," + $commitVersion
29+
if($env:GITHUB_REF_NAME.StartsWith("try-release-")) {
30+
echo "release=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
31+
}
32+
}
33+
# The version is unique even for rebuilds, so we can use it for the AppVeyor version.
34+
if($env:GITHUB_REF_NAME -eq "master") {
35+
$versionType = "snapshot:alpha"
36+
} elseif (!$env:GITHUB_REF_NAME.StartsWith("try-")) {
37+
$versionType = "snapshot:$env:GITHUB_REF_NAME"
38+
}
39+
}
40+
echo "version=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
41+
if ($versionType) {
42+
echo "versionType=$versionType" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
43+
}

ci/scripts/setSconsArgs.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$ErrorActionPreference = "Stop";
2+
$sconsOutTargets = "launcher developerGuide changes userGuide keyCommands client moduleList"
3+
if(!$env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:feature_buildAppx) {
4+
$sconsOutTargets += " appx"
5+
}
6+
$sconsArgs = "version=$env:version"
7+
if ($env:release) {
8+
$sconsArgs += " release=1"
9+
}
10+
if ($env:versionType) {
11+
$sconsArgs += " updateVersionType=$env:versionType"
12+
}
13+
$sconsArgs += " publisher=`"$env:scons_publisher`""
14+
if (!$env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:feature_signing) {
15+
$sconsArgs += " apiSigningToken=$env:apiSigningToken"
16+
}
17+
$sconsArgs += " version_build=$env:GITHUB_RUN_ID"
18+
# We use cmd to run scons because PowerShell throws exceptions if warnings get dumped to stderr.
19+
# It's possible to work around this, but the workarounds have annoying side effects.
20+
echo "sconsOutTargets=$sconsOutTargets" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
21+
echo "sconsArgs=$sconsArgs" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
22+
Write-Host "scons args: $sconsArgs"
23+
Write-Host "scons output targets: $sconsOutTargets"

ci/scripts/tests/beforeTests.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
New-Item -ItemType directory -Path testOutput
2+
New-Item -ItemType directory -Path testOutput\unit
3+
New-Item -ItemType directory -Path testOutput\system
4+
New-Item -ItemType directory -Path testOutput\lint
5+
New-Item -ItemType directory -Path testOutput\license
6+
7+
# The first Chrome system test to run occasionally fails.
8+
# This has been observed on developer machines after chrome updates, but is difficult to reproduce.
9+
# When this occurs the NVDA logs indicate that no virtual buffer is created.
10+
# It isn't known if this is a bug in Chrome or NVDA.
11+
# The problem does not seem to affect users frequently, and when it does
12+
# recovery is possible by waiting a few seconds before switching to another app
13+
# and then back to Chrome.
14+
# The system tests failing has an impact on NVDA development, requiring confirmation of the cause of
15+
# failed tests, re-running builds, and lowered confidence in automated testing.
16+
#
17+
# Theory: Chrome is busy with post install tasks, so start Chrome in the background ahead of the tests.
18+
# Use the same arguments to start Chrome as the system tests, some arguments are only observed for the first
19+
# start of Chrome.
20+
$chromeStartArgsString = $(py tests/system/libraries/_chromeArgs.py)
21+
$chromeStartArgsArray = $chromeStartArgsString -split " "
22+
23+
cmd /c start /min $chromeStartArgsArray
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ErrorActionPreference = "Stop";
2+
if($env:testFailExitCode -ne 0) { $host.SetShouldExit($env:testFailExitCode) }

ci/scripts/tests/licenseCheck.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$licenseOutput = (Resolve-Path .\testOutput\license\)
2+
$licenseOutput = "$licenseOutput\licenseCheckResults.md"
3+
cmd.exe /c "runlicensecheck.bat $licenseOutput"
4+
if ($LastExitCode -ne 0) {
5+
$message = "FAIL: License check. See $licenseOutput for more information."
6+
} else {
7+
$message = "PASS: License check."
8+
}
9+
$message >> $env:GITHUB_STEP_SUMMARY

ci/scripts/tests/systemTests.ps1

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
$testOutput = (Resolve-Path .\testOutput\)
2+
$systemTestOutput = (Resolve-Path "$testOutput\system")
3+
4+
if ($env:VERBOSE_SYSTEM_TEST_LOGGING) {
5+
$verboseDebugLogging="True"
6+
} else {
7+
$verboseDebugLogging=""
8+
}
9+
10+
# This tag is used to exclude system tests.
11+
# If provided to runsystemtests, RF would give an error.
12+
$SKIP_SYS_TESTS = "excluded_from_build"
13+
$tagsForTest = "installer NVDA" # include the tests tagged with installer, or NVDA
14+
if ($env:INCLUDE_SYSTEM_TEST_TAGS) {
15+
if ($env:INCLUDE_SYSTEM_TEST_TAGS -eq $SKIP_SYS_TESTS) {
16+
# Indicate the tests were skipped, and exit early.
17+
"Skipped: System tests." >> $env:GITHUB_STEP_SUMMARY
18+
return
19+
}
20+
$tagsForTest = $env:INCLUDE_SYSTEM_TEST_TAGS
21+
22+
}
23+
$tagsForTestArray = -split $tagsForTest # turn this string into an array
24+
$includeTags = $tagsForTestArray | ForEach-Object {
25+
# Before every item output '--include'
26+
# No spaces required.
27+
# Including spaces will result in automatic quote characters around the string. i.e. "--include "
28+
"--include", $_
29+
}
30+
31+
.\runsystemtests.bat `
32+
--variable whichNVDA:installed `
33+
--variable installDir:"${env:nvdaLauncherFile}" `
34+
--variable verboseDebugLogging:"${verboseDebugLogging}" `
35+
@includeTags `
36+
# last line intentionally blank, allowing all lines to have line continuations.
37+
if($LastExitCode -ne 0) {
38+
$MESSAGE = "FAIL: System tests (tags: ${tagsForTest}). See test results for more information."
39+
echo "testFailExitCode=$LastExitCode" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
40+
} else {
41+
$MESSAGE = "PASS: System tests (tags: ${tagsForTest})."
42+
}
43+
$MESSAGE >> $env:GITHUB_STEP_SUMMARY
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmd.exe /c "scons checkPot $sconsArgs --all-cores"
2+
if($LastExitCode -ne 0) {
3+
$message = "FAIL: Translation comments check. Translation comments missing or unexpectedly included. See build log for more information."
4+
echo "testFailExitCode=$LastExitCode" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
5+
} else {
6+
$message = "PASS: Translation comments check."
7+
}
8+
$message >> $env:GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)