Skip to content

Commit 23f1cfe

Browse files
committed
Merge branch 'master' into dtm
# Conflicts: # examples_tests
2 parents 1104bdf + 5a1575f commit 23f1cfe

File tree

219 files changed

+9512
-10458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+9512
-10458
lines changed

.github/workflows/build-nabla.yml

Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
name: Build Nabla Workflow
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: push-lock-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build-windows:
17+
runs-on: windows-2022
18+
19+
env:
20+
image: ghcr.io/devsh-graphics-programming/docker-nanoserver-msvc-winsdk
21+
entry: pwsh.exe
22+
cmd: -NoLogo -NoProfile -ExecutionPolicy Bypass
23+
mount: C:\mount\nabla
24+
binary: C:\mount\nabla\build-ct
25+
install: build-ct\install
26+
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
# vendor: [msvc, clangcl]
31+
# TODO: Yas please fix ClangCL, we have a few new compile errors
32+
# if we build MSVC then build "run-compiler-explorer" target, for ClangCL build just "nsc"
33+
vendor: [msvc]
34+
config: [Release, Debug, RelWithDebInfo]
35+
tag: ['17.13.6']
36+
37+
steps:
38+
- name: Environment Setup
39+
run: |
40+
Add-MpPreference -ExclusionPath "${{ github.workspace }}"
41+
Add-MpPreference -ExclusionExtension "*.*"
42+
Add-MpPreference -ExclusionProcess "docker.exe"
43+
Add-MpPreference -ExclusionProcess "dockerd.exe"
44+
Set-MpPreference -RemediationScheduleDay 8
45+
Set-MpPreference -DisableRealtimeMonitoring $true
46+
Set-MpPreference -DisableRemovableDriveScanning $true
47+
Set-MpPreference -DisableArchiveScanning $true
48+
Set-MpPreference -DisableScanningMappedNetworkDrivesForFullScan $true
49+
50+
if (-not (docker network ls --format '{{.Name}}' | Where-Object { $_ -eq 'docker_default' })) {
51+
docker network create --driver nat docker_default
52+
if ($LASTEXITCODE -ne 0) { exit 1 }
53+
}
54+
55+
- name: Set prefix
56+
id: set-prefix
57+
shell: pwsh
58+
run: |
59+
$prefix = "run-windows-${{ matrix.tag }}-${{ matrix.vendor }}-${{ matrix.config }}"
60+
$owner = "${{ github.repository_owner }}"
61+
$package = "nabla-shader-compiler-godbolt"
62+
$tag = "build-${{ matrix.vendor }}-${{ matrix.config }}-${{ matrix.tag }}"
63+
$nscTargetTaggedImage = "ghcr.io/${owner}/${package}:${tag}".ToLower()
64+
$nscTargetTaggedImageLatest = "ghcr.io/${owner}/${package}:latest".ToLower()
65+
66+
$shouldPushImage = (
67+
"${{ github.ref }}" -eq "refs/heads/master" -and
68+
"${{ matrix.vendor }}" -eq "msvc" -and
69+
"${{ matrix.config }}" -eq "Release"
70+
)
71+
72+
Write-Host "::notice::Should push image? $shouldPushImage"
73+
74+
"prefix=$prefix" >> $env:GITHUB_OUTPUT
75+
"nscTargetTaggedImage=$nscTargetTaggedImage" >> $env:GITHUB_OUTPUT
76+
"nscTargetTaggedImageLatest=$nscTargetTaggedImageLatest" >> $env:GITHUB_OUTPUT
77+
"shouldPushImage=$shouldPushImage" >> $env:GITHUB_OUTPUT
78+
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
with:
82+
submodules: 'recursive'
83+
84+
- name: Pull Image
85+
run: |
86+
docker pull "${{ env.image }}:${{ matrix.tag }}"
87+
88+
- name: Run Container
89+
run: |
90+
$ctx = docker context show
91+
$dockerHost = (docker context inspect $ctx | ConvertFrom-Json).Endpoints.docker.Host
92+
$pipeName = [regex]::Match($dockerHost, '/pipe/(?<n>.+)$').Groups['n'].Value
93+
$pipeHost = "\\.\pipe\$pipeName"
94+
95+
docker run `
96+
--entrypoint ${{ env.entry }} -di --isolation process `
97+
--env-file .\docker\ci-windows.env `
98+
--env-file .\docker\ninja.env `
99+
--env "NSC_IMAGE_NAME=${{ steps.set-prefix.outputs.nscTargetTaggedImage }}" `
100+
--name orphan --network docker_default `
101+
-v "${{ github.workspace }}:${{ env.mount }}" `
102+
-v "${pipeHost}:\\.\pipe\dockerd" -e "DOCKER_HOST=npipe:////./pipe/dockerd" `
103+
-w "${{ env.mount }}" `
104+
"${{ env.image }}:${{ matrix.tag }}" `
105+
${{ env.cmd }}
106+
107+
- name: Inspect Container
108+
run: |
109+
docker inspect orphan
110+
111+
- name: Container – Unpack Packages
112+
run: |
113+
docker exec orphan `
114+
${{ env.entry }} ${{ env.cmd }} C:\unpack.ps1
115+
116+
- name: Container – Configure Project with CMake
117+
run: |
118+
mkdir profiling
119+
docker exec orphan `
120+
${{ env.entry }} ${{ env.cmd }} -Command cmake `
121+
--preset ci-configure-dynamic-${{ matrix.vendor }} `
122+
--profiling-output=profiling/cmake-profiling.json `
123+
--profiling-format=google-trace
124+
125+
- name: Container – Build NSC
126+
run: |
127+
docker exec orphan `
128+
${{ env.entry }} ${{ env.cmd }} -Command cmake --build `
129+
--preset ci-build-dynamic-${{ matrix.vendor }} `
130+
-t run-compiler-explorer --config ${{ matrix.config }}
131+
132+
- name: Container – Build Examples
133+
id: build-examples
134+
continue-on-error: true
135+
run: |
136+
docker exec orphan `
137+
${{ env.entry }} ${{ env.cmd }} -Command cmake --build `
138+
--preset ci-build-dynamic-${{ matrix.vendor }} `
139+
-t examples_tests\all --config ${{ matrix.config }} `
140+
-- -k 0
141+
142+
- name: Container – Install Nabla
143+
run: |
144+
docker exec orphan `
145+
${{ env.entry }} ${{ env.cmd }} -Command cmake --install `
146+
${{ env.binary }} --config ${{ matrix.config }} `
147+
--prefix ${{ env.install }}
148+
149+
- name: Container – Install Examples
150+
id: install-examples
151+
continue-on-error: true
152+
run: |
153+
docker exec orphan `
154+
${{ env.entry }} ${{ env.cmd }} -Command cmake --install `
155+
${{ env.binary }}\examples_tests --config ${{ matrix.config }} `
156+
--prefix ${{ env.install }}
157+
158+
- name: Container – Save NSC Image
159+
run: |
160+
docker exec orphan `
161+
${{ env.entry }} ${{ env.cmd }} -Command docker `
162+
save ${{ steps.set-prefix.outputs.nscTargetTaggedImage }} | zstd -T0 -3 -f -o ${{ steps.set-prefix.outputs.prefix }}-nsc-godbolt-image.tar.zst
163+
164+
- name: Package left workflow artifacts
165+
run: |
166+
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-profiling.tar" profiling
167+
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-install.tar" ${{ env.install }}
168+
169+
- name: Upload NSC Godbolt Image artifact
170+
uses: actions/upload-artifact@v4
171+
with:
172+
name: ${{ steps.set-prefix.outputs.prefix }}-nsc-godbolt-image
173+
path: ${{ steps.set-prefix.outputs.prefix }}-nsc-godbolt-image.tar.zst
174+
compression-level: 0
175+
176+
- name: Upload profiling artifacts
177+
uses: actions/upload-artifact@v4
178+
with:
179+
name: ${{ steps.set-prefix.outputs.prefix }}-profiling
180+
path: ${{ steps.set-prefix.outputs.prefix }}-profiling.tar
181+
182+
- name: Upload install artifacts
183+
uses: actions/upload-artifact@v4
184+
with:
185+
name: ${{ steps.set-prefix.outputs.prefix }}-install
186+
path: ${{ steps.set-prefix.outputs.prefix }}-install.tar
187+
188+
- name: Login to GHCR
189+
if: steps.set-prefix.outputs.shouldPushImage == 'True'
190+
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u $env:GITHUB_ACTOR --password-stdin
191+
192+
- name: Tag Latest image
193+
if: steps.set-prefix.outputs.shouldPushImage == 'True'
194+
run: |
195+
docker tag ${{ steps.set-prefix.outputs.nscTargetTaggedImage }} ${{ steps.set-prefix.outputs.nscTargetTaggedImageLatest }}
196+
197+
- name: Push images to GHCR
198+
if: steps.set-prefix.outputs.shouldPushImage == 'True'
199+
run: |
200+
docker push ${{ steps.set-prefix.outputs.nscTargetTaggedImageLatest }}
201+
202+
update-badges:
203+
name: Update Build & Image Badges
204+
if: ${{ always() && github.ref == 'refs/heads/master' }}
205+
needs: build-windows
206+
runs-on: windows-2022
207+
permissions:
208+
contents: write
209+
210+
steps:
211+
- name: Checkout
212+
uses: actions/checkout@v4
213+
214+
- name: Create Build Badge
215+
run: |
216+
$jobStatus = "${{ needs.build-windows.result }}"
217+
$buildMsg = if ($jobStatus -eq "success") { "passing" } else { "failing" }
218+
$buildColor = if ($jobStatus -eq "success") { "brightgreen" } else { "red" }
219+
220+
$buildBadge = @{
221+
schemaVersion = 1
222+
label = "build"
223+
message = $buildMsg
224+
color = $buildColor
225+
} | ConvertTo-Json -Depth 2
226+
227+
$buildPath = ".badge-public/nabla"
228+
New-Item -ItemType Directory -Path $buildPath -Force | Out-Null
229+
$buildBadge | Set-Content -Path "$buildPath/build.json" -Encoding utf8
230+
231+
- name: Create Image Size Badge
232+
run: |
233+
$owner = "${{ github.repository_owner }}"
234+
$package = "nabla-shader-compiler-godbolt"
235+
$image = "ghcr.io/${owner}/${package}:latest".ToLower()
236+
$manifest = docker manifest inspect $image | ConvertFrom-Json
237+
238+
if ($manifest.manifests) {
239+
$totalSize = ($manifest.manifests | Measure-Object -Property size -Sum).Sum
240+
} elseif ($manifest.layers) {
241+
$totalSize = ($manifest.layers | Measure-Object -Property size -Sum).Sum
242+
} else {
243+
Write-Error "No valid size information found in manifest."
244+
exit 1
245+
}
246+
247+
$sizeMB = [Math]::Round($totalSize / 1MB, 2)
248+
$size = "$sizeMB MB"
249+
250+
$imageBadge = @{
251+
schemaVersion = 1
252+
label = $image
253+
message = $size
254+
color = "blue"
255+
} | ConvertTo-Json -Depth 2
256+
257+
$imagePath = ".badge-public/packages/nabla-shader-compiler-nsc"
258+
New-Item -ItemType Directory -Path $imagePath -Force | Out-Null
259+
$imageBadge | Set-Content -Path "$imagePath/image-badge.json" -Encoding utf8
260+
261+
- name: Deploy Badges
262+
uses: peaceiris/actions-gh-pages@v3
263+
with:
264+
github_token: ${{ secrets.GITHUB_TOKEN }}
265+
publish_branch: badges
266+
publish_dir: .badge-public
267+
keep_files: true
268+
commit_message: "[CI] badges update"
269+
270+
deploy-production:
271+
name: Deploy to production host
272+
if: ${{ always() && github.ref == 'refs/heads/master' }}
273+
needs: build-windows
274+
runs-on: ubuntu-latest
275+
276+
steps:
277+
- name: Pull latest images, re-run containers
278+
uses: appleboy/ssh-action@v1
279+
with:
280+
host: ${{ secrets.CE_HOST }}
281+
username: ${{ secrets.CE_USER }}
282+
key: ${{ secrets.CE_KEY }}
283+
script: |
284+
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -NoExit -File C:\Scripts\startup-docker.ps1

0 commit comments

Comments
 (0)