Skip to content

Commit 917e184

Browse files
committed
WIP #248 - Initial attempt at GitHub actions
I've commented out the AppVeyor build config in this commit to, so that it doesn't run.
1 parent 54ed55b commit 917e184

2 files changed

Lines changed: 164 additions & 135 deletions

File tree

.appveyor.yml

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
1-
environment:
2-
matrix:
3-
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
4-
JAVA_HOME: C:\Program Files\Java\jdk17
5-
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2204
6-
JAVA_HOME: /usr/lib/jvm/jdk15
1+
# environment:
2+
# matrix:
3+
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
4+
# JAVA_HOME: C:\Program Files\Java\jdk17
5+
# - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2204
6+
# JAVA_HOME: /usr/lib/jvm/jdk15
77

8-
skip_branch_with_pr: true
8+
# skip_branch_with_pr: true
99

10-
# A note/reminder for readers: Script items prefixed "cmd:" are executed on Windows-only environments.
11-
# Items with no prefix (or "ps:" prefix) are run on all environments (Windows & Linux)
10+
# # A note/reminder for readers: Script items prefixed "cmd:" are executed on Windows-only environments.
11+
# # Items with no prefix (or "ps:" prefix) are run on all environments (Windows & Linux)
1212

13-
init:
14-
- cmd: git config --global core.autocrlf true
13+
# init:
14+
# - cmd: git config --global core.autocrlf true
1515

16-
install:
17-
- cmd: dotnet tool install --global dotnet-sonarscanner
18-
- cmd: dotnet tool install --global coverlet.console
19-
- cmd: dotnet tool update -g docfx
20-
- ps: |
21-
cd CSF.Screenplay.JsonToHtmlReport.Template\src
22-
npm ci
23-
cd ..\..
24-
# This was taken from https://stackoverflow.com/questions/60304251/unable-to-open-x-display-when-trying-to-run-google-chrome-on-centos-rhel-7-5
25-
# It's the minimum dependencies for running Chrome in a headless environment on Linux
26-
- sh: |
27-
sudo apt-get update
28-
sudo apt install -y xorg xvfb gtk2-engines-pixbuf dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable
16+
# install:
17+
# - cmd: dotnet tool install --global dotnet-sonarscanner
18+
# - cmd: dotnet tool install --global coverlet.console
19+
# - cmd: dotnet tool update -g docfx
20+
# - ps: |
21+
# cd CSF.Screenplay.JsonToHtmlReport.Template\src
22+
# npm ci
23+
# cd ..\..
24+
# # This was taken from https://stackoverflow.com/questions/60304251/unable-to-open-x-display-when-trying-to-run-google-chrome-on-centos-rhel-7-5
25+
# # It's the minimum dependencies for running Chrome in a headless environment on Linux
26+
# - sh: |
27+
# sudo apt-get update
28+
# sudo apt install -y xorg xvfb gtk2-engines-pixbuf dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable
2929

30-
before_build:
31-
- dotnet --version
32-
- dotnet restore --verbosity m
33-
- dotnet clean
34-
- cmd: Tools\appveyor-setup-sonarscanner.bat
35-
- cmd: Tools\appveyor-setup-selenium.bat
36-
- cmd: >
37-
dotnet-sonarscanner begin
38-
/k:"csf-dev_CSF.Screenplay"
39-
/v:AppVeyor_build_%APPVEYOR_BUILD_NUMBER%
40-
/o:craigfowler-github
41-
/d:sonar.host.url=https://sonarcloud.io
42-
/d:sonar.token=%SONARCLOUD_SECRET_KEY%
43-
/d:%BranchParam%=%BranchName%
44-
%PRParam%
45-
/d:sonar.javascript.lcov.reportPaths=%APPVEYOR_BUILD_FOLDER%\CSF.Screenplay.JsonToHtmlReport.Template\src\TestResults\lcov.info
46-
/s:%APPVEYOR_BUILD_FOLDER%\.sonarqube-analysisproperties.xml
47-
# Activate Xvfb and export a display so that Chrome can run in Linux
48-
- sh: |
49-
Xvfb -ac :99 -screen 0 1280x1024x16 &
50-
export DISPLAY=:99
30+
# before_build:
31+
# - dotnet --version
32+
# - dotnet restore --verbosity m
33+
# - dotnet clean
34+
# - cmd: Tools\appveyor-setup-sonarscanner.bat
35+
# - cmd: Tools\appveyor-setup-selenium.bat
36+
# - cmd: >
37+
# dotnet-sonarscanner begin
38+
# /k:"csf-dev_CSF.Screenplay"
39+
# /v:AppVeyor_build_%APPVEYOR_BUILD_NUMBER%
40+
# /o:craigfowler-github
41+
# /d:sonar.host.url=https://sonarcloud.io
42+
# /d:sonar.token=%SONARCLOUD_SECRET_KEY%
43+
# /d:%BranchParam%=%BranchName%
44+
# %PRParam%
45+
# /d:sonar.javascript.lcov.reportPaths=%APPVEYOR_BUILD_FOLDER%\CSF.Screenplay.JsonToHtmlReport.Template\src\TestResults\lcov.info
46+
# /s:%APPVEYOR_BUILD_FOLDER%\.sonarqube-analysisproperties.xml
47+
# # Activate Xvfb and export a display so that Chrome can run in Linux
48+
# - sh: |
49+
# Xvfb -ac :99 -screen 0 1280x1024x16 &
50+
# export DISPLAY=:99
5151

