-
Notifications
You must be signed in to change notification settings - Fork 0
412 lines (366 loc) · 13.7 KB
/
release.yml
File metadata and controls
412 lines (366 loc) · 13.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
400
401
402
403
404
405
406
407
408
409
410
411
412
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
skip_publish:
description: 'Skip npm publish (for testing)'
type: boolean
default: true
jobs:
build-and-test:
name: Build & Test ${{ matrix.package }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS
- os: macos-14
arch: arm64
gpu: metal
package: darwin-arm64
- os: macos-15-intel
arch: x64
gpu: cpu
package: darwin-x64
# Linux x64
- os: ubuntu-22.04
arch: x64
gpu: cpu
package: linux-x64
- os: ubuntu-22.04
arch: x64
gpu: cuda
package: linux-x64-cuda
- os: ubuntu-22.04
arch: x64
gpu: vulkan
package: linux-x64-vulkan
# Linux ARM64 (native runners)
- os: ubuntu-22.04-arm
arch: arm64
gpu: cpu
package: linux-arm64
- os: ubuntu-22.04-arm
arch: arm64
gpu: cuda
package: linux-arm64-cuda
- os: ubuntu-22.04-arm
arch: arm64
gpu: vulkan
package: linux-arm64-vulkan
# Windows x64
- os: windows-2022
arch: x64
gpu: cpu
package: win32-x64
- os: windows-2022
arch: x64
gpu: cuda
package: win32-x64-cuda
- os: windows-2022
arch: x64
gpu: vulkan
package: win32-x64-vulkan
# Windows ARM64 (cross-compiled from x64)
- os: windows-2022
arch: arm64
gpu: cpu
package: win32-arm64
cross_compile: true
- os: windows-2022
arch: arm64
gpu: vulkan
package: win32-arm64-vulkan
cross_compile: true
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
- name: Validate llama.cpp version
run: node scripts/sync-llama-cpp.js --check
shell: bash
# Platform-specific build dependencies
- name: Install build tools (Linux x64)
if: runner.os == 'Linux' && matrix.arch == 'x64' && matrix.gpu == 'cpu'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake
- name: Install build tools (Linux ARM64)
if: runner.os == 'Linux' && matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake
# CUDA 12.2.2 for x64 - must match L4 GPU driver (535.x supports max 12.2)
# PTX compiled with newer CUDA won't run on older drivers
- name: Provision CUDA toolkit (Linux x64)
if: matrix.gpu == 'cuda' && runner.os == 'Linux' && matrix.arch == 'x64'
uses: ./.github/actions/provision-cuda
with:
version: '12.2.2'
arch: x64
# CUDA 12.6 for ARM64 - no L4 testing, use latest available
- name: Provision CUDA toolkit (Linux ARM64)
if: matrix.gpu == 'cuda' && runner.os == 'Linux' && matrix.arch == 'arm64'
uses: ./.github/actions/provision-cuda
with:
arch: arm64
# Vulkan 1.4.x required for ARM64 (jakoch/vulkan-sdk-arm only has 1.4.x)
- name: Install Vulkan SDK (Linux)
if: matrix.gpu == 'vulkan' && runner.os == 'Linux'
uses: jakoch/install-vulkan-sdk-action@v1.2.4
with:
vulkan_version: '1.4.341.1'
install_runtime: true
cache: false
# Use default CUDA 12.6 for building (forward compatible with older drivers)
- name: Provision CUDA toolkit (Windows)
if: matrix.gpu == 'cuda' && runner.os == 'Windows'
uses: ./.github/actions/provision-cuda
with:
arch: ${{ matrix.arch }}
- name: Install Vulkan SDK (Windows)
if: matrix.gpu == 'vulkan' && runner.os == 'Windows'
uses: jakoch/install-vulkan-sdk-action@v1.2.4
with:
vulkan_version: '1.4.341.1'
install_runtime: true
cache: false
- name: Setup LLVM and Ninja for Windows ARM64 cross-compilation
if: runner.os == 'Windows' && matrix.cross_compile == true
shell: pwsh
run: |
choco install llvm ninja -y
echo "CC=clang-cl" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "CXX=clang-cl" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "CMAKE_GENERATOR=Ninja" | Out-File -FilePath $env:GITHUB_ENV -Append
# Build
- name: Install npm dependencies
run: npm install --ignore-scripts
- name: Build native module (Native builds)
if: matrix.cross_compile != true
run: npm run build
env:
LLOYAL_GPU: ${{ matrix.gpu }}
- name: Build native module (Windows ARM64 cross-compile)
if: runner.os == 'Windows' && matrix.cross_compile == true
shell: pwsh
run: |
$env:CMAKE_GENERATOR = "Ninja"
$env:CMAKE_TOOLCHAIN_FILE = "${{ github.workspace }}/cmake/arm64-cross.cmake"
npm run build
env:
LLOYAL_GPU: ${{ matrix.gpu }}
ARCH: arm64
# Create platform package
- name: Create platform package
shell: bash
run: |
node scripts/create-platform-package.js "${{ matrix.package }}" "${{ matrix.os }}" "${{ matrix.arch }}"
# Test platform package (skip for cross-compiled packages - can't run ARM64 on x64)
- name: Cache test models
if: matrix.cross_compile != true
uses: actions/cache@v4
with:
path: models/
key: test-models-v1
- name: Download test models
if: matrix.cross_compile != true
run: bash scripts/download-test-models.sh
- name: Install platform package locally
if: matrix.cross_compile != true
shell: bash
run: |
npm install ./packages/${{ matrix.package }}
rm -rf build/Release
echo "Installed package contents:"
ls -la node_modules/@lloyal-labs/lloyal.node-${{ matrix.package }}/bin/ || echo "Package not found in node_modules"
- name: Verify platform package loading (Unix)
if: runner.os != 'Windows' && matrix.cross_compile != true && matrix.gpu != 'cuda'
shell: bash
run: |
# Set LD_LIBRARY_PATH to find sibling .so files (Linux CUDA/Vulkan)
PKG_BIN="$PWD/node_modules/@lloyal-labs/lloyal.node-${{ matrix.package }}/bin"
export LD_LIBRARY_PATH="${PKG_BIN}:${LD_LIBRARY_PATH:-}"
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
node -e "
const { loadBinary } = require('./dist');
const addon = loadBinary();
console.log('✓ Platform package loaded successfully');
console.log(' Exports:', Object.keys(addon));
"
env:
LLOYAL_GPU: ${{ matrix.gpu }}
LLOYAL_NO_FALLBACK: '1'
- name: Verify platform package loading (Windows)
if: runner.os == 'Windows' && matrix.cross_compile != true && matrix.gpu != 'cuda'
shell: pwsh
run: |
# Add package bin to PATH for DLL discovery
$pkgBin = "$PWD\node_modules\@lloyal-labs\lloyal.node-${{ matrix.package }}\bin"
$env:PATH = "$pkgBin;$env:PATH"
# Add Vulkan SDK runtime to PATH if available
if ($env:VULKAN_SDK) {
$env:PATH = "$env:VULKAN_SDK\Bin;$env:PATH"
# Vulkan runtime is in runtime\x64, not Bin
if (Test-Path "$env:VULKAN_SDK\runtime\x64\vulkan-1.dll") {
$env:PATH = "$env:VULKAN_SDK\runtime\x64;$env:PATH"
Write-Host "Added Vulkan runtime to PATH: $env:VULKAN_SDK\runtime\x64"
}
}
# Add CUDA runtime to PATH if available
if ($env:CUDA_PATH) {
$env:PATH = "$env:CUDA_PATH\bin;$env:PATH"
Write-Host "Added CUDA bin to PATH: $env:CUDA_PATH\bin"
}
Write-Host "Package bin: $pkgBin"
Write-Host "VULKAN_SDK: $env:VULKAN_SDK"
Write-Host "CUDA_PATH: $env:CUDA_PATH"
node -e "
const { loadBinary } = require('./dist');
const addon = loadBinary();
console.log('✓ Platform package loaded successfully');
console.log(' Exports:', Object.keys(addon));
"
env:
LLOYAL_GPU: ${{ matrix.gpu }}
LLOYAL_NO_FALLBACK: '1'
# Integration tests on GitHub runners (no GPU hardware)
# GPU tests (CUDA/Vulkan) run separately via gpu-test.yml on Cloud Run with NVIDIA L4
- name: Run integration tests (Windows)
if: runner.os == 'Windows' && matrix.gpu == 'cpu' && matrix.cross_compile != true
shell: pwsh
run: |
$pkgBin = "$PWD\node_modules\@lloyal-labs\lloyal.node-${{ matrix.package }}\bin"
$env:PATH = "$pkgBin;$env:PATH"
if ($env:VULKAN_SDK) {
$env:PATH = "$env:VULKAN_SDK\Bin;$env:PATH"
if (Test-Path "$env:VULKAN_SDK\runtime\x64\vulkan-1.dll") {
$env:PATH = "$env:VULKAN_SDK\runtime\x64;$env:PATH"
}
}
if ($env:CUDA_PATH) { $env:PATH = "$env:CUDA_PATH\bin;$env:PATH" }
npm run test:integration
timeout-minutes: 5
env:
LLOYAL_GPU: ${{ matrix.gpu }}
LLOYAL_NO_FALLBACK: '1'
# Skip Metal integration tests on CI - GitHub Actions paravirtual GPU (Apple5)
# has driver bugs with strided memory access (NeoX RoPE kernel).
# Metal packages are built and verified to load, but GPU tests are skipped.
- name: Run integration tests (Unix)
if: runner.os != 'Windows' && matrix.gpu == 'cpu'
run: |
PKG_BIN="$PWD/node_modules/@lloyal-labs/lloyal.node-${{ matrix.package }}/bin"
export LD_LIBRARY_PATH="${PKG_BIN}:${LD_LIBRARY_PATH:-}"
npm run test:integration
timeout-minutes: 5
env:
LLOYAL_GPU: ${{ matrix.gpu }}
LLOYAL_NO_FALLBACK: '1'
# Upload package artifact for publish job
- name: Upload platform package artifact
uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.package }}
path: packages/${{ matrix.package }}/
retention-days: 1
# GPU Integration Tests (reusable workflow)
gpu-tests:
name: GPU Tests
needs: build-and-test
uses: ./.github/workflows/gpu-test.yml
secrets: inherit
permissions:
contents: read
id-token: write
publish:
name: Publish all packages
needs: [build-and-test, gpu-tests]
runs-on: ubuntu-latest
# Only run if ALL jobs succeeded AND either it's a tag push or manual run without skip
if: success() && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.skip_publish))
permissions:
contents: read
id-token: write # Required for npm provenance
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
# Download all platform package artifacts
- name: Download all platform packages
uses: actions/download-artifact@v4
with:
path: packages/
pattern: package-*
merge-multiple: false
- name: List downloaded packages
run: |
echo "Downloaded platform packages:"
ls -la packages/
for dir in packages/package-*/; do
echo " - $(basename $dir): $(ls $dir)"
done
# Publish platform packages
- name: Publish platform packages
shell: bash
run: |
VERSION=$(node -p "require('./package.json').version")
echo "Publishing version: $VERSION"
# Determine npm tag based on version
if [[ "$VERSION" == *-alpha* ]]; then
NPM_TAG="alpha"
elif [[ "$VERSION" == *-beta* ]]; then
NPM_TAG="beta"
elif [[ "$VERSION" == *-rc* ]]; then
NPM_TAG="rc"
else
NPM_TAG="latest"
fi
echo "Using npm tag: $NPM_TAG"
# Publish each platform package
for pkg_dir in packages/package-*/; do
pkg_name=$(basename "$pkg_dir" | sed 's/^package-//')
echo ""
echo "Publishing @lloyal-labs/lloyal.node-${pkg_name}..."
cd "$pkg_dir"
npm publish --access public --tag "$NPM_TAG" --provenance
cd - > /dev/null
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Build TypeScript before publishing main package
- name: Install dependencies
run: npm install --ignore-scripts
- name: Build TypeScript
run: npm run build:ts
- name: Sync package versions
run: node scripts/sync-versions.js
- name: Publish main package
shell: bash
run: |
VERSION=$(node -p "require('./package.json').version")
if [[ "$VERSION" == *-alpha* ]]; then
npm publish --tag alpha --access public --provenance
elif [[ "$VERSION" == *-beta* ]]; then
npm publish --tag beta --access public --provenance
elif [[ "$VERSION" == *-rc* ]]; then
npm publish --tag rc --access public --provenance
else
npm publish --access public --provenance
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}