Repository navigation
152 lines (131 loc) · 5.74 KB
/
Copy pathbuild.yml
File metadata and controls
152 lines (131 loc) · 5.74 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
name: Build Spectrum
on:
push:
pull_request:
jobs:
build:
runs-on: windows-2025-vs2026
strategy:
fail-fast: false
matrix:
configuration: [Debug-D3D12, Debug-Vulkan]
# Cache vcpkg's per-package binary archives, not vcpkg_installed: vcpkg keys
# each archive by ABI hash (compiler, tool version, portfile), so a runner
# image update only rebuilds what actually changed. A cached vcpkg_installed
# is thrown away wholesale on any such mismatch.
env:
VCPKG_BINARY_CACHE_DIR: ${{ github.workspace }}\vcpkg_binary_cache
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg_binary_cache,readwrite
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
# The key is unique per run so a partially-built cache (vcpkg install failed
# halfway) can still be saved; restore-keys picks up the newest prior one.
- name: Restore vcpkg binary cache
uses: actions/cache/restore@v4
with:
path: ${{ env.VCPKG_BINARY_CACHE_DIR }}
key: vcpkg-bin-v3-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'custom-overlay/**') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
vcpkg-bin-v3-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'custom-overlay/**') }}-
vcpkg-bin-v3-${{ runner.os }}-
- name: Snapshot vcpkg binary cache
id: vcpkg-cache-before
shell: powershell
run: |
New-Item -ItemType Directory -Force "$env:VCPKG_BINARY_CACHE_DIR" | Out-Null
$n = (Get-ChildItem "$env:VCPKG_BINARY_CACHE_DIR" -Recurse -Filter *.zip).Count
"count=$n" >> $env:GITHUB_OUTPUT
"since=$((Get-Date).ToUniversalTime().Ticks)" >> $env:GITHUB_OUTPUT
Write-Host "$n archives restored"
- name: Setup project
shell: cmd
run: setup.bat
- name: Generate Visual Studio projects
shell: cmd
run: generate_project.bat
- name: Install vcpkg dependencies
id: vcpkg-install
shell: cmd
run: vcpkg install --triplet x64-windows --x-install-root ./vcpkg_installed/x64-windows
# Drop archives whose ABI no longer appears in the installed status file,
# otherwise every compiler/port bump leaves dead archives in the cache
# forever. Only safe after a successful install: a failed one has an
# incomplete status file and would prune archives that are still valid.
- name: Prune stale vcpkg binary archives
if: steps.vcpkg-install.outcome == 'success'
shell: powershell
run: |
$status = "vcpkg_installed/x64-windows/vcpkg/status"
if (-not (Test-Path $status)) { Write-Host "no status file at $status, skipping prune"; exit 0 }
$live = @{}
Select-String -Path $status -Pattern '^Abi: (\w+)' | ForEach-Object { $live[$_.Matches[0].Groups[1].Value] = $true }
if ($live.Count -eq 0) { Write-Host "no ABIs in $status, skipping prune"; exit 0 }
$stale = Get-ChildItem "$env:VCPKG_BINARY_CACHE_DIR" -Recurse -Filter *.zip | Where-Object { -not $live.ContainsKey($_.BaseName) }
$stale | Remove-Item -Force
Write-Host "$($live.Count) live ABIs, pruned $(@($stale).Count) stale archives"
- name: Check vcpkg binary cache for changes
id: vcpkg-cache-after
if: always() && steps.vcpkg-install.outcome != 'skipped'
shell: powershell
run: |
$files = Get-ChildItem "$env:VCPKG_BINARY_CACHE_DIR" -Recurse -Filter *.zip
$changed = ($files.Count -ne ${{ steps.vcpkg-cache-before.outputs.count }}) -or
(@($files | Where-Object { $_.LastWriteTimeUtc.Ticks -gt ${{ steps.vcpkg-cache-before.outputs.since }} }).Count -gt 0)
"changed=$($changed.ToString().ToLower())" >> $env:GITHUB_OUTPUT
Write-Host "$($files.Count) archives now, changed=$changed"
- name: Save vcpkg binary cache
if: always() && steps.vcpkg-cache-after.outputs.changed == 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.VCPKG_BINARY_CACHE_DIR }}
key: vcpkg-bin-v3-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'custom-overlay/**') }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Integrate vcpkg with MSBuild
shell: cmd
run: vcpkg integrate install
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Debug vcpkg installed dir
shell: powershell
run: |
msbuild ./projects/modules/modules.vcxproj `
/p:Configuration="${{ matrix.configuration }}" /p:Platform=x64 `
/pp:preprocessed.xml
Select-String "_ZVcpkgCurrentInstalledDir" preprocessed.xml | Select-Object -First 5
- name: Build solution
run: msbuild ./projects/spectrum.sln /p:Configuration="${{ matrix.configuration }}" /p:Platform=x64 /m /v:minimal
- name: Upload build output
uses: actions/upload-artifact@v4
if: always()
with:
name: build-${{ matrix.configuration }}
path: ./bin/Debug/
retention-days: 1
test:
runs-on: windows-2025-vs2026
needs: build
strategy:
matrix:
configuration: [Debug-D3D12, Debug-Vulkan]
steps:
- name: Download build output
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.configuration }}
path: ./bin/Debug
- name: Run tests
shell: powershell
working-directory: ./bin/Debug
run: |
& ".\test.exe"
if ($LASTEXITCODE -ne 0) {
Write-Error "Tests failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
Write-Host "All tests passed!"