Skip to content

Commit 88e41e3

Browse files
mikemolinetclaude
andcommitted
ci(test): spin up cueapi-core locally instead of hitting staging with ARGUS_STAGING_KEY
The `test` job's `pytest tests/` runs the SDK's CRUD tests against a real CueAPI server. Previously that server was remote staging, authenticated by `secrets.ARGUS_STAGING_KEY`. Argus was retired 2026-05-02 (cueapi PR #539) and that key/user is no longer valid — every PR's `test` job has been red for ~3 days with `AuthenticationError: Invalid API key`, blocking PRs #30 and #31 (and any future SDK PRs). This switches the job to the same self-contained pattern that's already proven by the passing `sdk-integration` job: clone cueapi-core, install, migrate, boot uvicorn locally, register a fresh test user via POST /v1/auth/register (gated by ALLOW_REGISTER=true), capture the key, plumb it through the existing `CUEAPI_STAGING_URL` / `CUEAPI_STAGING_API_KEY` env vars (no SDK code change needed — `tests/conftest.py` already reads them from env). Workflow-only diff. No SDK behavior change. Note: `notify-merge` still references `secrets.ARGUS_CUEAPI_KEY` for the post-merge prod telemetry cue. That key is also stale, but the step runs after auto-merge so it doesn't gate the PR — leaving for a follow-up that needs a new prod key minted by an operator. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a2b5325 commit 88e41e3

1 file changed

Lines changed: 55 additions & 3 deletions

File tree

.github/workflows/feature-to-main.yml

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,69 @@ jobs:
5353
pip install -r cueapi-core/requirements.txt
5454
pip install -e .
5555
56-
- name: Run tests
56+
- name: Apply migrations to test DB
57+
working-directory: cueapi-core
5758
env:
5859
DATABASE_URL: postgresql+asyncpg://runner@localhost:5432/cueapi_test
5960
REDIS_URL: redis://localhost:6379
6061
SESSION_SECRET: test-session-secret-32-chars-minimum!!
6162
ENV: test
6263
RESEND_API_KEY: ""
63-
CUEAPI_STAGING_URL: https://api-staging-e962.up.railway.app
64-
CUEAPI_STAGING_API_KEY: ${{ secrets.ARGUS_STAGING_KEY }}
64+
run: python -m alembic upgrade head
65+
66+
- name: Start cueapi-core API in background
67+
working-directory: cueapi-core
68+
env:
69+
DATABASE_URL: postgresql+asyncpg://runner@localhost:5432/cueapi_test
70+
REDIS_URL: redis://localhost:6379
71+
SESSION_SECRET: test-session-secret-32-chars-minimum!!
72+
ENV: test
73+
RESEND_API_KEY: ""
74+
ALLOW_REGISTER: "true"
75+
BASE_URL: http://localhost:8000
76+
run: |
77+
nohup python -m uvicorn app.main:app --host 127.0.0.1 --port 8000 \
78+
> /tmp/uvicorn.log 2>&1 &
79+
echo $! > /tmp/uvicorn.pid
80+
81+
- name: Wait for API health
82+
run: |
83+
for i in $(seq 1 30); do
84+
if curl -sf http://127.0.0.1:8000/health > /dev/null; then
85+
echo "API ready after ${i}s"
86+
exit 0
87+
fi
88+
sleep 1
89+
done
90+
echo "API failed to start within 30s"
91+
cat /tmp/uvicorn.log
92+
exit 1
93+
94+
- name: Register test user and capture API key
95+
id: register_user
96+
run: |
97+
EMAIL="ci-sdk-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}@example.com"
98+
RESP=$(curl -sf -X POST http://127.0.0.1:8000/v1/auth/register \
99+
-H "Content-Type: application/json" \
100+
-d "{\"email\":\"${EMAIL}\"}")
101+
KEY=$(printf '%s' "$RESP" | python -c 'import sys,json;print(json.load(sys.stdin)["api_key"])')
102+
if [ -z "$KEY" ]; then
103+
echo "Registration failed; response: $RESP"
104+
exit 1
105+
fi
106+
echo "::add-mask::$KEY"
107+
echo "api_key=$KEY" >> "$GITHUB_OUTPUT"
108+
109+
- name: Run tests
110+
env:
111+
CUEAPI_STAGING_URL: http://127.0.0.1:8000
112+
CUEAPI_STAGING_API_KEY: ${{ steps.register_user.outputs.api_key }}
65113
run: pytest tests/ -v --tb=short
66114

115+
- name: Dump uvicorn log on failure
116+
if: failure()
117+
run: cat /tmp/uvicorn.log || true
118+
67119
auto-merge:
68120
needs: test
69121
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)