Repository navigation
85 lines (74 loc) · 3.1 KB
/
Copy pathbuild.yml
File metadata and controls
85 lines (74 loc) · 3.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
name: Build
# Builds every project and target, and checks the packages for known vulnerabilities, on every pull request and every push to master.
# The library builds for netstandard2.0, netstandard2.1, net6.0, net8.0, net9.0, net10.0 and net11.0.
# The test suite does not run here. Its timing-sensitive channel tests fail on small hosted runners (they fail on master too),
# so the owner runs the full suite locally before every release.
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
permissions:
contents: read
# One group per ref: a pull request's ref (refs/pull/N/merge) never equals master's, so a pull request run can never cancel a master run.
# A newer push to a pull request cancels the older run; master and manual runs queue and are never cancelled.
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
build:
name: Build every project and target
runs-on: windows-latest
timeout-minutes: 20
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v6
with:
dotnet-version: 11.0.x
# Builds the library for all of its target frameworks, plus the tests, the comparison app and the benchmarks.
# Only the build runs here: no benchmark is run. Any warning fails the run.
- name: Build the solution (Release, warnings as errors)
run: dotnet build Open.ChannelExtensions.sln -c Release -warnaserror
vulnerable-packages:
name: Vulnerable packages
runs-on: windows-latest
timeout-minutes: 15
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v6
with:
dotnet-version: 11.0.x
# `dotnet list package --vulnerable` exits 0 even when it finds something, so read what it prints.
- name: List vulnerable packages (any finding fails the run)
run: |
$projects = @(Get-ChildItem -Recurse -Filter *.csproj)
$failures = @()
foreach ($project in $projects) {
$output = (dotnet list $project.FullName package --vulnerable --include-transitive 2>&1 | Out-String)
$exitCode = $LASTEXITCODE
Write-Host $output
if ($exitCode -ne 0) {
$failures += "$($project.Name): dotnet list exited with code $exitCode"
}
elseif ($output -match 'has the following vulnerable packages') {
$failures += "$($project.Name): vulnerable packages found (listed above)"
}
elseif ($output -match 'NU1900') {
$failures += "$($project.Name): the vulnerability data could not be read, so the check proved nothing"
}
}
if ($failures.Count -gt 0) {
foreach ($failure in $failures) { Write-Host "::error title=Vulnerable packages::$failure" }
exit 1
}
"No vulnerable packages in $($projects.Count) project(s)."