Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
e2e: key-gated jobs say when empty provider secrets made their tests skip
garrytanc9ed95c8eeb6
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex a78c308938..99a6d16656 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -459,6 +459,12 @@ jobs:GBRAIN_TEST_ALLOW_DATABASE_URL: '1'OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ - name: Provider-key coverage notice+ if: ${{ !cancelled() }}+ env:+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ run: bash scripts/e2e-provider-key-notice.sh# ──────────────────────────────────────────────────────────────────────# Full coverage pipeline (scheduled or explicitly dispatched). The honest@@ -620,6 +626,12 @@ jobs:E2E_FILE_TIMEOUT_SECS: '300'OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ - name: Provider-key coverage notice+ if: ${{ !cancelled() }}+ env:+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ run: bash scripts/e2e-provider-key-notice.sh- name: Upload coverageif: always()uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4diff --git a/.github/workflows/heavy-tests.yml b/.github/workflows/heavy-tests.ymlindex 6dc7e16a84..13dfbd34d2 100644--- a/.github/workflows/heavy-tests.yml+++ b/.github/workflows/heavy-tests.yml@@ -182,13 +182,13 @@ jobs:fiecho "keyed=false" >> "$GITHUB_OUTPUT"setcmds=$(printf 'gh secret set %s; ' "${missing[@]}")- echo "::warning::Real-agent door e2e executed 0 live claude/codex tests — empty secret(s): ${missing[*]}. Why: only the repo owner can set secrets. Fix (owner-only): ${setcmds% } then re-check with: gh workflow run heavy-tests.yml --ref master (or label a PR real-agent-e2e)." >&2+ echo "::warning::Real-agent door e2e executed 0 live claude/codex tests — empty secret(s): ${missing[*]}. Why: only the repo owner can set secrets. Fix (owner-only): ${setcmds%; } then re-check with: gh workflow run heavy-tests.yml --ref master (or label a PR real-agent-e2e)." >&2{echo "## Real-agent door e2e: 0 live tests executed"echo "Empty secret(s): ${missing[*]}. bootstrap-real-claude and bootstrap-real-codex run in no other job, so this run is not real-agent coverage."echo ""echo "- Why: only the repo owner can set secrets."- echo "- Fix (owner-only): \`${setcmds% }\`"+ echo "- Fix (owner-only): \`${setcmds%; }\`"echo "- Re-check: \`gh workflow run heavy-tests.yml --ref master\`, or add the \`real-agent-e2e\` label to a PR."} >> "$GITHUB_STEP_SUMMARY"diff --git a/scripts/e2e-provider-key-notice.sh b/scripts/e2e-provider-key-notice.shnew file mode 100755index 0000000000..7f81fd8fd8--- /dev/null+++ b/scripts/e2e-provider-key-notice.sh@@ -0,0 +1,28 @@+#!/usr/bin/env bash+# scripts/e2e-provider-key-notice.sh — make keyless E2E coverage visible (GBRA-47 A9).+#+# e2e.yml passes the OPENAI_API_KEY / ANTHROPIC_API_KEY repo secrets to its+# key-gated jobs; when a secret is empty, the key-gated tests self-skip and+# the job still goes green. This step says so in the log (::warning::) and the+# step summary, with the owner-only fix, so a green run is never read as+# keyed coverage. Exit 0 always: it reports, it does not gate.+set -euo pipefail++missing=()+[ -n "${OPENAI_API_KEY:-}" ] || missing+=(OPENAI_API_KEY)+[ -n "${ANTHROPIC_API_KEY:-}" ] || missing+=(ANTHROPIC_API_KEY)++summary="${GITHUB_STEP_SUMMARY:-/dev/null}"+if [ "${#missing[@]}" -eq 0 ]; then+ echo "Provider secrets set (OPENAI_API_KEY, ANTHROPIC_API_KEY): key-gated E2E tests ran keyed."+ exit 0+fi++fix=$(printf 'gh secret set %s; ' "${missing[@]}")+echo "::warning::Key-gated E2E tests skipped for missing keys: empty secret(s) ${missing[*]}. Why: only the repo owner can set secrets. Fix (owner-only): ${fix%; }"+{+ echo "## Key-gated E2E tests skipped for missing keys"+ echo "Empty secret(s): ${missing[*]}. Tests gated on these keys self-skipped, so this job's green is keyless coverage only."+ echo ""+ echo "- Fix (owner-only): \`${fix%; }\`"+} >> "$summary"diff --git a/test/scripts/e2e-provider-key-notice.test.ts b/test/scripts/e2e-provider-key-notice.test.tsnew file mode 100644index 0000000000..0a7323a539--- /dev/null+++ b/test/scripts/e2e-provider-key-notice.test.ts@@ -0,0 +1,38 @@+import { describe, expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';++const SCRIPT = resolve(import.meta.dir, '..', '..', 'scripts', 'e2e-provider-key-notice.sh');++function run(env: Record<string, string>) {+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-key-notice-'));+ const summary = join(dir, 'summary');+ try {+ const r = spawnSync('bash', [SCRIPT], { env: { PATH: process.env.PATH!, GITHUB_STEP_SUMMARY: summary, ...env }, encoding: 'utf8' });+ let written = '';+ try { written = readFileSync(summary, 'utf8'); } catch { /* no summary written */ }+ return { status: r.status, stdout: r.stdout, summary: written };+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+}++describe('scripts/e2e-provider-key-notice.sh', () => {+ test('an empty secret is a visible warning naming it and the owner-only fix, never a failure', () => {+ const r = run({ OPENAI_API_KEY: 'set', ANTHROPIC_API_KEY: '' });+ expect(r.status).toBe(0);+ expect(r.stdout).toContain('::warning::Key-gated E2E tests skipped for missing keys: empty secret(s) ANTHROPIC_API_KEY.');+ expect(r.stdout).toContain('Fix (owner-only): gh secret set ANTHROPIC_API_KEY');+ expect(r.stdout).not.toContain('OPENAI_API_KEY;');+ expect(r.summary).toContain('## Key-gated E2E tests skipped for missing keys');+ });++ test('both secrets set prints no warning and no summary', () => {+ const r = run({ OPENAI_API_KEY: 'set', ANTHROPIC_API_KEY: 'set' });+ expect(r.status).toBe(0);+ expect(r.stdout).not.toContain('::warning::');+ expect(r.summary).toBe('');+ });+});