-
Notifications
You must be signed in to change notification settings - Fork 4
306 lines (275 loc) · 12 KB
/
Copy pathbuild.yml
File metadata and controls
306 lines (275 loc) · 12 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
name: Build Desktop App
# Tests run on every push and PR (quick feedback), but the expensive
# 3-platform desktop build matrix only runs on manual trigger —
# `workflow_dispatch` from the Actions tab or `gh workflow run`.
# Pushes to main / staging no longer kick off a full cross-platform build.
on:
push:
branches: [main, staging]
pull_request:
branches: [main, staging]
workflow_dispatch:
env:
NODE_VERSION: "24"
PYTHON_VERSION: "3.12"
RUST_TOOLCHAIN: "stable"
jobs:
test:
name: Test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
shell: bash
venv-activate: source .venv/bin/activate
advisory: false
- os: macos-latest
shell: bash
venv-activate: source .venv/bin/activate
advisory: false
- os: windows-latest
shell: bash
venv-activate: source .venv/Scripts/activate
# Promoted from advisory to required in v0.8.0 Phase 4-5 once
# the cross-OS parity scripts (PowerShell update-* ports,
# cross-platform pre-build-check.mjs) shipped. Windows
# failures now block PRs the same way macOS / Ubuntu do.
advisory: false
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.advisory }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- uses: dtolnay/rust-toolchain@stable
- name: Linux system deps for Tauri
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev \
librsvg2-dev patchelf
- run: npm ci
- run: npx tsc --noEmit
- run: npm test -- --run --coverage
- name: cargo check
run: cargo check --manifest-path src-tauri/Cargo.toml --all-targets
- name: Python venv + install
shell: ${{ matrix.shell }}
run: |
python -m venv .venv
${{ matrix.venv-activate }}
pip install --upgrade pip
# [images] brings torch+diffusers+accelerate+pillow+safetensors, which
# tests/test_video_runtime.py needs because probe() does a real
# ``import torch`` after the mocked _find_missing returns. Without
# torch installed, probe bails out with "PyTorch could not be
# imported cleanly" and every ``realGenerationAvailable == True``
# assertion fails.
pip install -e ".[desktop,dev,images]"
- name: Python tests with coverage
shell: ${{ matrix.shell }}
run: |
${{ matrix.venv-activate }}
python -m pytest tests/ -v --tb=short \
--cov=backend_service --cov=cache_compression --cov=dflash \
--cov-report=term --cov-report=json:coverage.json
- name: Coverage gate vs baseline
# Linux is the canonical baseline runner; macOS/Windows numbers
# may differ slightly because some platform-gated branches only
# execute on one OS (e.g. mlx imports on macOS only).
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
source .venv/bin/activate
python - <<'PY'
import json, sys
d = json.load(open('coverage.json'))
pct = d['totals']['percent_covered']
floor = 60.0
print(f"line coverage: {pct:.2f}% (floor {floor:.1f}%)")
if pct + 0.01 < floor:
sys.exit(f"coverage regression: {pct:.2f}% < {floor:.1f}%")
PY
build:
# Only run the expensive desktop bundle matrix on manual dispatch.
# Pushes and PRs stop at the `test` job above.
if: github.event_name == 'workflow_dispatch'
needs: test
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
platform: darwin
arch: aarch64
bundle_targets: app,dmg
- os: ubuntu-22.04
platform: linux
arch: x86_64
bundle_targets: deb,appimage
- os: windows-latest
platform: windows
arch: x86_64
bundle_targets: msi,nsis
runs-on: ${{ matrix.os }}
name: Build (${{ matrix.os }})
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
# ── Linux system dependencies ──────────────────────────────
- name: Install Linux system dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
# ── Node.js ────────────────────────────────────────────────
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: package-lock.json
- name: Install npm dependencies
run: npm ci
# ── Rust ───────────────────────────────────────────────────
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
src-tauri/target
key: cargo-${{ matrix.os }}-${{ hashFiles('src-tauri/Cargo.lock') }}
restore-keys: cargo-${{ matrix.os }}-
# ── Python + venv ──────────────────────────────────────────
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
# See release.yml for the full explanation — cert must be in the
# keychain before beforeBundleCommand runs so stage-runtime.mjs can
# sign the embedded Python runtime for notarization.
- name: Import Apple certificate (macOS)
if: matrix.platform == 'darwin'
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
run: |
set -euo pipefail
KEYCHAIN_PATH="$RUNNER_TEMP/app-signing.keychain-db"
KEYCHAIN_PASSWORD="$(openssl rand -base64 20)"
echo "$CSC_LINK" | base64 --decode > "$RUNNER_TEMP/certificate.p12"
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security import "$RUNNER_TEMP/certificate.p12" \
-P "$CSC_KEY_PASSWORD" \
-A -t cert -f pkcs12 \
-k "$KEYCHAIN_PATH"
security set-key-partition-list \
-S apple-tool:,apple: \
-k "$KEYCHAIN_PASSWORD" \
"$KEYCHAIN_PATH"
security list-keychain -d user -s "$KEYCHAIN_PATH" $(security list-keychains -d user | xargs)
IDENTITY="$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" | grep 'Developer ID Application' | head -1 | awk -F'"' '{print $2}')"
if [ -z "$IDENTITY" ]; then
echo "::error::No Developer ID Application identity found in keychain"
security find-identity -v -p codesigning "$KEYCHAIN_PATH" || true
exit 1
fi
echo "Resolved signing identity: $IDENTITY"
echo "APPLE_SIGNING_IDENTITY=$IDENTITY" >> "$GITHUB_ENV"
echo "CHAOSENGINE_APPLE_SIGNING_IDENTITY=$IDENTITY" >> "$GITHUB_ENV"
rm -f "$RUNNER_TEMP/certificate.p12"
- name: Create Python venv (macOS)
if: matrix.platform == 'darwin'
run: |
python -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install mlx mlx-lm gguf fastapi psutil uvicorn "pypdf>=6.10.2" python-multipart huggingface_hub
- name: Create Python venv (Linux)
if: matrix.platform == 'linux'
run: |
python -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install fastapi psutil uvicorn "pypdf>=6.10.2" python-multipart huggingface_hub
- name: Create Python venv (Windows)
if: matrix.platform == 'windows'
run: |
python -m venv .venv
.venv\Scripts\pip install --upgrade pip
.venv\Scripts\pip install fastapi psutil uvicorn "pypdf>=6.10.2" python-multipart huggingface_hub
# ── Configure runtime staging ──────────────────────────────
- name: Set Python embed path (Unix)
if: matrix.platform != 'windows'
run: echo "CHAOSENGINE_EMBED_PYTHON_BIN=${{ github.workspace }}/.venv/bin/python3" >> $GITHUB_ENV
- name: Set Python embed path (Windows)
if: matrix.platform == 'windows'
run: echo "CHAOSENGINE_EMBED_PYTHON_BIN=${{ github.workspace }}\.venv\Scripts\python.exe" >> $env:GITHUB_ENV
# Use dev mode staging to skip llama.cpp binary requirement.
# To enable llama.cpp, build the binaries and set CHAOSENGINE_LLAMA_BIN_DIR.
- name: Override bundle command to dev mode staging
shell: bash
run: |
node -e "
const fs = require('fs');
const conf = JSON.parse(fs.readFileSync('src-tauri/tauri.conf.json', 'utf8'));
conf.build.beforeBundleCommand = 'npm run stage:runtime';
fs.writeFileSync('src-tauri/tauri.conf.json', JSON.stringify(conf, null, 2) + '\n');
"
# ── Build ──────────────────────────────────────────────────
- name: Build Tauri app (macOS, signed)
if: matrix.platform == 'darwin'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: npx tauri build --bundles ${{ matrix.bundle_targets }} --ci
- name: Build Tauri app (Linux / Windows)
if: matrix.platform != 'darwin'
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: npx tauri build --bundles ${{ matrix.bundle_targets }}
# ── Upload artifacts ───────────────────────────────────────
- name: Upload macOS artifacts
if: matrix.platform == 'darwin'
uses: actions/upload-artifact@v7
with:
name: ChaosEngineAI-macos
path: |
src-tauri/target/release/bundle/macos/*.app
src-tauri/target/release/bundle/dmg/*.dmg
- name: Upload Linux artifacts
if: matrix.platform == 'linux'
uses: actions/upload-artifact@v7
with:
name: ChaosEngineAI-linux
path: |
src-tauri/target/release/bundle/deb/*.deb
src-tauri/target/release/bundle/appimage/*.AppImage
- name: Upload Windows artifacts
if: matrix.platform == 'windows'
uses: actions/upload-artifact@v7
with:
name: ChaosEngineAI-windows
path: |
src-tauri/target/release/bundle/msi/*.msi
src-tauri/target/release/bundle/nsis/*.exe