Repository navigation
262 lines (251 loc) · 12.1 KB
/
Copy pathci.yml
File metadata and controls
262 lines (251 loc) · 12.1 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
# Continuous integration of the WCS.
#
# Every job runs on Windows: Windows is the reference platform of the WCS (Common/Log.Windows writes
# to the Windows event log, Common/Helper also targets net10.0-windows, the host runs as a Windows
# service) and Linux has not been verified. The .NET SDK is the one pinned by global.json, and every
# restore is in locked mode: a project whose packages.lock.json does not match its package
# references fails the job instead of resolving other versions.
#
# Every job ends by checking that the working tree is still clean: a build or a test that rewrites a
# tracked file (a lock file, a document, a fixture) or leaves a file .gitignore does not cover fails.
#
# The browser tests (Playwright) are in browser.yml; releases are in release.yml.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_NOLOGO: "true"
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true"
defaults:
run:
shell: pwsh
jobs:
build:
name: Restore, build and pack
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Restore (locked mode)
run: dotnet restore Wcs.slnx --locked-mode
- name: Build
run: dotnet build Wcs.slnx -c Release --no-restore
- name: Pack (the packages are not published, only kept as artefacts)
run: dotnet pack Wcs.slnx -c Release --no-build -o artifacts/packages
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: packages
path: artifacts/packages
if-no-files-found: error
- name: The working tree stays clean
run: |
$dirty = git status --porcelain
if ($dirty) { $dirty; throw 'The job changed tracked files or left files that .gitignore does not cover.' }
test:
name: Tests (${{ matrix.suite }})
runs-on: windows-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- suite: engine
projects: WCS/Wcs.Engine/tests/Wcs.Engine.Test/Wcs.Engine.Test.csproj
- suite: host
projects: WCS/Wcs.Host/tests/Wcs.Host.Test/Wcs.Host.Test.csproj
- suite: web-editor-bunit
projects: WCS/Wcs.WebEditor/tests/Wcs.WebEditor.Test/Wcs.WebEditor.Test.csproj
- suite: clients-and-contracts
projects: >-
WCS/Wcs.Api.Client/tests/Wcs.Api.Client.Test/Wcs.Api.Client.Test.csproj
WCS/Wcs.Wms.Client/tests/Wcs.Wms.Client.Test/Wcs.Wms.Client.Test.csproj
WCS/Wcs.Wms.Contracts/tests/Wcs.Wms.Contracts.Test/Wcs.Wms.Contracts.Test.csproj
- suite: sample-wms-end-to-end
projects: samples/Wcs.SampleWms.Test/Wcs.SampleWms.Test.csproj
- suite: tools
projects: >-
tools/Wcs.LinkCheck/tests/Wcs.LinkCheck.Test/Wcs.LinkCheck.Test.csproj
WCS/tools/Wcs.DbTool/tests/Wcs.DbTool.Test/Wcs.DbTool.Test.csproj
tools/Wcs.ContractCheck/tests/Wcs.ContractCheck.Test/Wcs.ContractCheck.Test.csproj
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Restore (locked mode)
run: dotnet restore Wcs.slnx --locked-mode
- name: Test
env:
SUITE: ${{ matrix.suite }}
PROJECTS: ${{ matrix.projects }}
run: |
$failed = @()
foreach ($project in ($env:PROJECTS -split '\s+' | Where-Object { $_ })) {
$name = [System.IO.Path]::GetFileNameWithoutExtension($project)
dotnet test $project -c Release --no-restore --logger "trx;LogFileName=$name.trx" --results-directory "TestResults/$env:SUITE"
if ($LASTEXITCODE -ne 0) { $failed += $name }
}
if ($failed) { throw "Failed: $($failed -join ', ')" }
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: test-results-${{ matrix.suite }}
path: TestResults
if-no-files-found: ignore
- name: The working tree stays clean
run: |
$dirty = git status --porcelain
if ($dirty) { $dirty; throw 'The job changed tracked files or left files that .gitignore does not cover.' }
vulnerable-packages:
name: Vulnerable packages
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Restore (locked mode)
run: dotnet restore Wcs.slnx --locked-mode
# `dotnet list package --vulnerable` exits with 0 whatever it finds: the JSON report is read
# and any vulnerable package, direct or transitive, fails the job.
- name: No known vulnerable package, direct or transitive
run: |
$json = (dotnet list Wcs.slnx package --vulnerable --include-transitive --format json) -join "`n"
if ($LASTEXITCODE -ne 0) { throw "dotnet list package failed (exit $LASTEXITCODE)" }
$report = $json | ConvertFrom-Json
$found = @()
foreach ($project in $report.projects) {
if (-not ($project.PSObject.Properties.Name -contains 'frameworks')) { continue }
foreach ($framework in $project.frameworks) {
foreach ($set in 'topLevelPackages', 'transitivePackages') {
if (-not ($framework.PSObject.Properties.Name -contains $set)) { continue }
foreach ($package in $framework.$set) {
foreach ($vulnerability in @($package.vulnerabilities)) {
if ($vulnerability) {
$found += "$($package.id) $($package.resolvedVersion) [$($vulnerability.severity)] $($vulnerability.advisoryurl) in $([System.IO.Path]::GetFileName($project.path)) ($($framework.framework))"
}
}
}
}
}
}
$problems = @(if ($report.PSObject.Properties.Name -contains 'problems') { $report.problems })
foreach ($problem in $problems) { Write-Host "$($problem.level): $($problem.text)" }
if ($found) { $found | Sort-Object -Unique | ForEach-Object { Write-Host $_ }; throw "$(@($found | Sort-Object -Unique).Count) vulnerable package entries" }
if ($problems | Where-Object level -eq 'error') { throw 'dotnet list package reported errors: the check is not conclusive' }
Write-Host "No vulnerable package in $(@($report.projects).Count) projects."
- name: The working tree stays clean
run: |
$dirty = git status --porcelain
if ($dirty) { $dirty; throw 'The job changed tracked files or left files that .gitignore does not cover.' }
markdown-links:
name: Markdown links
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# No NuGet cache: Wcs.LinkCheck has no packages, so on a cache miss the packages folder is
# never created and saving the cache fails the job.
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Restore (locked mode)
run: dotnet restore tools/Wcs.LinkCheck/src/Wcs.LinkCheck.csproj --locked-mode
- name: Check the links of the current documentation
run: dotnet run --project tools/Wcs.LinkCheck/src -c Release --no-restore -- .
# The checking functions of the release script (CHANGELOG sections, tags, versions in the docs,
# placeholders, local paths, secrets, vulnerable-package reports), on in-memory fixtures
- name: Self-test of tools/Test-PublicRelease.ps1
run: ./tools/Test-PublicRelease.ps1 -SelfTest
- name: The working tree stays clean
run: |
$dirty = git status --porcelain
if ($dirty) { $dirty; throw 'The job changed tracked files or left files that .gitignore does not cover.' }
sbom:
name: SBOM
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Restore (locked mode)
run: dotnet restore Wcs.slnx --locked-mode
# Regenerates the SBOM from the restored packages and the inventory of embedded components,
# and compares it with sbom/wcs.cdx.json: a package change without the SBOM fails here.
- name: sbom/wcs.cdx.json matches the packages
run: ./sbom/Test-WcsSbom.ps1 -Out "$env:RUNNER_TEMP/wcs.cdx.json"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: sbom
path: ${{ runner.temp }}/wcs.cdx.json
if-no-files-found: error
- name: The working tree stays clean
run: |
$dirty = git status --porcelain
if ($dirty) { $dirty; throw 'The job changed tracked files or left files that .gitignore does not cover.' }
# The machine-readable contracts in docs/contracts/ (OpenAPI of the host API and of the WMS contract)
# are regenerated from the code and must match the committed files, with every example valid. On a
# pull request the committed files of the target branch are the baseline: a breaking change fails
# unless the contract's major version was raised (docs/contracts/README.md).
contracts:
name: Machine-readable contracts
runs-on: windows-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Restore (locked mode)
run: dotnet restore Wcs.slnx --locked-mode
- name: Baseline from the target branch (pull requests only)
if: github.event_name == 'pull_request'
run: |
New-Item -ItemType Directory -Force baseline | Out-Null
foreach ($file in 'wcs-host.openapi.json', 'wms-contract.openapi.json') {
git show "origin/$($env:GITHUB_BASE_REF):docs/contracts/$file" | Set-Content -Encoding utf8NoBOM "baseline/$file"
if ($LASTEXITCODE -ne 0) { throw "No $file on the target branch" }
}
- name: Contracts match the code (and compatibility on pull requests)
run: |
if ($env:GITHUB_EVENT_NAME -eq 'pull_request') {
dotnet run --project tools/Wcs.ContractCheck/src -c Release --no-restore -- check --baseline baseline
} else {
dotnet run --project tools/Wcs.ContractCheck/src -c Release --no-restore -- check
}
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Remove the baseline
if: always()
run: Remove-Item -Recurse -Force baseline -ErrorAction SilentlyContinue
- name: The working tree stays clean
run: |
$dirty = git status --porcelain
if ($dirty) { $dirty; throw 'The job changed tracked files or left files that .gitignore does not cover.' }