Skip to content

Commit 09ae3c8

Browse files
committed
fix(ci): install deps for examples deploy
1 parent 25a57b0 commit 09ae3c8

2 files changed

Lines changed: 63 additions & 27 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ jobs:
147147
printf '%s=%s\n' "$key" "$value" >> "$GITHUB_OUTPUT"
148148
echo "$key=$value"
149149
done
150+
- name: Validate CI workflow guards
151+
run: node --test scripts/ci-workflow.spec.mjs
150152

151153
library:
152154
name: Library — lint / test / build
@@ -445,16 +447,40 @@ jobs:
445447
446448
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
447449
deploy_relevant=false
448-
if printf '%s\n' "$changed_files" | grep -E '^(\.github/workflows/ci\.yml|vercel\.(json|cockpit\.json|examples\.json)|apps/(website|cockpit)/|cockpit/|examples/chat/|libs/|scripts/(assemble-examples|deploy-smoke|demo-middleware|langgraph-proxy|rate-limit)\.ts|scripts/assemble-demo\.ts)$' >/dev/null; then
450+
if printf '%s\n' "$changed_files" | grep -E '^(\.github/workflows/ci\.yml|vercel\.(json|cockpit\.json|examples\.json)|apps/(website|cockpit)/.*|cockpit/.*|examples/chat/.*|libs/.*|scripts/(assemble-examples|deploy-smoke|demo-middleware|langgraph-proxy|rate-limit)\.ts|scripts/assemble-demo\.ts)$' >/dev/null; then
449451
deploy_relevant=true
450452
fi
451453
452454
echo "relevant=$deploy_relevant" >> "$GITHUB_OUTPUT"
453455
if [ "$deploy_relevant" != "true" ]; then
454456
echo "::notice::No deploy-relevant files changed; skipping Vercel dependency setup."
455457
fi
458+
# ── Angular examples deploy ──────────────────────────────────────────
459+
- name: Check if examples changed
460+
id: examples_changed
461+
run: |
462+
base_sha="${{ github.event.before }}"
463+
head_sha="${{ github.sha }}"
464+
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
465+
base_sha="$(git rev-parse "$head_sha^")"
466+
fi
467+
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
468+
examples_changed=false
469+
if printf '%s\n' "$changed_files" | grep -E '^cockpit/.*/angular/' >/dev/null; then
470+
examples_changed=true
471+
fi
472+
if printf '%s\n' "$changed_files" | grep -E '^(vercel\.examples\.json|scripts/assemble-examples\.ts)$' >/dev/null; then
473+
examples_changed=true
474+
fi
475+
# Any libs/ change retriggers examples deploy. Previous hand-maintained
476+
# allow-list silently broke whenever a new lib was added; cost of a
477+
# spurious example rebuild is far cheaper than a missed deploy.
478+
if printf '%s\n' "$changed_files" | grep -E '^libs/' >/dev/null; then
479+
examples_changed=true
480+
fi
481+
echo "changed=$examples_changed" >> "$GITHUB_OUTPUT"
456482
- uses: actions/setup-node@v6.3.0
457-
if: steps.deploy_preflight.outputs.relevant == 'true'
483+
if: steps.deploy_preflight.outputs.relevant == 'true' || steps.examples_changed.outputs.changed == 'true'
458484
with:
459485
node-version: 22
460486
cache: npm
@@ -464,7 +490,7 @@ jobs:
464490
# VERCEL_WEBSITE_PROJECT_ID — website project id
465491
# VERCEL_COCKPIT_PROJECT_ID — cockpit project id
466492
# VERCEL_EXAMPLES_PROJECT_ID — examples project id
467-
- if: steps.deploy_preflight.outputs.relevant == 'true'
493+
- if: steps.deploy_preflight.outputs.relevant == 'true' || steps.examples_changed.outputs.changed == 'true'
468494
run: npm ci
469495
- name: Resolve deploy targets
470496
if: steps.deploy_preflight.outputs.relevant == 'true'
@@ -549,30 +575,6 @@ jobs:
549575
run: |
550576
npx tsx apps/cockpit/scripts/deploy-smoke.ts --url https://cockpit.cacheplane.ai --retries 20 --retry-delay-ms 5000
551577
552-
# ── Angular examples deploy ──────────────────────────────────────────
553-
- name: Check if examples changed
554-
id: examples_changed
555-
run: |
556-
base_sha="${{ github.event.before }}"
557-
head_sha="${{ github.sha }}"
558-
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
559-
base_sha="$(git rev-parse "$head_sha^")"
560-
fi
561-
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
562-
examples_changed=false
563-
if printf '%s\n' "$changed_files" | grep -E '^cockpit/.*/angular/' >/dev/null; then
564-
examples_changed=true
565-
fi
566-
if printf '%s\n' "$changed_files" | grep -E '^(vercel\.examples\.json|scripts/assemble-examples\.ts)$' >/dev/null; then
567-
examples_changed=true
568-
fi
569-
# Any libs/ change retriggers examples deploy. Previous hand-maintained
570-
# allow-list silently broke whenever a new lib was added; cost of a
571-
# spurious example rebuild is far cheaper than a missed deploy.
572-
if printf '%s\n' "$changed_files" | grep -E '^libs/' >/dev/null; then
573-
examples_changed=true
574-
fi
575-
echo "changed=$examples_changed" >> "$GITHUB_OUTPUT"
576578
- name: Build and assemble Angular examples
577579
if: steps.examples_changed.outputs.changed == 'true'
578580
run: npx tsx scripts/assemble-examples.ts

scripts/ci-workflow.spec.mjs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { readFile } from 'node:fs/promises';
2+
import { describe, it } from 'node:test';
3+
import assert from 'node:assert/strict';
4+
5+
describe('CI workflow', () => {
6+
async function readDeployJob() {
7+
const workflow = await readFile('.github/workflows/ci.yml', 'utf8');
8+
return workflow.slice(
9+
workflow.indexOf(' deploy:'),
10+
workflow.indexOf(' demo-deploy:')
11+
);
12+
}
13+
14+
it('treats nested library files as deploy-relevant changes', async () => {
15+
const deployJob = await readDeployJob();
16+
17+
const pattern = deployJob.match(/grep -E '([^']+)' >\/dev\/null/);
18+
19+
assert.match('libs/chat/src/lib/styles/chat-sidenav.styles.ts', new RegExp(pattern?.[1] ?? ''));
20+
});
21+
22+
it('installs dependencies before assembling changed Angular examples', async () => {
23+
const deployJob = await readDeployJob();
24+
25+
const dependencyInstall = deployJob.match(
26+
/-\s+if:\s*(.+)\n\s+run:\s+npm ci/
27+
);
28+
29+
assert.match(
30+
dependencyInstall?.[1] ?? '',
31+
/steps\.examples_changed\.outputs\.changed == 'true'/
32+
);
33+
});
34+
});

0 commit comments

Comments
 (0)