-
Notifications
You must be signed in to change notification settings - Fork 42
230 lines (208 loc) · 8.54 KB
/
ci.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
name: CI
on:
push:
branches:
- 'main'
paths-ignore:
- 'docs/**'
- README.md
- CHANGELOG.md
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
configuration:
description: 'Build Configuration'
required: true
default: 'Debug'
type: choice
options:
- Debug
- Release
production_release:
description: 'If the build produces a production package'
type: boolean
default: false
required: true
version_suffix:
description: 'Suffix for the NuGet packages (without leading -). Build ID will be appended. Use "-" to force empty.'
required: false
specs_filter:
description: 'Filter for Specs execution (e.g. Category=basicExecution)'
required: false
permissions:
checks: write
env:
SPECS_FILTER: "" # use for testing CI: "&Category=basicExecution"
REQNROLL_TEST_PIPELINEMODE: true
jobs:
build:
runs-on: ubuntu-latest
outputs:
product_version_suffix: ${{ steps.versions.outputs.product_version_suffix }}
product_configuration: ${{ steps.versions.outputs.product_configuration }}
build_params: ${{ steps.versions.outputs.build_params }}
test_params: ${{ steps.versions.outputs.test_params }}
specs_filter: ${{ steps.versions.outputs.specs_filter }}
gh_logger_settings: ${{ steps.versions.outputs.gh_logger_settings }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- id: versions
name: Calculate versions
shell: pwsh
env:
APPINSIGHTS_KEY: ${{ secrets.APPINSIGHTS_KEY }}
run: |
$productionReleaseSetting = "${{ inputs.production_release }}"
$productionRelease = $false
if ($productionReleaseSetting -eq 'true') {
$productionRelease = $true
}
Write-Output "Production release: $productionRelease"
$versionSuffix = "${{ inputs.version_suffix }}"
if ($versionSuffix -eq "") {
$date = [datetime]::Today
$dateString = $date.ToString('yyyyMMdd')
$versionSuffix = "ci$dateString-${env:GITHUB_RUN_NUMBER}"
}
elseif ($versionSuffix -eq "-") {
$versionSuffix = ""
}
else {
$versionSuffix = "$versionSuffix-${env:GITHUB_RUN_NUMBER}"
}
Write-Output "product_version_suffix=$versionSuffix" >> $env:GITHUB_OUTPUT
Write-Output "Product Suffix: $versionSuffix"
$productConfig = "${{ inputs.configuration }}"
if ($productConfig -eq "") {
$productConfig = "Debug"
}
Write-Output "product_configuration=$productConfig" >> $env:GITHUB_OUTPUT
Write-Output "Product Configuration: $productConfig"
$specsFilter = "${{ inputs.specs_filter }}"
if ($specsFilter -ne "") {
$specsFilter = "&$specsFilter"
}
else {
$specsFilter = $env:SPECS_FILTER
}
Write-Output "specs_filter=$specsFilter" >> $env:GITHUB_OUTPUT
Write-Output "Specs Filter: $specsFilter"
$buildParams = "-p:VersionSuffix=$versionSuffix -c $productConfig"
Write-Output "build_params=$buildParams" >> $env:GITHUB_OUTPUT
Write-Output "Build Params: $buildParams"
$mainBuildParams = $buildParams
if ($productionRelease) {
$mainBuildParams = "$mainBuildParams -p:AppInsightsInstrumentationKey=$env:APPINSIGHTS_KEY"
Write-Output "Main Build Params Updated for Production"
}
Write-Output "main_build_params=$mainBuildParams" >> $env:GITHUB_OUTPUT
$gitHubActionsLoggerSettings = '"GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true;annotations.titleFormat=[@traits.Category] @test;annotations.messageFormat=@error\n@trace"'
$testParams = "--no-build --verbosity normal -c $productConfig --logger $gitHubActionsLoggerSettings -- RunConfiguration.CollectSourceInformation=true RunConfiguration.TreatNoTestsAsError=true"
Write-Output "test_params=$testParams" >> $env:GITHUB_OUTPUT
Write-Output "Test Params: $testParams"
- name: Restore dependencies
run: dotnet restore
- name: Install Test Report Dependencies
run: |
dotnet add ./Tests/Reqnroll.RuntimeTests/Reqnroll.RuntimeTests.csproj package GitHubActionsTestLogger
dotnet add ./Tests/Reqnroll.PluginTests/Reqnroll.PluginTests.csproj package GitHubActionsTestLogger
dotnet add ./Tests/Reqnroll.GeneratorTests/Reqnroll.GeneratorTests.csproj package GitHubActionsTestLogger
- name: Build
run: dotnet build --no-restore ${{ steps.versions.outputs.main_build_params }}
- name: Runtime Tests
run: dotnet test ./Tests/Reqnroll.RuntimeTests/Reqnroll.RuntimeTests.csproj --logger "trx;LogFileName=runtimetests-results.trx" ${{ steps.versions.outputs.test_params }}
- name: Generator Tests
run: dotnet test ./Tests/Reqnroll.GeneratorTests/Reqnroll.GeneratorTests.csproj --logger "trx;LogFileName=generatortests-results.trx" ${{ steps.versions.outputs.test_params }}
- name: Plugin Tests
run: dotnet test ./Tests/Reqnroll.PluginTests/Reqnroll.PluginTests.csproj --logger "trx;LogFileName=plugintests-results.trx" ${{ steps.versions.outputs.test_params }}
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages
path: "GeneratedNuGetPackages/**/*.*nupkg"
- name: Upload TRX files
uses: actions/upload-artifact@v4
if: always()
with:
name: build-trx
path: "**/*.trx"
specs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Restore dependencies
run: dotnet restore
- name: Install Test Report Dependencies
run: |
dotnet add ./Tests/Reqnroll.Specs/Reqnroll.Specs.csproj package GitHubActionsTestLogger
- name: Build
run: dotnet build --no-restore ${{ needs.build.outputs.build_params }}
- name: Specs
shell: pwsh
run: dotnet test ./Tests/Reqnroll.Specs/Reqnroll.Specs.csproj --filter "Category!=quarantaine{{ needs.build.outputs.specs_filter }}" --logger "trx;LogFileName=specs-results.trx" ${{ needs.build.outputs.test_params }}
- name: Upload TRX files
uses: actions/upload-artifact@v4
if: always()
with:
name: specs-trx
path: "**/specs-results.trx"
system-tests-windows:
runs-on: windows-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: .NET Information
run: |
dotnet --list-sdks
dotnet --list-runtimes
- name: Restore dependencies
run: dotnet restore
- name: Install Test Report Dependencies
run: |
dotnet add ./Tests/Reqnroll.SystemTests/Reqnroll.SystemTests.csproj package GitHubActionsTestLogger
- name: Build
run: dotnet build --no-restore ${{ needs.build.outputs.build_params }}
- name: System Tests
shell: pwsh
run: dotnet test ./Tests/Reqnroll.SystemTests/Reqnroll.SystemTests.csproj --logger "trx;LogFileName=systemtests-windows-results.trx" ${{ needs.build.outputs.test_params }}
- name: Upload Test Result TRX Files
uses: actions/upload-artifact@v4
if: always()
with:
name: systemtests-windows-trx
path: "**/*.trx"
system-tests-linux:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: .NET Information
run: |
dotnet --list-sdks
dotnet --list-runtimes
- name: Restore dependencies
run: dotnet restore
- name: Install Test Report Dependencies
run: |
dotnet add ./Tests/Reqnroll.SystemTests/Reqnroll.SystemTests.csproj package GitHubActionsTestLogger
- name: Build
run: dotnet build --no-restore ${{ needs.build.outputs.build_params }}
- name: System Tests
shell: pwsh
run: dotnet test ./Tests/Reqnroll.SystemTests/Reqnroll.SystemTests.csproj --filter "TestCategory!=MsBuild&TestCategory!=Net481" --logger "trx;LogFileName=systemtests-linux-results.trx" ${{ needs.build.outputs.test_params }}
- name: Upload Test Result TRX Files
uses: actions/upload-artifact@v4
if: always()
with:
name: systemtests-linux-trx
path: "**/*.trx"