-
Notifications
You must be signed in to change notification settings - Fork 1
426 lines (417 loc) · 15.3 KB
/
Copy pathci-deep.yml
File metadata and controls
426 lines (417 loc) · 15.3 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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
name: CI Deep
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * *"
concurrency:
group: ci-deep-${{ github.ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
checks: write
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings
CARGO_INCREMENTAL: "0"
CARGO_PROFILE_DEV_DEBUG: "0"
jobs:
audit:
name: Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rustsec/audit-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
api-e2e-server:
name: API E2E Server (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.93.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: api-e2e-server-${{ matrix.os }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Start opensession-server
run: |
mkdir -p .ci-logs .ci-data/server
PORT=3000 \
BASE_URL=http://127.0.0.1:3000 \
JWT_SECRET=ci-jwt-secret \
OPENSESSION_ADMIN_KEY=ci-admin-key \
OPENSESSION_DATA_DIR="$PWD/.ci-data/server" \
cargo run -p opensession-server > .ci-logs/server.log 2>&1 &
echo $! > .ci-logs/server.pid
- name: Wait for server health endpoint
run: |
for i in $(seq 1 120); do
if curl -fsS http://127.0.0.1:3000/api/health >/dev/null; then
exit 0
fi
sleep 1
done
echo "server did not start in time"
cat .ci-logs/server.log || true
exit 1
- name: Run server API E2E suite
env:
OPENSESSION_E2E_SERVER_BASE_URL: http://127.0.0.1:3000
OPENSESSION_E2E_ALLOW_REMOTE: "0"
run: cargo test -p opensession-e2e --test server -- --nocapture
- name: Stop opensession-server
if: always()
run: |
if [ -f .ci-logs/server.pid ]; then
kill "$(cat .ci-logs/server.pid)" || true
fi
- name: Upload server E2E logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: api-e2e-server-logs-${{ matrix.os }}
path: .ci-logs/server.log
if-no-files-found: ignore
worker-web-live-e2e:
name: Worker + Web Live E2E (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.93.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: worker-web-live-e2e-${{ matrix.os }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: |
web/package-lock.json
packages/ui/package-lock.json
- name: Cache Playwright browser
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('web/package-lock.json') }}
- name: Install UI deps
run: npm ci --prefer-offline --no-audit --no-fund --silent
working-directory: packages/ui
- name: Install web deps
run: npm ci --prefer-offline --no-audit --no-fund --silent
working-directory: web
- name: Install Playwright browser (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: npx playwright install --with-deps chromium
working-directory: web
- name: Install Playwright browser (macOS)
if: matrix.os == 'macos-latest'
run: npx playwright install chromium
working-directory: web
- name: Start wrangler dev (local)
run: |
mkdir -p .ci-logs
npx --yes wrangler@4 dev \
--ip 127.0.0.1 \
--port 8788 \
--persist-to .wrangler/state \
--show-interactive-dev-session=false \
--log-level=warn \
--var BASE_URL:http://127.0.0.1:8788 \
--var OPENSESSION_BASE_URL:http://127.0.0.1:8788 \
--var JWT_SECRET:ci-jwt-secret \
--var OPENSESSION_ADMIN_KEY:ci-admin-key \
--var GITHUB_CLIENT_ID:ci-github-client \
--var GITHUB_CLIENT_SECRET:ci-github-secret \
> .ci-logs/wrangler.log 2>&1 &
echo $! > .ci-logs/wrangler.pid
- name: Wait for worker health endpoint
run: |
for i in $(seq 1 360); do
api_code="$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8788/api/health || true)"
root_code="$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8788/ || true)"
if [ "$api_code" = "200" ] && [ "$root_code" = "200" ]; then
exit 0
fi
sleep 1
done
echo "wrangler dev did not start in time (api=$api_code root=$root_code)"
cat .ci-logs/wrangler.log || true
exit 1
- name: Start opensession-server for web live API
run: |
mkdir -p .ci-logs .ci-data/server
PORT=3000 \
BASE_URL=http://127.0.0.1:3000 \
JWT_SECRET=ci-jwt-secret \
OPENSESSION_ADMIN_KEY=ci-admin-key \
OPENSESSION_DATA_DIR="$PWD/.ci-data/server" \
OPENSESSION_LOCAL_REVIEW_ROOT="$PWD/web/e2e-live/fixtures/local-review" \
OPENSESSION_ALLOWED_ORIGINS=http://127.0.0.1:8788 \
cargo run -p opensession-server > .ci-logs/server.log 2>&1 &
echo $! > .ci-logs/server.pid
- name: Wait for server health endpoint
run: |
for i in $(seq 1 120); do
if curl -fsS http://127.0.0.1:3000/api/health >/dev/null; then
exit 0
fi
sleep 1
done
echo "opensession-server did not start in time"
cat .ci-logs/server.log || true
exit 1
- name: Run worker API E2E suite
env:
OPENSESSION_E2E_WORKER_BASE_URL: http://127.0.0.1:8788
OPENSESSION_E2E_ALLOW_REMOTE: "0"
run: cargo test -p opensession-e2e --test worker -- --nocapture
- name: Run web live Playwright suite
env:
OPENSESSION_E2E_WORKER_BASE_URL: http://127.0.0.1:8788
OPENSESSION_E2E_SERVER_BASE_URL: http://127.0.0.1:3000
OPENSESSION_E2E_ALLOW_REMOTE: "0"
CI: "1"
run: npm run test:e2e:live -- --reporter=list,junit --output=e2e-live-results
working-directory: web
- name: Stop opensession-server
if: always()
run: |
if [ -f .ci-logs/server.pid ]; then
kill "$(cat .ci-logs/server.pid)" || true
fi
- name: Stop wrangler dev
if: always()
run: |
if [ -f .ci-logs/wrangler.pid ]; then
kill "$(cat .ci-logs/wrangler.pid)" || true
fi
- name: Upload worker/web live E2E artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: worker-web-live-e2e-${{ matrix.os }}
path: |
.ci-logs/wrangler.log
.ci-logs/server.log
web/e2e-live-results
web/test-results
web/playwright-report
if-no-files-found: ignore
desktop-e2e:
name: Desktop E2E (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.93.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: desktop-e2e-${{ matrix.os }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install Linux desktop test dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
xvfb \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libwebkit2gtk-4.1-dev
- name: Run desktop test suite (Linux)
if: matrix.os == 'ubuntu-latest'
env:
OPENSESSION_E2E_DESKTOP: "1"
run: xvfb-run -a cargo test --manifest-path desktop/src-tauri/Cargo.toml --quiet
- name: Run desktop test suite (macOS)
if: matrix.os == 'macos-latest'
env:
OPENSESSION_E2E_DESKTOP: "1"
run: cargo test --manifest-path desktop/src-tauri/Cargo.toml --quiet
desktop-bundle-verify:
name: Desktop Bundle Verify (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.93.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: desktop-bundle-verify-${{ matrix.os }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: |
desktop/package-lock.json
web/package-lock.json
packages/ui/package-lock.json
- name: Install universal Rust targets (macOS)
if: matrix.os == 'macos-latest'
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
- name: Install Linux desktop build dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
xvfb \
patchelf \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libwebkit2gtk-4.1-dev
- name: Run desktop build preflight (Linux)
if: matrix.os == 'ubuntu-latest'
run: node scripts/validate/desktop-build-preflight.mjs --mode ci --os linux
- name: Run desktop build preflight (macOS)
if: matrix.os == 'macos-latest'
run: node scripts/validate/desktop-build-preflight.mjs --mode ci --os macos
- name: Install UI deps
run: npm ci --prefer-offline --no-audit --no-fund --silent
working-directory: packages/ui
- name: Install web deps
run: npm ci --prefer-offline --no-audit --no-fund --silent
working-directory: web
- name: Install desktop deps
run: npm ci --prefer-offline --no-audit --no-fund --silent
working-directory: desktop
- name: Link @opensession/ui
run: |
mkdir -p node_modules/@opensession
rm -f node_modules/@opensession/ui
ln -sf "${{ github.workspace }}/packages/ui" node_modules/@opensession/ui
working-directory: web
- name: Build desktop bundle (Linux)
if: matrix.os == 'ubuntu-latest'
id: build_linux
run: |
set -euo pipefail
mkdir -p .ci-logs
start="$(date +%s)"
npm --prefix desktop run tauri:build -- --no-sign --ci 2>&1 | tee .ci-logs/desktop-build.log
end="$(date +%s)"
echo "build_seconds=$((end - start))" >> "$GITHUB_OUTPUT"
- name: Build desktop bundle (macOS universal)
if: matrix.os == 'macos-latest'
id: build_macos
run: |
set -euo pipefail
mkdir -p .ci-logs
start="$(date +%s)"
npm --prefix desktop run tauri:build -- --target universal-apple-darwin --bundles app --no-sign --ci 2>&1 | tee .ci-logs/desktop-build.log
end="$(date +%s)"
echo "build_seconds=$((end - start))" >> "$GITHUB_OUTPUT"
- name: Verify desktop bundle (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
set -euo pipefail
mkdir -p .ci-logs
BUNDLE_DIR="desktop/src-tauri/target/release/bundle"
APP_BIN="desktop/src-tauri/target/release/opensession-desktop"
if [ ! -d "$BUNDLE_DIR" ]; then
echo "missing bundle dir: $BUNDLE_DIR"
exit 1
fi
if ! find "$BUNDLE_DIR" -type f | grep -q .; then
echo "bundle dir has no files: $BUNDLE_DIR"
exit 1
fi
if [ ! -f "$APP_BIN" ]; then
echo "missing desktop binary: $APP_BIN"
exit 1
fi
xvfb-run -a sh -c '
"$1" > "$2" 2>&1 &
pid=$!
sleep 5
if ! kill -0 "$pid" 2>/dev/null; then
echo "desktop process exited before smoke timeout"
cat "$2" || true
exit 1
fi
kill "$pid" 2>/dev/null || true
wait "$pid" 2>/dev/null || true
' sh "$APP_BIN" ".ci-logs/desktop-smoke.log"
- name: Verify desktop bundle (macOS universal)
if: matrix.os == 'macos-latest'
run: |
set -euo pipefail
mkdir -p .ci-logs
BUNDLE_DIR="desktop/src-tauri/target/universal-apple-darwin/release/bundle"
APP_PATH="$(find "${BUNDLE_DIR}/macos" -maxdepth 1 -type d -name '*.app' | head -n 1 || true)"
if [ -z "$APP_PATH" ]; then
echo "missing .app bundle in ${BUNDLE_DIR}/macos"
exit 1
fi
APP_BIN="${APP_PATH}/Contents/MacOS/opensession-desktop"
if [ ! -f "$APP_BIN" ]; then
echo "missing app executable: $APP_BIN"
exit 1
fi
archs="$(lipo -archs "$APP_BIN" | xargs)"
if [ "$archs" != "x86_64 arm64" ] && [ "$archs" != "arm64 x86_64" ]; then
echo "unexpected universal archs: $archs"
exit 1
fi
"$APP_BIN" > .ci-logs/desktop-smoke.log 2>&1 &
app_pid=$!
sleep 5
if ! kill -0 "$app_pid" 2>/dev/null; then
echo "desktop process exited before smoke timeout"
cat .ci-logs/desktop-smoke.log || true
exit 1
fi
kill "$app_pid" 2>/dev/null || true
wait "$app_pid" 2>/dev/null || true
- name: Collect desktop diagnostics
if: always()
env:
BUILD_SECONDS: ${{ steps.build_linux.outputs.build_seconds || steps.build_macos.outputs.build_seconds || '0' }}
run: |
set -euo pipefail
if [ "${{ matrix.os }}" = "macos-latest" ]; then
BUNDLE_DIR="desktop/src-tauri/target/universal-apple-darwin/release/bundle"
APP_BIN="desktop/src-tauri/target/universal-apple-darwin/release/bundle/macos/OpenSession Desktop.app/Contents/MacOS/opensession-desktop"
OS_LABEL="macos"
else
BUNDLE_DIR="desktop/src-tauri/target/release/bundle"
APP_BIN="desktop/src-tauri/target/release/opensession-desktop"
OS_LABEL="linux"
fi
scripts/ci/collect-desktop-diagnostics.sh \
--out-dir ".ci-diagnostics/desktop-bundle-${{ matrix.os }}" \
--os "$OS_LABEL" \
--bundle-dir "$BUNDLE_DIR" \
--app-bin "$APP_BIN" \
--build-seconds "${BUILD_SECONDS}" \
--smoke-log ".ci-logs/desktop-smoke.log"
- name: Upload desktop bundle diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: desktop-bundle-verify-${{ matrix.os }}
path: |
.ci-logs
.ci-diagnostics/desktop-bundle-${{ matrix.os }}
if-no-files-found: ignore