Skip to content

Commit c1786ab

Browse files
committed
ci(e2e): fail fast when anthropic key missing for AI E2E
1 parent a9b94a0 commit c1786ab

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

.github/workflows/api-e2e.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ jobs:
5454
run: pnpm turbo run test --filter=@repo/api
5555
- name: Install Playwright
5656
run: pnpm --filter @repo/api exec playwright install chromium --with-deps
57+
- name: Verify ANTHROPIC_API_KEY for E2E (AI_PROVIDER=anthropic)
58+
shell: bash
59+
env:
60+
AI_PROVIDER: ${{ env.AI_PROVIDER }}
61+
ANTHROPIC_API_KEY: ${{ env.ANTHROPIC_API_KEY }}
62+
run: |
63+
if [[ "${AI_PROVIDER}" == "anthropic" && -z "${ANTHROPIC_API_KEY}" ]]; then
64+
echo "::error::AI_PROVIDER is anthropic but ANTHROPIC_API_KEY is empty or unset. Set the ANTHROPIC_API_KEY repository secret; required before E2E tests (local)." >&2
65+
exit 1
66+
fi
5767
- name: E2E tests (local)
5868
run: pnpm --filter @repo/api test:e2e:local
5969
- name: Upload Playwright report

.github/workflows/web-e2e.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ jobs:
5858
run: pnpm turbo run test --filter=@repo/web
5959
- name: Install Playwright
6060
run: pnpm --filter @repo/web exec playwright install chromium --with-deps
61+
- name: Verify ANTHROPIC_API_KEY for E2E (AI_PROVIDER=anthropic)
62+
shell: bash
63+
env:
64+
AI_PROVIDER: ${{ env.AI_PROVIDER }}
65+
ANTHROPIC_API_KEY: ${{ env.ANTHROPIC_API_KEY }}
66+
run: |
67+
if [[ "${AI_PROVIDER}" == "anthropic" && -z "${ANTHROPIC_API_KEY}" ]]; then
68+
echo "::error::AI_PROVIDER is anthropic but ANTHROPIC_API_KEY is empty or unset. Set the ANTHROPIC_API_KEY repository secret; required before E2E tests (local)." >&2
69+
exit 1
70+
fi
6171
- name: E2E tests (local)
6272
env:
6373
SKIP_BUILD: '1'

apps/api/scripts/run-e2e-local.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ async function main() {
6868
)
6969
process.exit(1)
7070
}
71+
const anthropicApiKey = loaded.ANTHROPIC_API_KEY ?? process.env.ANTHROPIC_API_KEY
72+
if (!anthropicApiKey) {
73+
process.stderr.write(
74+
'E2E local: ANTHROPIC_API_KEY must be set in .env.test or process.env when AI_PROVIDER is anthropic. Refusing to run without it.\n',
75+
)
76+
process.exit(1)
77+
}
7178
const env = {
7279
...process.env,
7380
...loaded,
@@ -76,6 +83,7 @@ async function main() {
7683
NODE_ENV: 'test',
7784
JWT_SECRET: jwtSecret,
7885
AI_PROVIDER: 'anthropic',
86+
ANTHROPIC_API_KEY: anthropicApiKey,
7987
}
8088
delete env.OPEN_ROUTER_API_KEY
8189
delete env.OLLAMA_BASE_URL

apps/web/scripts/start-e2e-servers.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ const env = {
2121
NEXT_PUBLIC_API_URL: 'http://localhost:3001',
2222
AI_PROVIDER: 'anthropic',
2323
}
24+
if (env.AI_PROVIDER === 'anthropic' && !String(env.ANTHROPIC_API_KEY ?? '').trim()) {
25+
process.stderr.write(
26+
'start-e2e-servers: ANTHROPIC_API_KEY is required when AI_PROVIDER is anthropic. Set it in the environment (e.g. .env.local) before starting E2E servers.\n',
27+
)
28+
process.exit(1)
29+
}
2430
delete env.OPEN_ROUTER_API_KEY
2531
delete env.OLLAMA_BASE_URL
2632
delete env.AI_DEFAULT_MODEL

0 commit comments

Comments
 (0)