-
Notifications
You must be signed in to change notification settings - Fork 0
305 lines (298 loc) · 13.3 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
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- published
workflow_dispatch:
env:
CI: true
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true
# Set the build number in MinVer.
MINVERBUILDMETADATA: build.${{github.run_number}}
jobs:
build:
permissions:
pull-requests: write
packages: write
checks: write
actions: write
statuses: write
name: Build .NET
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@v4
with:
global-json-file: ./src/HomeInventory/global.json
- name: Info
run: dotnet --info
working-directory: ./src/HomeInventory
- name: Download cached dependencies
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{github.ref}}
restore-keys: |
${{ runner.os }}-nuget-refs/heads/main
- name: Restore dependencies
run: dotnet restore HomeInventory.sln -v minimal
working-directory: ./src/HomeInventory
- name: Build Release
run: dotnet build HomeInventory.sln -m:1 -c Release -v minimal --nologo --no-incremental --no-restore --no-self-contained
working-directory: ./src/HomeInventory
- name: Cache build results
uses: actions/cache@v4
with:
path: ./src/HomeInventory
key: ${{ runner.os }}-build-${{github.ref}}-${{github.run_number}}
format-test:
name: "Formatting test"
needs: build
if: ${{ success() }}
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@v4
with:
global-json-file: ./src/HomeInventory/global.json
- name: Info
run: dotnet --info
working-directory: ./src/HomeInventory
- name: Download cached dependencies
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{github.ref}}
restore-keys: |
${{ runner.os }}-nuget-refs/heads/main
- name: Check formatting
run: dotnet format --verify-no-changes --severity error --verbosity diag HomeInventory.sln || (echo "Run 'dotnet format' to fix issues" && exit 1)
working-directory: ./src/HomeInventory
unit-test:
name: "Unit Test .NET"
needs: build
if: ${{ success() }}
permissions:
checks: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@v4
with:
global-json-file: ./src/HomeInventory/global.json
- name: Info
run: dotnet --info
working-directory: ./src/HomeInventory
- name: Cache build results
uses: actions/cache@v4
with:
path: ./src/HomeInventory
key: ${{ runner.os }}-build-${{github.ref}}-${{github.run_number}}
- name: Download cached dependencies
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{github.ref}}
restore-keys: |
${{ runner.os }}-nuget-refs/heads/main
- name: Run Architecture Tests
run: dotnet test HomeInventory.Tests --filter "Category=Architecture" -c Release -v minimal
working-directory: ./src/HomeInventory
- name: Run Unit Tests
if: success() || failure()
run: dotnet test HomeInventory.Tests --filter "Category=Unit" -c Release -v minimal --collect:"XPlat Code Coverage;CollectCoverage=true;Format=json,lcov,cobertura,opencover;SkipAutoProps=true;IncludeTestAssembly=false;ExcludeByFile=\"**/*.g.cs\"" --logger trx --results-directory ./coverage
working-directory: ./src/HomeInventory
- name: Test Report
uses: dorny/[email protected]
if: success() || failure()
with:
name: Unit tests # Name of the check run which will be created
path: "./src/HomeInventory/coverage/*.trx" # Path to test results
reporter: dotnet-trx # Format of test results
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
continue-on-error: true
if: always()
with:
files: |
./src/HomeInventory/coverage/**/*.trx
- name: Collect Coverage
run: cp coverage/**/coverage.cobertura.xml coverage.cobertura.xml
working-directory: ./src/HomeInventory
- name: Code Coverage Summary Report
id: report
uses: irongut/[email protected]
with:
filename: ./src/HomeInventory/coverage.cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: "60 80"
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event_name == 'pull_request' && (success() || steps.report.conclusion == 'failure') }}
with:
header: "Unit test coverage summary"
recreate: true
path: code-coverage-results.md
- name: Write coverage to Job Summary
if: ${{ success() || steps.report.conclusion == 'failure' }}
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
- name: Create code coverage report
uses: danielpalme/[email protected]
if: ${{ success() || steps.report.conclusion == 'failure' }}
with:
reports: "./src/HomeInventory/coverage.cobertura.xml" # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir: "coveragereport" # REQUIRED # The directory where the generated report should be saved.
reporttypes: "MarkdownSummaryGithub;HtmlInline_AzurePipelines_Dark;Cobertura;CodeClimate" # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, Html_Dark, Html_Light, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlInline_AzurePipelines_Light, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MarkdownSummaryGithub, MarkdownDeltaSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, TextDeltaSummary, Xml, XmlSummary
sourcedirs: "./src/HomeInventory" # Optional directories which contain the corresponding source code (separated by semicolon). The source directories are used if coverage report contains classes without path information.
historydir: "" # Optional directory for storing persistent coverage information. Can be used in future reports to show coverage evolution.
plugins: "" # Optional plugin files for custom reports or custom history storage (separated by semicolon).
assemblyfilters: "+*" # Optional list of assemblies that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
classfilters: "+*" # Optional list of classes that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
filefilters: "+*" # Optional list of files that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
verbosity: "Info" # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
title: "" # Optional title.
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version.
license: "" # Optional license for PRO version. Get your license here: https://reportgenerator.io/pro
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool.
- name: Add Coverage PR Comment 2
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event_name == 'pull_request' && (success() || steps.report.conclusion == 'failure') }}
with:
header: "Detailed"
recreate: true
path: coveragereport/SummaryGithub.md
- name: Write coverage to Job Summary 2
if: ${{ success() || steps.report.conclusion == 'failure' }}
run: cat coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: Upload coverage report artifact
uses: actions/[email protected]
if: ${{ success() || steps.report.conclusion == 'failure' }}
with:
name: CoverageReport # Artifact name
path: coveragereport # A file, directory or wildcard pattern that describes what to upload
if-no-files-found: warn # The desired behavior if no files are found using the provided path.
retention-days: 90 # Duration after which artifact will expire in days. 0 means using default retention.
intergration-test:
name: "Integration Test .NET"
needs: build
if: ${{ success() }}
permissions:
checks: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@v4
with:
global-json-file: ./src/HomeInventory/global.json
- name: Info
run: dotnet --info
working-directory: ./src/HomeInventory
- name: Cache build results
uses: actions/cache@v4
with:
path: ./src/HomeInventory
key: ${{ runner.os }}-build-${{github.ref}}-${{github.run_number}}
- name: Download cached dependencies
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{github.ref}}
restore-keys: |
${{ runner.os }}-nuget-refs/heads/main
- name: Run Integration Tests
run: dotnet test HomeInventory.Tests.Integration --filter "Category=Integration" -c Release -v minimal
working-directory: ./src/HomeInventory
acceptance-test:
name: "Acceptance Test .NET"
needs: build
if: ${{ success() }}
permissions:
checks: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@v4
with:
global-json-file: ./src/HomeInventory/global.json
- name: Info
run: dotnet --info
working-directory: ./src/HomeInventory
- name: Cache build results
uses: actions/cache@v4
with:
path: ./src/HomeInventory
key: ${{ runner.os }}-build-${{github.ref}}-${{github.run_number}}
- name: Download cached dependencies
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{github.ref}}
restore-keys: |
${{ runner.os }}-nuget-refs/heads/main
- name: Run Acceptance Tests
run: dotnet test HomeInventory.Tests.Acceptance -c Release -v minimal --logger:"trx;verbosity=normal;LogFileName=./Acceptance/AcceptanceTestResults.trx"
working-directory: ./src/HomeInventory
- name: Install Living Documentation Tool
run: dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI
- name: Generate Living Documentation Specification
run: livingdoc test-assembly "HomeInventory.Tests.Acceptance/bin/Release/net9/HomeInventory.Tests.Acceptance.dll" -t "HomeInventory.Tests.Acceptance/bin/Release/net9/TestExecution.json" -o "./Acceptance/AcceptanceTestResults.html"
working-directory: ./src/HomeInventory
- name: Publish Specflow Test Results
if: success() || failure()
uses: actions/[email protected]
with:
name: "Specflow Test Results"
path: ./Acceptance/AcceptanceTestResults.html
if-no-files-found: warn # The desired behavior if no files are found using the provided path.
retention-days: 90 # Duration after which artifact will expire in days. 0 means using default retention.