2323
2424 build_test_and_pack :
2525 name : Build, test & package
26- runs-on : ubuntu-slim
26+ runs-on : ubuntu-24.04
2727 timeout-minutes : 30
2828
2929 env :
4040 BranchParam : ${{ github.event_name == 'pull_request' && 'sonar.pullrequest.branch' || 'sonar.branch.name' }}
4141 PullRequestParam : ${{ github.event_name == 'pull_request' && format('/d:sonar.pullrequest.key={0}', github.event.number) || '' }}
4242 DISPLAY : :99
43-
43+
4444 steps :
4545 - name : Checkout
4646 uses : actions/checkout@v4
@@ -68,19 +68,18 @@ jobs:
6868 with :
6969 java-version : 21
7070 distribution : ' zulu'
71- - name : Install GUI packages so Chrome may run
72- run : |
73- sudo apt-get update
74- sudo apt install -y xorg xvfb gtk2-engines-pixbuf dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable psmisc
71+ # See https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
72+ - name : Disable AppArmor restrictions so Chrome may run
73+ run : echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
74+ - name : Start an Xvfb display so Chrome may run
75+ run : Xvfb -ac $DISPLAY -screen 0 1280x1024x16 &
7576
7677 # Environment setup pre-build
7778
7879 - name : Setup Selenium Manager config
7980 run : |
8081 mkdir ~/.cache/selenium
8182 cp Tools/se-config.toml ~/.cache/selenium
82- - name : Start an Xvfb display so Chrome may run
83- run : Xvfb -ac $DISPLAY -screen 0 1280x1024x16 &
8483 - name : Restore .NET packages
8584 run : dotnet restore
8685 - name : Restore Node modules
@@ -100,34 +99,38 @@ jobs:
10099 /d:sonar.host.url=${{ env.SonarCloudUrl }}
101100 /d:sonar.token=${{ env.SonarCloudSecretKey }}
102101 /d:${{ env.BranchParam }}=${{ env.BranchName }} ${{ env.PullRequestParam }}
103- /d:sonar.javascript.lcov.reportPaths=CSF.Screenplay.JsonToHtmlReport.Template/src/TestResults/lcov.info
102+ /d:sonar.javascript.lcov.reportPaths=$PWD/ CSF.Screenplay.JsonToHtmlReport.Template/src/TestResults/lcov.info
104103 /s:$PWD/.sonarqube-analysisproperties.xml
105104 - name : Build the solution
106105 run : dotnet build -c ${{ env.Configuration }} --no-incremental
107106 - name : Run .NET tests with coverage
108107 id : dotnet_tests
109- continue-on-error : true
108+ shell : bash {0}
110109 run : |
111110 for proj in Tests/*.Tests
112111 do
113112 projNameArray=(${proj//// })
114113 projName=${projNameArray[1]}
115114 assemblyPath=$proj/bin/$Configuration/$Tfm/$projName.dll
116115 coverlet "$assemblyPath" --target "dotnet" --targetargs "test $proj -c $Configuration --no-build --logger:nunit --test-adapter-path:." -f=opencover -o="TestResults/$projName.opencover.xml"
117- if [ $? -ne 0 ]
116+ exitCode=$?
117+ if [ $exitCode -ne 0 ]
118118 then
119- echo "failures=true" >> $GITHUB_OUTPUT
119+ echo "One or more tests have failed; this build should eventually fail"
120+ echo "failures=true" >> "$GITHUB_OUTPUT"
120121 fi
121122 done
122123 - name : Run JavaScript tests with coverage
123124 id : js_tests
124- continue-on-error : true
125+ shell : bash {0}
125126 run : |
126127 cd CSF.Screenplay.JsonToHtmlReport.Template/src
127128 npm test
128- if [ $? -ne 0 ]
129+ exitCode=$?
130+ if [ $exitCode -ne 0 ]
129131 then
130- echo "failures=true" >> $GITHUB_OUTPUT
132+ echo "One or more tests have failed; this build should eventually fail"
133+ echo "failures=true" >> "$GITHUB_OUTPUT"
131134 fi
132135 cd ../..
133136
@@ -139,11 +142,23 @@ jobs:
139142 - name : Gracefully stop Xvfb
140143 run : killall Xvfb
141144 continue-on-error : true
142- - name : Upload test results artifacts
145+ - name : Upload .NET test results artifacts
143146 uses : actions/upload-artifact@v4
144147 with :
145148 name : NUnit test results
146149 path : Tests/*.Tests/**/TestResults.xml
150+ # This step won't produce any artifacts if the verbose factory isn't
151+ # selected via appsettings.json in CSF.Screenplay.Selenium.Tests, but that's OK
152+ - name : Upload verbose webdriver log artifacts
153+ uses : actions/upload-artifact@v4
154+ with :
155+ name : Verbose webdriver logs
156+ path : ' **/chrome-verbose-log.txt'
157+ - name : Upload JS test results artifacts
158+ uses : actions/upload-artifact@v4
159+ with :
160+ name : Jest test results
161+ path : CSF.Screenplay.JsonToHtmlReport.Template/src/TestResults/**/*
147162 - name : Upload Screenplay JSON report artifact
148163 uses : actions/upload-artifact@v4
149164 with :
@@ -164,7 +179,7 @@ jobs:
164179 name : Screenplay HTML reports
165180 path : Tests/**/ScreenplayReport.html
166181 - name : Fail the build if any test failures
167- if : ${{ steps.dotnet_tests.outputs.failures == 'true' || steps.js_tests.outputs.failures == 'true' }}
182+ if : steps.dotnet_tests.outputs.failures == 'true' || steps.js_tests.outputs.failures == 'true'
168183 run : |
169184 echo "Failing the build due to test failures"
170185 exit 1
0 commit comments