-
Notifications
You must be signed in to change notification settings - Fork 44
267 lines (236 loc) · 10.6 KB
/
Copy pathci.yml
File metadata and controls
267 lines (236 loc) · 10.6 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
name: ci
on:
workflow_dispatch:
push:
branches: [main]
paths-ignore:
- "docs/**"
- "LICENSES/**"
- "LICENSE"
- "**.md"
- .github/workflows/wheels.yml
- .github/workflows/ci-gcp.yml
- .github/workflows/ci-latest-slang.yml
pull_request:
branches: [main]
paths-ignore:
- "LICENSES/**"
- "LICENSE"
- "**.md"
- .github/workflows/wheels.yml
- .github/workflows/ci-gcp.yml
- .github/workflows/ci-latest-slang.yml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
checks: write
id-token: write
jobs:
build:
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
os: [windows, linux, macos]
platform: [x86_64, aarch64]
compiler: [msvc, gcc, clang]
config: [Debug, Release]
python: ["3.10"]
exclude:
# Exclude aarch64 for windows
- { os: windows, platform: aarch64 }
# Exclude x86_64 for macos
- { os: macos, platform: x86_64 }
# Exclude unavailable compilers
- { os: windows, compiler: gcc }
- { os: windows, compiler: clang }
- { os: linux, compiler: msvc }
- { os: macos, compiler: msvc }
- { os: macos, compiler: gcc }
include:
# Builds running on self-hosted runners (build + tests + coverage)
- { os: windows, platform: x86_64, compiler: msvc, config: Debug, flags: "unit-test,header-validation,crashpad", runs-on: { labels: [Windows, X64, nvrgfx-bridge] } }
- { os: windows, platform: x86_64, compiler: msvc, config: Release, flags: "unit-test,test-examples,crashpad", runs-on: { labels: [Windows, X64, nvrgfx-bridge] } }
- { os: linux, platform: x86_64, compiler: gcc, config: Debug, flags: "unit-test,header-validation,coverage,crashpad", runs-on: { group: nvrgfx, labels: [Linux, X64] } }
- { os: linux, platform: x86_64, compiler: gcc, config: Release, flags: "unit-test,test-examples,crashpad", runs-on: { group: nvrgfx, labels: [Linux, X64] } }
# Builds running on GitHub hosted runners (build + tests)
- { os: macos, platform: aarch64, compiler: clang, config: Debug, flags: "unit-test,header-validation,crashpad", runs-on: macos-latest }
- { os: macos, platform: aarch64, compiler: clang, config: Release, flags: "unit-test,test-examples,crashpad", runs-on: macos-latest }
# Additional builds running on GitHub hosted runners (build only)
- { os: linux, platform: x86_64, compiler: clang, runs-on: ubuntu-latest }
- { os: linux, platform: aarch64, compiler: gcc, runs-on: ubuntu-24.04-arm }
- { os: linux, platform: aarch64, compiler: clang, runs-on: ubuntu-24.04-arm }
env:
# Environment variables used by ci.py
CI_OS: ${{ matrix.os }}
CI_PLATFORM: ${{ matrix.platform }}
CI_COMPILER: ${{ matrix.compiler }}
CI_CONFIG: ${{ matrix.config }}
CI_PYTHON: ${{ matrix.python }}
CI_FLAGS: ${{ matrix.flags }}
steps:
# Kill processes that may hold locks on build artifacts (Windows self-hosted runners).
# D3D12/GPU DLLs can be locked by system processes that cannot be killed, so we
# rename the build dir out of the way and schedule it for deletion on reboot.
- name: Pre-checkout cleanup
if: runner.os == 'Windows'
run: |
$buildDir = "${{ github.workspace }}\build"
if (Test-Path $buildDir) {
Write-Host "Cleaning build directory to avoid locked file issues ..."
# Kill any lingering user processes from previous runs that may lock DLLs.
# Use Modules to find processes with loaded DLLs from the build dir,
# then taskkill /F /T to force-kill the process tree.
Get-Process | Where-Object {
try { $_.Modules.FileName -like "${{ github.workspace }}\*" } catch { $false }
} | ForEach-Object {
Write-Host "Killing process $($_.ProcessName) (PID $($_.Id)) with taskkill /F /T"
& taskkill /F /T /PID $_.Id 2>&1 | Write-Host
}
Start-Sleep -Seconds 3
# Try direct removal first, and on failure, move the build directory out of the way
cmd /c "rd /s /q `"$buildDir`"" 2>$null
if (-not (Test-Path $buildDir)) {
Write-Host "Build directory removed successfully."
} else {
$tombstone = "${{ runner.temp }}\build_old_$([System.IO.Path]::GetRandomFileName())"
Write-Host "Direct removal failed, renaming to $tombstone (outside workspace) ..."
try {
[System.IO.Directory]::Move($buildDir, $tombstone)
Write-Host "Renamed successfully. Checkout can proceed."
} catch {
Write-Host "Rename also failed: $_. Locked files may cause checkout issues."
}
}
# Clean up any stale build_old_ directories from prior runs.
Get-ChildItem -Path "${{ runner.temp }}" -Directory -Filter "build_old_*" -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host "Cleaning stale tombstone: $($_.Name)"
cmd /c "rd /s /q `"$($_.FullName)`"" 2>$null
}
}
shell: pwsh
continue-on-error: true
- uses: actions/checkout@v6
with:
submodules: recursive
lfs: true
- name: Cleanup submodules # Fix for https://github.com/actions/checkout/issues/358
run: |
git submodule foreach --recursive git clean -ffdx
git submodule foreach --recursive git reset --hard
# Setup Linux.
- name: Setup Linux
if: startsWith(matrix.os, 'linux') && contains(matrix.runs-on, 'ubuntu-')
run: |
sudo apt update && sudo apt install -y libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config
# Setup Python (no pip cache on self-hosted runners).
- name: Setup Python ${{ matrix.python }} (No cache)
if: runner.environment == 'self-hosted'
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
# Setup Python (with pip cache on github-hosted runners).
- name: Setup Python ${{ matrix.python }} (Pip cache)
if: runner.environment == 'github-hosted'
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
cache: 'pip'
# Setup Python environment.
- name: Setup Python environment
run: |
python -m pip install -r requirements-dev.txt
python -m pip install -r samples/requirements.txt
python -m pip install pytest-github-actions-annotate-failures
# Setup PyTorch environment
- name: Setup PyTorch environment
if: runner.os != 'macos' && contains(matrix.flags, 'unit-test')
run: |
python -m pip install torch==2.8.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
# Setup MSVC.
- name: Setup MSVC
uses: step-security/msvc-dev-cmd@v1
# Setup CMake/Ninja.
- name: Setup CMake/Ninja
uses: lukka/get-cmake@latest
# Setup.
- name: Setup
run: python tools/ci.py setup
# Setup vcpkg caching.
# Only run on hosted runners.
# For self-hosted runners, we use a local cache directory.
- name: Set vcpkg cache directory
if: startsWith(matrix.runs-on, 'ubuntu-') || startsWith(matrix.runs-on, 'macos-') || startsWith(matrix.runs-on, 'windows-')
run: |
echo "VCPKG_DEFAULT_BINARY_CACHE=${{ github.workspace }}/vcpkg-cache" >> $GITHUB_ENV
mkdir -p ${{ github.workspace }}/vcpkg-cache
- name: Setup vcpkg caching
if: startsWith(matrix.runs-on, 'ubuntu-') || startsWith(matrix.runs-on, 'macos-') || startsWith(matrix.runs-on, 'windows-')
uses: actions/cache@v5
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: vcpkg-cache-${{ runner.os }}-${{ matrix.platform }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json', 'external/vcpkg-triplets/**') }}
# Configure.
- name: Configure
run: python tools/ci.py configure
# Build.
- name: Build
run: python tools/ci.py build
# Install slangpy-torch extension (requires MSVC on Windows, PyTorch installed)
- name: Install slangpy-torch
if: runner.os != 'macos' && contains(matrix.flags, 'unit-test')
run: python tools/ci.py install-slangpy-torch
# Typing Checks (Python)
- name: Typing Checks (Python)
run: python tools/ci.py typing-check-python
# Unit Tests (C++)
- name: Unit Tests (C++)
if: contains(matrix.flags, 'unit-test')
run: python tools/ci.py unit-test-cpp
# Unit Tests (Python)
- name: Unit Tests (Python)
if: contains(matrix.flags, 'unit-test')
run: python tools/ci.py unit-test-python --parallel
# Test Examples
- name: Test Examples
if: contains(matrix.flags, 'test-examples')
run: python tools/ci.py test-examples -p
# Upload Crashpad Reports
- name: Upload Crashpad Reports
if: always() && contains(matrix.flags, 'crashpad')
uses: actions/upload-artifact@v7
with:
name: crash-reports-${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.compiler }}-${{ matrix.config }}
path: .crashpad/reports/
if-no-files-found: ignore
# Generate Coverage Report
- name: Generate Coverage Report
if: contains(matrix.flags, 'coverage')
run: python tools/ci.py coverage-report
# Coverage Report
- name: Coverage Report
uses: actions/upload-artifact@v7
if: contains(matrix.flags, 'coverage')
with:
name: coverage-report
path: reports/coverage.html
# Cleanup slangpy-torch
- name: Uninstall slangpy-torch
if: always()
run: python -m pip uninstall slangpy-torch -y
continue-on-error: true
# Kill any processes that loaded DLLs from the workspace so the next job
# doesn't hit locked-file errors during checkout cleanup.
- name: Post-job process cleanup
if: always() && runner.os == 'Windows'
run: |
Get-Process | Where-Object {
try { $_.Modules.FileName -like "${{ github.workspace }}\*" } catch { $false }
} | ForEach-Object {
Write-Host "Killing leftover process $($_.ProcessName) (PID $($_.Id))"
& taskkill /F /T /PID $_.Id 2>&1 | Write-Host
}
shell: pwsh
continue-on-error: true