-
Notifications
You must be signed in to change notification settings - Fork 71
399 lines (339 loc) · 14.7 KB
/
Copy pathbuild-nabla.yml
File metadata and controls
399 lines (339 loc) · 14.7 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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
name: Build
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
checks: write
concurrency:
group: push-lock-${{ github.ref }}
cancel-in-progress: true
jobs:
build-windows:
name: Nabla (${{ matrix.os }}, ${{ matrix.vendor }}-${{ matrix.tag }}, ${{ matrix.config }})
runs-on: ${{ matrix.os }}
env:
image: ghcr.io/devsh-graphics-programming/docker-nanoserver-msvc-winsdk
entry: pwsh.exe
cmd: -NoLogo -NoProfile -ExecutionPolicy Bypass
mount: C:\mount\nabla
binary: C:\mount\nabla\build-ct
install: build-ct\install
strategy:
fail-fast: false
matrix:
# vendor: [msvc, clangcl]
# TODO: Yas please fix ClangCL, we have a few new compile errors
# if we build MSVC then build "run-compiler-explorer" target, for ClangCL build just "nsc"
vendor: [msvc]
config: [Release, Debug, RelWithDebInfo]
tag: ['17.13.6']
os: [windows-2022]
steps:
- name: Environment Setup
run: |
Add-MpPreference -ExclusionPath "${{ github.workspace }}"
Add-MpPreference -ExclusionExtension "*.*"
Add-MpPreference -ExclusionProcess "docker.exe"
Add-MpPreference -ExclusionProcess "dockerd.exe"
Set-MpPreference -RemediationScheduleDay 8
Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference -DisableRemovableDriveScanning $true
Set-MpPreference -DisableArchiveScanning $true
Set-MpPreference -DisableScanningMappedNetworkDrivesForFullScan $true
if (-not (docker network ls --format '{{.Name}}' | Where-Object { $_ -eq 'docker_default' })) {
docker network create --driver nat docker_default
if ($LASTEXITCODE -ne 0) { exit 1 }
}
- name: Set prefix
id: set-prefix
shell: pwsh
run: |
$prefix = "run-windows-${{ matrix.tag }}-${{ matrix.vendor }}-${{ matrix.config }}"
$owner = "${{ github.repository_owner }}"
$package = "nabla-shader-compiler-godbolt"
$tag = "build-${{ matrix.vendor }}-${{ matrix.config }}-${{ matrix.tag }}"
$nscTargetTaggedImage = "ghcr.io/${owner}/${package}:${tag}".ToLower()
$nscTargetTaggedImageLatest = "ghcr.io/${owner}/${package}:latest".ToLower()
$shouldPushImage = (
"${{ github.ref }}" -eq "refs/heads/master" -and
"${{ matrix.vendor }}" -eq "msvc" -and
"${{ matrix.config }}" -eq "Release"
)
Write-Host "::notice::Should push image? $shouldPushImage"
"prefix=$prefix" >> $env:GITHUB_OUTPUT
"nscTargetTaggedImage=$nscTargetTaggedImage" >> $env:GITHUB_OUTPUT
"nscTargetTaggedImageLatest=$nscTargetTaggedImageLatest" >> $env:GITHUB_OUTPUT
"shouldPushImage=$shouldPushImage" >> $env:GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Pull Image
run: |
docker pull "${{ env.image }}:${{ matrix.tag }}"
- name: Run Container
run: |
$ctx = docker context show
$dockerHost = (docker context inspect $ctx | ConvertFrom-Json).Endpoints.docker.Host
$pipeName = [regex]::Match($dockerHost, '/pipe/(?<n>.+)$').Groups['n'].Value
$pipeHost = "\\.\pipe\$pipeName"
docker run `
--entrypoint ${{ env.entry }} -di --isolation process `
--env-file .\docker\ci-windows.env `
--env-file .\docker\ninja.env `
--env "NSC_IMAGE_NAME=${{ steps.set-prefix.outputs.nscTargetTaggedImage }}" `
--name orphan --network docker_default `
-v "${{ github.workspace }}:${{ env.mount }}" `
-v "${pipeHost}:\\.\pipe\dockerd" -e "DOCKER_HOST=npipe:////./pipe/dockerd" `
-w "${{ env.mount }}" `
"${{ env.image }}:${{ matrix.tag }}" `
${{ env.cmd }}
- name: Inspect Container
run: |
docker inspect orphan
- name: Container – Unpack Packages
run: |
docker exec orphan `
${{ env.entry }} ${{ env.cmd }} C:\unpack.ps1
- name: Container – Configure Project with CMake
run: |
mkdir profiling
docker exec orphan `
${{ env.entry }} ${{ env.cmd }} -Command cmake `
--preset ci-configure-dynamic-${{ matrix.vendor }} `
--profiling-output=profiling/cmake-profiling.json `
--profiling-format=google-trace
- name: Container – Build NSC
run: |
docker exec orphan `
${{ env.entry }} ${{ env.cmd }} -Command cmake --build `
--preset ci-build-dynamic-${{ matrix.vendor }} `
-t run-compiler-explorer --config ${{ matrix.config }}
- name: Container – Install Nabla
run: |
docker exec orphan `
${{ env.entry }} ${{ env.cmd }} -Command cmake --install `
${{ env.binary }} --config ${{ matrix.config }} `
--prefix ${{ env.install }}
- name: API / Examples / Check Run (Create)
id: check-run-create
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const response = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: `Examples (${{ matrix.os }}, ${{ matrix.vendor }}-${{ matrix.tag }}, ${{ matrix.config }})`,
head_sha: context.sha,
status: 'in_progress'
});
return response.data.id;
- name: Container – Build & Install Examples
id: build-examples
continue-on-error: true
run: |
docker exec orphan `
${{ env.entry }} ${{ env.cmd }} -Command cmake --build `
--preset ci-build-dynamic-${{ matrix.vendor }} `
-t examples_tests\all --config ${{ matrix.config }} `
-- -k 0
docker exec orphan `
${{ env.entry }} ${{ env.cmd }} -Command cmake --install `
${{ env.binary }}\examples_tests --config ${{ matrix.config }} `
--prefix ${{ env.install }}
- name: API / Examples / Check Run (Conclusion)
id: outcome-examples
run: |
$completedAt = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
if ("${{ steps.build-examples.outcome }}" -eq "success") {
"conclusion=success" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
} else {
"conclusion=failure" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
"completed_at=$completedAt" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: API / Examples / Check Run (Update)
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.checks.update({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: ${{ steps.check-run-create.outputs.result }},
status: 'completed',
conclusion: '${{ steps.outcome-examples.outputs.conclusion }}',
completed_at: '${{ steps.outcome-examples.outputs.completed_at }}',
output: {
title: '',
summary: '[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to see details.'
}
});
- name: Container – Save NSC Image
run: |
docker exec orphan `
${{ env.entry }} ${{ env.cmd }} -Command docker `
save ${{ steps.set-prefix.outputs.nscTargetTaggedImage }} | zstd -T0 -3 -f -o ${{ steps.set-prefix.outputs.prefix }}-nsc-godbolt-image.tar.zst
- name: Package left workflow artifacts
run: |
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-profiling.tar" profiling
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-install.tar" ${{ env.install }}
- name: Upload NSC Godbolt Image artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-prefix.outputs.prefix }}-nsc-godbolt-image
path: ${{ steps.set-prefix.outputs.prefix }}-nsc-godbolt-image.tar.zst
compression-level: 0
- name: Upload profiling artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-prefix.outputs.prefix }}-profiling
path: ${{ steps.set-prefix.outputs.prefix }}-profiling.tar
- name: Upload install artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-prefix.outputs.prefix }}-install
path: ${{ steps.set-prefix.outputs.prefix }}-install.tar
- name: Login to GHCR
if: steps.set-prefix.outputs.shouldPushImage == 'True'
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u $env:GITHUB_ACTOR --password-stdin
- name: Tag Latest image
if: steps.set-prefix.outputs.shouldPushImage == 'True'
run: |
docker tag ${{ steps.set-prefix.outputs.nscTargetTaggedImage }} ${{ steps.set-prefix.outputs.nscTargetTaggedImageLatest }}
- name: Push images to GHCR
if: steps.set-prefix.outputs.shouldPushImage == 'True'
run: |
docker push ${{ steps.set-prefix.outputs.nscTargetTaggedImageLatest }}
update-badges:
name: Update Build & Image Badges
if: ${{ always() && github.ref == 'refs/heads/master' }}
needs: build-windows
runs-on: windows-2022
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Build Badge
run: |
$jobStatus = "${{ needs.build-windows.result }}"
$buildMsg = if ($jobStatus -eq "success") { "passing" } else { "failing" }
$buildColor = if ($jobStatus -eq "success") { "brightgreen" } else { "red" }
$buildBadge = @{
schemaVersion = 1
label = "build"
message = $buildMsg
color = $buildColor
} | ConvertTo-Json -Depth 2
$buildPath = ".badge-public/nabla"
New-Item -ItemType Directory -Path $buildPath -Force | Out-Null
$buildBadge | Set-Content -Path "$buildPath/build.json" -Encoding utf8
- name: Create Image Size Badge
run: |
$owner = "${{ github.repository_owner }}"
$package = "nabla-shader-compiler-godbolt"
$image = "ghcr.io/${owner}/${package}:latest".ToLower()
$manifest = docker manifest inspect $image | ConvertFrom-Json
if ($manifest.manifests) {
$totalSize = ($manifest.manifests | Measure-Object -Property size -Sum).Sum
} elseif ($manifest.layers) {
$totalSize = ($manifest.layers | Measure-Object -Property size -Sum).Sum
} else {
Write-Error "No valid size information found in manifest."
exit 1
}
$sizeMB = [Math]::Round($totalSize / 1MB, 2)
$size = "$sizeMB MB"
$imageBadge = @{
schemaVersion = 1
label = $image
message = $size
color = "blue"
} | ConvertTo-Json -Depth 2
$imagePath = ".badge-public/packages/nabla-shader-compiler-nsc"
New-Item -ItemType Directory -Path $imagePath -Force | Out-Null
$imageBadge | Set-Content -Path "$imagePath/image-badge.json" -Encoding utf8
- name: Deploy Badges
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: badges
publish_dir: .badge-public
keep_files: true
commit_message: "[CI] badges update"
deploy-production:
name: Deploy Godbolt production image
if: ${{ always() && github.ref == 'refs/heads/master' }}
needs: build-windows
runs-on: windows-2022
steps:
- name: Invoke Web Request
run: |
function Invoke-UpdateImages {
param(
[string]$Token,
[string]$Url = 'https://godbolt.devsh.eu/api/update-images'
)
$resp = Invoke-WebRequest -Method Post `
-Uri $Url `
-Headers @{ 'X-API-Token' = $Token } `
-SkipHttpErrorCheck
$httpCode = $resp.StatusCode
$body = $resp.Content | ConvertFrom-Json
Write-Host "HTTP code : $httpCode"
Write-Host "status : $($body.status)"
Write-Host "message : $($body.message)"
if ($httpCode -ne 200) {
throw "Request failed"
}
}
$token = '${{ secrets.CE_IMAGE_UPDATE_TOKEN }}'
Invoke-UpdateImages -Token $token
smoke-tests:
name: Nabla / Smoke (${{ matrix.os }}, ${{ matrix.vendor }}-latest, ${{ matrix.config }})
needs: build-windows
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
config: [Release, Debug, RelWithDebInfo]
os: [windows-2022]
vendor: [msvc]
steps:
- name: Checkout smoke
uses: actions/checkout@v4
with:
fetch-depth: 1
sparse-checkout: |
smoke
- name: Download VulkanSDK
uses: jakoch/install-vulkan-sdk-action@v1
with:
install_runtime: true
cache: false
stripdown: true
install_lavapipe: true
- name: Add lavapipe driver
run: reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers" /v "C:\lavapipe\share\vulkan\icd.d\lvp_icd.x86_64.json" /t REG_DWORD /d 0 /f
- name: Download Nabla install artifact
uses: actions/download-artifact@v4
with:
name: run-windows-17.13.6-msvc-${{ matrix.config }}-install
path: smoke
- name: Unpack Nabla install artifact
run: |
$tar = Get-ChildItem smoke -Filter *-install.tar -File | Select-Object -First 1
if (-not $tar) { throw "install tar not found in smoke" }
tar -xf $tar.FullName -C smoke
if (-not (Test-Path "smoke/build-ct/install")) { throw "smoke/build-ct/install not found" }
tree.com smoke /F
- name: Configure Smoke
run: cmake -S smoke -B smoke/out
- name: Build Smoke
run: cmake --build smoke/out --config ${{ matrix.config }}
- name: CTest Smoke
run: ctest --verbose --test-dir smoke/out --force-new-ctest-process --output-on-failure --no-tests=error -C ${{ matrix.config }}