52-
build_script:
53-
- dotnet build --no-incremental
52+
# build_script:
53+
# - dotnet build --no-incremental
5454

55-
test_script:
56-
- ps: if ($isWindows) { Tools\run-tests-with-coverage.ps1 }
57-
- sh: >
58-
dotnet test
59-
--test-adapter-path:.
60-
--logger:nunit
61-
- ps: |
62-
cd CSF.Screenplay.JsonToHtmlReport.Template\src
63-
npm test
64-
cd ..\..
55+
# test_script:
56+
# - ps: if ($isWindows) { Tools\run-tests-with-coverage.ps1 }
57+
# - sh: >
58+
# dotnet test
59+
# --test-adapter-path:.
60+
# --logger:nunit
61+
# - ps: |
62+
# cd CSF.Screenplay.JsonToHtmlReport.Template\src
63+
# npm test
64+
# cd ..\..
6565

66-
after_test:
67-
- cmd: >
68-
dotnet-sonarscanner end
69-
/d:"sonar.token=%SONARCLOUD_SECRET_KEY%"
70-
- ps: if ($isWindows) { Tools\appveyor-upload-test-results.ps1 }
71-
- cmd: dotnet build -c Docs
72-
- ps: if ($isWindows) { Tools\appveyor_publish_docs.ps1 }
66+
# after_test:
67+
# - cmd: >
68+
# dotnet-sonarscanner end
69+
# /d:"sonar.token=%SONARCLOUD_SECRET_KEY%"
70+
# - ps: if ($isWindows) { Tools\appveyor-upload-test-results.ps1 }
71+
# - cmd: dotnet build -c Docs
72+
# - ps: if ($isWindows) { Tools\appveyor_publish_docs.ps1 }
7373

74-
artifacts:
75-
- path: Tests\**\ScreenplayReport_*.json
76-
name: Screenplay report
74+
# artifacts:
75+
# - path: Tests\**\ScreenplayReport_*.json
76+
# name: Screenplay report

.github/workflows/dotnetCi.yml

Lines changed: 97 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ jobs:
1111
buildAndRunBasicTests:
1212
runs-on: ubuntu-slim
1313

14-
# env:
15-
# TODO: put env vars here
14+
env:
15+
RunNumber: ${{ github.run_number }}.${{ github.run_attempt }}
16+
SonarCloudProject: csf-dev_CSF.Screenplay
17+
SonarCloudUsername: craigfowler-github
18+
SonarCloudUrl: https://sonarcloud.io
19+
Configuration: Debug
20+
Tfm: net8.0
21+
DotnetVersion: 8.0.x
22+
SonarCloudSecretKey: ${{ secrets.SONARCLOUDKEY }}
1623

