Repository navigation
274 lines (267 loc) · 10.8 KB
/
Copy pathbuild-and-tests.yml
File metadata and controls
274 lines (267 loc) · 10.8 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
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
name: Build and Tests
on:
push:
branches: [main]
paths-ignore:
- 'site/**'
- '.github/workflows/website.yml'
pull_request:
paths-ignore:
- 'site/**'
- '.github/workflows/website.yml'
workflow_dispatch:
workflow_call:
env:
KEYLOAD_TEST_CONFIGURATION: Release
permissions:
contents: read
# Shards and lanes come from scripts/Features/TestInfrastructure/ci-test-shards.json (ADR-148).
# Build owns the complete solution outputs. Test jobs consume that same build after it succeeds.
jobs:
build:
name: Build
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Download source code
uses: actions/checkout@v7
- name: Set up .NET
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
cache: true
cache-dependency-path: |
Directory.Packages.props
global.json
**/*.csproj
- name: Check repository rules
run: node scripts/Features/RepositoryGovernance/verify.mjs
- name: Check test shard partition
run: node scripts/Features/TestInfrastructure/ci-test-shards.mjs verify
- name: Build
run: dotnet build KeyLoad.slnx --configuration "$KEYLOAD_TEST_CONFIGURATION" -warnaserror
- name: Check compiled TUnit shard inventory
run: node --test scripts/Features/TestInfrastructure/ci-test-inventory.test.mjs
- name: Check compiled unit inventory and coverage selectors
shell: pwsh
run: |
$evidence = Join-Path $PWD 'tests/KeyLoad.FunctionalTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-inventory'
New-Item -ItemType Directory -Path $evidence -ErrorAction Stop | Out-Null
& ./scripts/Features/CodeQuality/functional-coverage.workflow-discovery.ps1 -Repository $PWD -EvidenceRoot $evidence
- name: Save compiled discovery evidence
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: compiled-test-discovery
path: |
tests/KeyLoad.FunctionalTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-inventory
tests/*/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/compiled-shard-inventory-*
if-no-files-found: warn
retention-days: 30
- name: Archive the built solution
run: |
python3 - <<'PY'
from pathlib import Path
import tarfile
import xml.etree.ElementTree as ET
Path('artifacts').mkdir(exist_ok=True)
with tarfile.open('artifacts/compiled-solution.tar.gz', 'w:gz', compresslevel=1) as archive:
for project in ET.parse('KeyLoad.slnx').findall('.//Project'):
directory = Path(project.attrib['Path']).parent
for output in (directory / 'bin' / 'Release', directory / 'obj'):
if not output.is_dir():
raise FileNotFoundError(output)
archive.add(output, arcname=output.as_posix())
PY
- name: Save the built solution
uses: actions/upload-artifact@v7
with:
name: compiled-solution
path: artifacts/compiled-solution.tar.gz
if-no-files-found: error
compression-level: 0
retention-days: 1
overwrite: true
shards:
name: Plan named test groups
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
functional: ${{ steps.plan.outputs.functional }}
cluster: ${{ steps.plan.outputs.cluster }}
steps:
- name: Download source code
uses: actions/checkout@v7
- name: Read the shard manifest
id: plan
run: |
echo "functional=$(node scripts/Features/TestInfrastructure/ci-test-shards.mjs matrix functional)" >> "$GITHUB_OUTPUT"
echo "cluster=$(node scripts/Features/TestInfrastructure/ci-test-shards.mjs matrix cluster)" >> "$GITHUB_OUTPUT"
functional:
name: Functional tests – ${{ matrix.name }}
needs: [build, shards]
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.shards.outputs.functional) }}
env:
SHARD: ${{ matrix.shard }}
steps:
- name: Download source code
uses: actions/checkout@v7
- name: Set up .NET
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
cache: true
cache-dependency-path: |
Directory.Packages.props
global.json
**/*.csproj
- name: Download the built solution
uses: actions/download-artifact@v8
with:
name: compiled-solution
path: artifacts
- name: Prepare the built solution
run: |
tar -xzf artifacts/compiled-solution.tar.gz -C "$GITHUB_WORKSPACE"
dotnet restore KeyLoad.slnx
- name: Test functional operations
run: node scripts/Features/TestInfrastructure/ci-test-shards.mjs run "$SHARD" --results-directory "$GITHUB_WORKSPACE/tests/KeyLoad.FunctionalTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-results"
- name: Save test results
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: test-results-functional-${{ matrix.shard }}
path: tests/KeyLoad.FunctionalTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-results
if-no-files-found: warn
retention-days: 30
overwrite: true
analyzers-recovery:
name: Analyzers and process recovery
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Download source code
uses: actions/checkout@v7
- name: Set up .NET
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
cache: true
cache-dependency-path: |
Directory.Packages.props
global.json
**/*.csproj
- name: Download the built solution
uses: actions/download-artifact@v8
with:
name: compiled-solution
path: artifacts
- name: Prepare the built solution
run: |
tar -xzf artifacts/compiled-solution.tar.gz -C "$GITHUB_WORKSPACE"
dotnet restore KeyLoad.slnx
- name: Test code analyzers
run: node scripts/Features/TestInfrastructure/ci-test-shards.mjs run compiler-analyzers --results-directory "$GITHUB_WORKSPACE/tests/KeyLoad.AnalyzerTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-results"
- name: Test process recovery
if: ${{ !cancelled() }}
run: node scripts/Features/TestInfrastructure/ci-test-shards.mjs run process-crash-recovery --results-directory "$GITHUB_WORKSPACE/tests/KeyLoad.ProcessRecoveryTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-results"
- name: Save test results
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: test-results-analyzers-recovery
path: |
tests/KeyLoad.AnalyzerTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-results
tests/KeyLoad.ProcessRecoveryTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-results
tests/KeyLoad.ProcessRecoveryTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/TestResults/crash-trials-*
if-no-files-found: warn
retention-days: 30
overwrite: true
cluster:
name: Cluster tests – ${{ matrix.name }}
needs: [build, shards]
runs-on: ubuntu-24.04
timeout-minutes: 55
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.shards.outputs.cluster) }}
env:
SHARD: ${{ matrix.shard }}
LANE: ${{ matrix.lane }}
steps:
- name: Download source code
uses: actions/checkout@v7
- name: Set up .NET
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
cache: true
cache-dependency-path: |
Directory.Packages.props
global.json
**/*.csproj
- name: Download the built solution
uses: actions/download-artifact@v8
with:
name: compiled-solution
path: artifacts
- name: Prepare the built solution
run: |
tar -xzf artifacts/compiled-solution.tar.gz -C "$GITHUB_WORKSPACE"
dotnet restore KeyLoad.slnx
- name: Prepare Aspire runtime
run: dotnet msbuild build/KeyLoad.AppHost/KeyLoad.AppHost.csproj -target:ResolveAspireCliBundlePaths -property:Configuration="$KEYLOAD_TEST_CONFIGURATION" -warnaserror
- name: Install administration browser
if: ${{ matrix.playwright }}
shell: pwsh
run: tests/KeyLoad.ClusterTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/playwright.ps1 install --with-deps chromium
- name: Prepare Chromium certificate store
if: ${{ matrix.playwright }}
run: |
sudo apt-get update
sudo apt-get install --yes libnss3-tools
mkdir -p "$HOME/.pki/nssdb"
if [[ ! -f "$HOME/.pki/nssdb/cert9.db" ]]; then
certutil -N -d "sql:$HOME/.pki/nssdb" --empty-password
fi
- name: Trust standard Aspire development certificate
run: |
export SSL_CERT_DIR="$HOME/.aspnet/dev-certs/trust:/usr/lib/ssl/certs"
echo "SSL_CERT_DIR=$SSL_CERT_DIR" >> "$GITHUB_ENV"
dotnet dev-certs https --trust
- name: Test Aspire topology lanes
run: node scripts/Features/TestInfrastructure/ci-test-shards.mjs run "$SHARD" --lane "$LANE" --results-directory "$GITHUB_WORKSPACE/tests/KeyLoad.ClusterTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-results"
- name: Save test results
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: test-results-cluster-${{ matrix.shard }}-${{ matrix.lane }}
path: |
tests/KeyLoad.ClusterTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/ci-results
tests/KeyLoad.ClusterTests/bin/${{ env.KEYLOAD_TEST_CONFIGURATION }}/net10.0/aspire-diagnostics-*.log
if-no-files-found: warn
retention-days: 30
overwrite: true
verify-partition:
name: Verify every required test ran exactly once
needs: [build, functional, analyzers-recovery, cluster]
if: ${{ !cancelled() && needs.build.result == 'success' }}
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Download source code
uses: actions/checkout@v7
- name: Download test results
uses: actions/download-artifact@v8
with:
pattern: test-results-*
path: TestResults
merge-multiple: true
- name: Check every test ran exactly once
run: node scripts/Features/TestInfrastructure/ci-test-shards.mjs verify TestResults