-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (127 loc) · 4.54 KB
/
Copy pathdotnetCi.yml
File metadata and controls
142 lines (127 loc) · 4.54 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
name: .NET CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
buildAndRunBasicTests:
runs-on: ubuntu-slim
env:
RunNumber: ${{ github.run_number }}.${{ github.run_attempt }}
SonarCloudProject: csf-dev_CSF.Screenplay
SonarCloudUsername: craigfowler-github
SonarCloudUrl: https://sonarcloud.io
Configuration: Debug
Tfm: net8.0
DotnetVersion: 8.0.x
SonarCloudSecretKey: ${{ secrets.SONARCLOUDKEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Install build dependencies
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DotnetVersion }}
- name: Setup Node.js for building JSON-to-HTML report converter
uses: actions/setup-node@v6.2.0
- name: Setup Java JDK for SonarScanner
uses: actions/setup-java@v5.1.0
with:
java-version: 17
# Environment setup pre-build
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
- name: Setup SonarScanner
run: dotnet tool install --global dotnet-sonarscanner
- name: Setup Coverlet console
run: dotnet tool install --global coverlet.console
- name: Setup SonarScanner for pull request processing
if: ${{ github.event_name == 'pull_request' }}
env:
BranchName: ${{ github.base_ref }}
BranchParam: sonar.pullrequest.branch
PullRequestParam: /d:sonar.pullrequest.key=${{ github.event.number }}
- name: Setup SonarScanner for normal branch processing
if: ${{ github.event_name != 'pull_request' }}
env:
BranchName: ${{ github.ref_name }}
BranchParam: sonar.branch.name
PullRequestParam:
- name: Setup Selenium Manager config
run: |
mkdir ~/.cache/selenium
cp Tools/se-config.toml ~/.cache/selenium
- name: Setup an Xvfb display so Chrome may run
run: |
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
# Build and test the solution
- name: Restore .NET packages
run: dotnet restore -c ${{ env.Configuration }}
- name: Start SonarScanner
run: >
dotnet-sonarscanner begin
/k:${{ env.SonarCloudProject }}
/v:GitHub_build_${{ env.RunNumber }}
/o:${{ env.SonarCloudUsername }}
/d:sonar.host.url=${{ env.SonarCloudUrl }}
/d:sonar.token=${{ env.SonarCloudSecretKey }}
/d:${{ env.BranchParam }}=${{ env.BranchName }}
${{ env.PullRequestParam }}
/d:sonar.javascript.lcov.reportPaths=CSF.Screenplay.JsonToHtmlReport.Template/src/TestResults/lcov.info
/s:.sonarqube-analysisproperties.xml
- name: Build the solution
run: dotnet build -c ${{ env.Configuration }} --no-incremental
- name: Run .NET tests with coverage
run: |
AnyFailures=0
for proj in Tests/*.Tests
do
projNameArray=(${proj//// })
projName=${projNameArray[1]}
assemblyPath=$proj/bin/$Configuration/$Tfm/$projName.dll
coverlet "$assemblyPath" --target "dotnet" --targetargs "test $proj --no-build --logger:nunit --test-adapter-path:." -f=opencover -o="TestResults/$projName.opencover.xml"
if [ $? -ne 0 ]
then
AnyFailures=1
fi
done
export AnyFailures
- name: Run JavaScript tests with coverage
run: |
cd CSF.Screenplay.JsonToHtmlReport.Template/src
npm test
if [ $? -ne 0 ]
then
export AnyFailures=1
fi
cd ../..
- name: Stop SonarScanner
run:
dotnet-sonarscanner end /d:sonar.token=${{ env.SonarCloudSecretKey }}
- name: Upload test results artifacts
uses: actions/upload-artifact@v4
with:
name: NUnit test results
path: Tests/*.Tests/**/TestResults.xml
- name: Upload Screenplay JSON report artifact
uses: actions/upload-artifact@v4
with:
name: Screenplay JSON reports
path: Tests/**/ScreenplayReport_*.json
- name: Fail the build if any test failures
run: |
if [ $AnyFailures -ne 0 ]
then
echo "Failing the build due to test failures"
exit 1
fi
# TODO: Convert Screenplay reports to HTML and upload as an artifact
# buildDocs:
# TODO: Build the docco site and package the result as an artifact, don't publish it
# publishDocs:
# TODO: Take the docco site artifact and publish it to master
# runBrowserTests:
# TODO: Use build-results artifacts and run tests on matrix of browsers