Files
blackroad-io-site/.github/workflows/e2e.yml

69 lines
2.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: E2E Stripe + Clerk
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
e2e:
runs-on: ubuntu-latest
permissions:
contents: read
env:
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY || 'sk_test_placeholder' }}
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY || 'sk_test_placeholder' }}
SECRET_KEY: ${{ secrets.SECRET_KEY || 'blackroad-ci-secret' }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install backend dependencies
working-directory: backend
run: pip install -r requirements.txt
- name: Start backend
working-directory: backend
run: |
uvicorn main:app --host 0.0.0.0 --port 8000 &
for i in $(seq 1 15); do
curl -sf http://localhost:8000/health && break
sleep 1
done
- name: Health check
run: curl -f http://localhost:8000/health
- name: E2E Auth (register + login)
run: |
EMAIL="ci-test-$(date +%s)@blackroad.io"
RESP=$(curl -sf -X POST http://localhost:8000/api/auth/register \
-H "Content-Type: application/json" \
-d "{\"email\":\"$EMAIL\",\"password\":\"Test1234!\",\"name\":\"CI Bot\"}")
echo "Register response: $RESP"
TOKEN=$(echo "$RESP" | python3 -c "import sys,json; d=json.load(sys.stdin); sys.exit(0) or print(d['access_token']) if 'access_token' in d else (sys.stderr.write('ERROR: access_token missing: '+str(d)+'\n'), sys.exit(1))")
echo "AUTH_TOKEN=$TOKEN" >> $GITHUB_ENV
- name: E2E Stripe checkout session
run: |
RESPONSE=$(curl -sf -X POST http://localhost:8000/api/payments/create-checkout-session \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-d '{"amount":4900,"tier":"starter"}')
echo "$RESPONSE" | python3 -c "import sys,json; d=json.load(sys.stdin); assert 'sessionId' in d, f'Missing sessionId: {d}'"
echo "Stripe checkout session created successfully"
- name: E2E Clerk webhook stub
run: |
# Verify the /health endpoint responds (Clerk webhooks would be
# routed here in production via CLERK_WEBHOOK_SECRET).
STATUS=$(curl -sf -o /dev/null -w "%{http_code}" http://localhost:8000/health)
[ "$STATUS" = "200" ] || (echo "Health check failed: $STATUS" && exit 1)
echo "Clerk webhook endpoint reachable (status $STATUS)"