1724
steps:
1825
- name: Checkout
@@ -23,7 +30,7 @@ jobs:
2330
- name: Install .NET Core
2431
uses: actions/setup-dotnet@v4
2532
with:
26-
dotnet-version: 8.0.x
33+
dotnet-version: ${{ env.DotnetVersion }}
2734
- name: Setup Node.js for building JSON-to-HTML report converter
2835
uses: actions/setup-node@v6.2.0
2936
- name: Setup Java JDK for SonarScanner
@@ -39,75 +46,97 @@ jobs:
3946
run: dotnet tool install --global dotnet-sonarscanner
4047
- name: Setup Coverlet console
4148
run: dotnet tool install --global coverlet.console
42-
43-
# Start SonarScanner
44-
45-
# Build
49+
- name: Setup SonarScanner for pull request processing
50+
if: ${{ github.event_name == 'pull_request' }}
51+
env:
52+
BranchName: ${{ github.base_ref }}
53+
BranchParam: sonar.pullrequest.branch
54+
PullRequestParam: /d:sonar.pullrequest.key=${{ github.event.number }}
55+
- name: Setup SonarScanner for normal branch processing
56+
if: ${{ github.event_name != 'pull_request' }}
57+
env:
58+
BranchName: ${{ github.ref_name }}
59+
BranchParam: sonar.branch.name
60+
PullRequestParam:
61+
- name: Setup Selenium Manager config
62+
run: |
63+
mkdir ~/.cache/selenium
64+
cp Tools/se-config.toml ~/.cache/selenium
65+
- name: Setup an Xvfb display so Chrome may run
66+
run: |
67+
Xvfb -ac :99 -screen 0 1280x1024x16 &
68+
export DISPLAY=:99
69+
70+
# Build and test the solution
71+
72+
- name: Restore .NET packages
73+
run: dotnet restore -c ${{ env.Configuration }}
74+
- name: Start SonarScanner
75+
run: >
76+
dotnet-sonarscanner begin
77+
/k:${{ env.SonarCloudProject }}
78+
/v:GitHub_build_${{ env.RunNumber }}
79+
/o:${{ env.SonarCloudUsername }}
80+
/d:sonar.host.url=${{ env.SonarCloudUrl }}
81+
/d:sonar.token=${{ env.SonarCloudSecretKey }}
82+
/d:${{ env.BranchParam }}=${{ env.BranchName }}
83+
${{ env.PullRequestParam }}
84+
/d:sonar.javascript.lcov.reportPaths=CSF.Screenplay.JsonToHtmlReport.Template/src/TestResults/lcov.info
85+
/s:.sonarqube-analysisproperties.xml
4686
- name: Build the solution
47-
run: dotnet build --no-incremental
48-
49-
# Test .NET (with coverage)
50-
51-
# Test JavaScript (with coverage)
52-
53-
# Stop SonarScanner
54-
55-
# Upload test results artifact
56-
57-
# Convert Screenplay reports to HTML and upload artifacts
58-
59-
# Upload build-results artifacts
87+
run: dotnet build -c ${{ env.Configuration }} --no-incremental
88+
- name: Run .NET tests with coverage
89+
run: |
90+
AnyFailures=0
91+
for proj in Tests/*.Tests
92+
do
93+
projNameArray=(${proj//// })
94+
projName=${projNameArray[1]}
95+
assemblyPath=$proj/bin/$Configuration/$Tfm/$projName.dll
96+
coverlet "$assemblyPath" --target "dotnet" --targetargs "test $proj --no-build --logger:nunit --test-adapter-path:." -f=opencover -o="TestResults/$projName.opencover.xml"
97+
if [ $? -ne 0 ]
98+
then
99+
AnyFailures=1
100+
fi
101+
done
102+
export AnyFailures
103+
- name: Run JavaScript tests with coverage
104+
run: |
105+
cd CSF.Screenplay.JsonToHtmlReport.Template/src
106+
npm test
107+
if [ $? -ne 0 ]
108+
then
109+
export AnyFailures=1
110+
fi
111+
cd ../..
112+
- name: Stop SonarScanner
113+
run:
114+
dotnet-sonarscanner end /d:sonar.token=${{ env.SonarCloudSecretKey }}
115+
- name: Upload test results artifacts
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: NUnit test results
119+
path: Tests/*.Tests/**/TestResults.xml
120+
- name: Upload Screenplay JSON report artifact
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: Screenplay JSON reports
124+
path: Tests/**/ScreenplayReport_*.json
125+
- name: Fail the build if any test failures
126+
run: |
127+
if [ $AnyFailures -ne 0 ]
128+
then
129+
echo "Failing the build due to test failures"
130+
exit 1
131+
fi
132+
133+
# TODO: Convert Screenplay reports to HTML and upload as an artifact
60134

61-
buildDocs:
135+
# buildDocs:
62136
# TODO: Build the docco site and package the result as an artifact, don't publish it
63137

64-
publishDocs:
138+
# publishDocs:
65139
# TODO: Take the docco site artifact and publish it to master
66140

67-
runBrowserTests:
141+
# runBrowserTests:
68142
# TODO: Use build-results artifacts and run tests on matrix of browsers
69-
70-
71-
72-
73-
74-
75-
76-
77-
78-
79-
# - name: Execute unit tests
80-
# run: dotnet test
81-
82-
# # Restore the application to populate the obj folder with RuntimeIdentifiers
83-
# - name: Restore the application
84-
# run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
85-
# env:
86-
# Configuration: ${{ matrix.configuration }}
87-
88-
# # Decode the base 64 encoded pfx and save the Signing_Certificate
89-
# - name: Decode the pfx
90-
# run: |
91-
# $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
92-
# $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx
93-
# [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
94-
95-
# # Create the app package by building and packaging the Windows Application Packaging project
96-
# - name: Create the app package
97-
# run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }}
98-
# env:
99-
# Appx_Bundle: Always
100-
# Appx_Bundle_Platforms: x86|x64
101-
# Appx_Package_Build_Mode: StoreUpload
102-
# Configuration: ${{ matrix.configuration }}
103-
104-
# # Remove the pfx
105-
# - name: Remove the pfx
106-
# run: Remove-Item -path $env:Wap_Project_Directory\GitHubActionsWorkflow.pfx
107-
108-
# # Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact
109-
# - name: Upload build artifacts
110-
# uses: actions/upload-artifact@v4
111-
# with:
112-
# name: MSIX Package
113-
# path: ${{ env.Wap_Project_Directory }}\AppPackages

0 commit comments

Comments
 (0)