-
Notifications
You must be signed in to change notification settings - Fork 5
373 lines (362 loc) · 13.6 KB
/
build.yml
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
name: "Build"
on:
workflow_dispatch:
push:
branches: [main, 'release/v[0-9]+.[0-9]+.[0-9]+']
jobs:
test-macos:
name: Test (MacOS)
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Tag current commit
if: startsWith(github.ref, 'refs/heads/release/')
shell: bash
run: |
version="${GITHUB_REF#refs/heads/release/}"
git tag "${version}"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Build solution
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
- name: Run tests
uses: Wandalen/wretry.action@v3.7.3
with:
command: dotnet test --no-build --collect:"XPlat Code Coverage"
attempt_limit: 2
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage (MacOS)
path: "**/coverage.cobertura.xml"
test-ubuntu:
name: Test (Ubuntu)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Tag current commit
if: startsWith(github.ref, 'refs/heads/release/')
shell: bash
run: |
version="${GITHUB_REF#refs/heads/release/}"
git tag "${version}"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Build solution
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
- name: Run tests
uses: Wandalen/wretry.action@v3.7.3
with:
command: dotnet test --no-build --collect:"XPlat Code Coverage"
attempt_limit: 2
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage (Ubuntu)
path: "**/coverage.cobertura.xml"
test-windows:
name: Test (Windows)
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Tag current commit
if: startsWith(github.ref, 'refs/heads/release/')
shell: bash
run: |
version="${GITHUB_REF#refs/heads/release/}"
git tag "${version}"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Build solution
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
- name: Run tests
uses: Wandalen/wretry.action@v3.7.3
with:
command: dotnet test --no-build --collect:"XPlat Code Coverage"
attempt_limit: 2
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage (Windows)
path: "**/coverage.cobertura.xml"
test-net-framework:
name: Test (.NET Framework)
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Tag current commit
if: startsWith(github.ref, 'refs/heads/release/')
shell: bash
run: |
version="${GITHUB_REF#refs/heads/release/}"
git tag "${version}"
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup VSTest
uses: darenm/Setup-VSTest@v1
- name: Navigate to Workspace
run: cd $GITHUB_WORKSPACE
- name: Build solution
run: msbuild.exe Testably.Abstractions.sln /p:NetFrameworkOnly=True /p:platform="Any CPU" /p:configuration="Release" -t:restore,build -p:RestorePackagesConfig=true
- name: Run tests
uses: Wandalen/wretry.action@v3.7.3
with:
command: vstest.console.exe .\Build\Tests\Testably.Abstractions.Tests\net48\Testably.Abstractions.Tests.dll .\Build\Tests\Testably.Abstractions.Parity.Tests\net48\Testably.Abstractions.Parity.Tests.dll .\Build\Tests\Testably.Abstractions.Testing.Tests\net48\Testably.Abstractions.Testing.Tests.dll /Logger:trx /ResultsDirectory:TestResults /collect:"Code Coverage;Format=Cobertura"
attempt_limit: 2
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage (.NET Framework)
path: "**/*.cobertura.xml"
test-examples:
name: Test (Examples)
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Tag current commit
if: startsWith(github.ref, 'refs/heads/release/')
shell: bash
run: |
version="${GITHUB_REF#refs/heads/release/}"
git tag "${version}"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Build solution
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
- name: Build example solution
run: dotnet build Examples /p:UseFileReferenceToTestablyLibraries=True
- name: Run example tests
uses: Wandalen/wretry.action@v3.7.3
with:
command: dotnet test Examples --no-build
attempt_limit: 2
upload-coverage:
name: Upload coverage to Codacy
needs: [test-macos, test-ubuntu, test-windows, test-net-framework]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Download code coverage files (MacOS)
uses: actions/download-artifact@v3
with:
name: Code coverage (MacOS)
path: Coverage/MacOS
- name: Download code coverage files (Ubuntu)
uses: actions/download-artifact@v3
with:
name: Code coverage (Ubuntu)
path: Coverage/Ubuntu
- name: Download code coverage files (Windows)
uses: actions/download-artifact@v3
with:
name: Code coverage (Windows)
path: Coverage/Windows
- name: Generate coverage report
uses: danielpalme/ReportGenerator-GitHub-Action@v5.3.11
with:
reports: "Coverage/**/*.cobertura.xml"
targetdir: "coverage-report"
reporttypes: "Cobertura"
- name: Publish coverage report to Codacy
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage-report/Cobertura.xml
stryker-ubuntu:
name: Stryker mutation testing (Ubuntu)
runs-on: ubuntu-latest
timeout-minutes: 300
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Install .NET Stryker
shell: bash
run: |
dotnet tool install dotnet-stryker --tool-path ../tools
- name: Analyze Testably.Abstractions.Testing
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
shell: bash
run: |
cd Tests
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Testing.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext"
stryker-windows:
name: Stryker mutation testing (Windows)
runs-on: windows-latest
timeout-minutes: 300
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Install .NET Stryker
shell: bash
run: |
dotnet tool install dotnet-stryker --tool-path ../tools
- name: Analyze Testably.Abstractions
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
shell: bash
run: |
cd Tests
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext"
- name: Analyze Testably.Abstractions.AccessControl
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
shell: bash
run: |
cd Tests
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.AccessControl.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext"
- name: Analyze Testably.Abstractions.Compression
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
shell: bash
run: |
cd Tests
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Compression.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext"
deploy:
name: Deploy
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
environment: production
needs: [test-macos, test-ubuntu, test-windows, test-net-framework, test-examples, stryker-windows, stryker-ubuntu]
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Tag current commit
id: tag
shell: bash
run: |
version="${GITHUB_REF#refs/heads/release/}"
git tag "${version}"
git push origin "${version}"
echo "release_version=${version}" >> "$GITHUB_OUTPUT"
- name: Setup NuGet
uses: NuGet/setup-nuget@v2.0.1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Prepare README.md
shell: bash
run: |
version="${GITHUB_REF#refs/heads/release/}"
# Add changelog badge to README.md
sed -i -e "2 a\[!\[Changelog](https:\/\/img\.shields\.io\/badge\/Changelog-${version}-blue)](https:\/\/github\.com\/Testably\/Testably\.Abstractions\/releases\/tag\/${version})" "./README.md"
for f in "README.md" "Docs/AccessControl.md" "Docs/Compression.md" "Docs/Interface.md" "Docs/Testing.md"
do
echo "Processing $f" # always double quote "$f" filename
# do something on $f
# Remove the codacy and sonarcloud badge as it is not aligned to the release
grep -v "app.codacy.com" "./$f" > "./$f.backup" && mv "./$f.backup" "./$f"
grep -v "sonarcloud.io" "./$f" > "./$f.backup" && mv "./$f.backup" "./$f"
# Change status badges to display explicit version
sed -i -e "s/branch=main/branch=release%2F${version}/g" "./$f"
sed -i -e "s/Testably.Abstractions%2Fmain/Testably.Abstractions%2Frelease%2F${version}/g" "./$f"
sed -i -e "s/Testably.Abstractions%2Fmain/Testably.Abstractions%2Frelease%2F${version}/g" "./$f"
sed -i -e "s/Testably.Abstractions\/main)/Testably.Abstractions\/release\/${version})/g" "./$f"
sed -i -e "s/Testably.Abstractions\/actions\/workflows\/build.yml\/badge.svg)/Testably.Abstractions\/actions\/workflows\/build.yml\/badge.svg?branch=release\/${version})/g" "./$f"
sed -i -e "s/Testably.Abstractions\/actions\/workflows\/build.yml)/Testably.Abstractions\/actions\/workflows\/build.yml?query=branch%3Arelease%2F${version})/g" "./$f"
# Add absolute path to example section
sed -i -e 's/\(Examples\/README.md\)/https:\/\/github.com\/Testably\/Testably.Abstractions\/blob\/main\/Examples\/README.md/g' "./$f"
done
- name: Build
run: dotnet build --configuration "Release"
- name: Publish
run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}}
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.tag.outputs.release_version }}
tag_name: ${{ steps.tag.outputs.release_version }}
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
cleanup:
name: Cleanup
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
needs: [deploy]
steps:
- name: Comment relevant issues and pull requests
uses: apexskier/github-release-commenter@v1.3.6
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment-template: |
This is addressed in release {release_link}.
label-template: |
state: released
skip-label: |
state: released
dependencies
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Delete release branch
shell: bash
run: |
version="${GITHUB_REF#refs/heads/release/}"
git push origin -d "refs/heads/release/${version}"