forked from leeter/WinMTR-refresh
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (121 loc) · 5 KB
/
Copy pathwindows-build.yml
File metadata and controls
140 lines (121 loc) · 5 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
name: Windows Build
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
schedule:
- cron: "23 18 * * 2"
permissions:
contents: read
concurrency:
group: windows-build-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
name: x64 ${{ matrix.configuration }}
runs-on: windows-2022
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
configuration:
- Debug
- Release
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v4
- name: Locate MSBuild
id: msbuild
shell: pwsh
run: |
$vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
$msbuild = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild `
-find "MSBuild\**\Bin\MSBuild.exe" | Select-Object -First 1
if (-not $msbuild) { throw "MSBuild was not found" }
"path=$msbuild" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Build checked-in Visual Studio solution
shell: pwsh
run: |
& "${{ steps.msbuild.outputs.path }}" WinMTR.sln /m `
"/p:Configuration=${{ matrix.configuration }}" /p:Platform=x64
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Configure authoritative CMake build
run: >-
cmake -S . -B "out/build/${{ matrix.configuration }}"
-G "Visual Studio 17 2022" -A x64
-DBUILD_TESTING=ON
- name: Build CMake graph
run: >-
cmake --build "out/build/${{ matrix.configuration }}"
--config "${{ matrix.configuration }}" --parallel
- name: Run offline tests
run: >-
ctest --test-dir "out/build/${{ matrix.configuration }}"
-C "${{ matrix.configuration }}" --output-on-failure
- name: Validate report schema and golden sample
run: python tests/validate_report_schema.py
- name: Verify x64 release imports and manifest policy
if: matrix.configuration == 'Release'
shell: pwsh
run: |
$vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
$dumpbin = & $vswhere -latest -products * `
-find "VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" | Select-Object -First 1
if (-not $dumpbin) { throw "dumpbin was not found" }
$dependencies = & $dumpbin /dependents Release_x64\WinMTR.exe | Out-String
if ($dependencies -match '(?im)^\s*(VCRUNTIME|MSVCP|MFC)[^\s]*\.DLL\s*$') {
throw "Release artifact unexpectedly imports a dynamic VC/MFC runtime`n$dependencies"
}
if (-not (Select-String -Path app.manifest -SimpleMatch 'level="asInvoker"')) {
throw "Application manifest must remain asInvoker"
}
$imports = & $dumpbin /imports Release_x64\WinMTR.exe | Out-String
$imports | Set-Content Release_x64\IMPORTS.txt -Encoding utf8
foreach ($forbidden in @('GetAddrInfoExCancel', 'GetAddrInfoExOverlappedResult')) {
if ($imports -match "(?m)\b$forbidden\b") {
throw "Windows 7 release statically imports $forbidden"
}
}
$hash = (Get-FileHash Release_x64\WinMTR.exe -Algorithm SHA256).Hash.ToLowerInvariant()
"$hash *WinMTR.exe" | Set-Content Release_x64\SHA256SUMS.txt -Encoding ascii
- name: Generate SPDX release SBOM
if: matrix.configuration == 'Release'
shell: pwsh
run: >-
pwsh -NoProfile -ExecutionPolicy Bypass -File .github/scripts/New-ReleaseSbom.ps1
-OutputPath Release_x64/WinMTR-Hyper.spdx.json
-Commit "${{ github.sha }}"
- name: Upload verified release artifact
if: matrix.configuration == 'Release'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4
with:
name: WinMTR-Hyper-x64-${{ github.sha }}
if-no-files-found: error
path: |
Release_x64/WinMTR.exe
Release_x64/WinMTR.pdb
Release_x64/SHA256SUMS.txt
Release_x64/IMPORTS.txt
Release_x64/WinMTR-Hyper.spdx.json
docs/schema/winmtr-report-v1.json
address-sanitizer:
name: x64 core AddressSanitizer
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: windows-2022
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v4
- name: Configure ASAN core tests
run: >-
cmake -S . -B out/build/asan
-G "Visual Studio 17 2022" -A x64
-DBUILD_TESTING=ON -DWINMTR_ENABLE_ASAN=ON
- name: Build ASAN core tests
run: cmake --build out/build/asan --config Debug --target WinMTRCoreTests --parallel
- name: Run ASAN core tests
run: ctest --test-dir out/build/asan -C Debug --output-on-failure