Skip to content

Commit 4c68055

Browse files
committed
fix(ci): gracefully skip E2E tests when BrowserStack credentials unavailable
- Add BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY to CI env vars - Add credential validation step that checks if BrowserStack creds exist - Create two conditional CI runs: qa:all (with E2E) or qa:all:no-e2e (without) - Add new qa:all:no-e2e task to Taskfile for credential-less CI runs - Update CI documentation to clarify BrowserStack setup is optional for early stage - E2E tests now gracefully skip instead of failing the entire CI build
1 parent af71d28 commit 4c68055

File tree

2 files changed

+68
-9
lines changed

2 files changed

+68
-9
lines changed

.cursor/commands/qa/Taskfile.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,27 @@ tasks:
132132
- echo "🎉 All validation checks passed!"
133133
silent: false
134134

135+
# QA suite without E2E (for CI when BrowserStack credentials unavailable)
136+
all:no-e2e:
137+
desc: "Validation QA suite without E2E tests (rules + smoke + lint + typecheck + unit)"
138+
cmds:
139+
- echo "🎯 Running validation QA suite (no E2E, no auto-fix)..."
140+
- echo ""
141+
- task: rules:check
142+
- echo ""
143+
- task: smoke
144+
- echo ""
145+
- task: lint
146+
- echo ""
147+
- task: typecheck
148+
- echo ""
149+
- task: unit
150+
- echo ""
151+
- echo "⏭️ Skipping E2E tests (BrowserStack credentials not available)"
152+
- echo ""
153+
- echo "🎉 All validation checks passed!"
154+
silent: false
155+
135156
# Complete QA workflow (fix THEN validate)
136157
# Use this manually before committing
137158
all:fix:

.github/workflows/ci.yml

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
runs-on: ubuntu-latest
2727
env:
2828
ENCORE_AUTH_KEY: ${{ secrets.ENCORE_AUTH_KEY }}
29+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
30+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
31+
BROWSERSTACK_HUB_URL: https://hub.browserstack.com/wd/hub
2932

3033
steps:
3134
- name: Checkout code
@@ -91,14 +94,37 @@ jobs:
9194
echo "Waiting for frontend to be ready..."
9295
timeout 60 bash -c 'until curl -sf http://localhost:5173 > /dev/null; do sleep 2; done'
9396
94-
- name: Run Complete QA Suite
97+
- name: Validate BrowserStack Credentials
98+
run: |
99+
if [ -z "${{ secrets.BROWSERSTACK_USERNAME }}" ] || [ -z "${{ secrets.BROWSERSTACK_ACCESS_KEY }}" ]; then
100+
echo "⚠️ WARNING: BrowserStack credentials not configured"
101+
echo " E2E tests will be skipped"
102+
echo " To enable E2E tests in CI:"
103+
echo " 1. Go to BrowserStack account settings to get credentials"
104+
echo " 2. Go to: GitHub repo → Settings → Secrets and variables → Actions"
105+
echo " 3. Create new secrets: BROWSERSTACK_USERNAME, BROWSERSTACK_ACCESS_KEY"
106+
export SKIP_E2E=1
107+
else
108+
echo "✅ BrowserStack credentials available - E2E tests enabled"
109+
export SKIP_E2E=0
110+
fi
111+
echo "SKIP_E2E=$SKIP_E2E" >> $GITHUB_ENV
112+
113+
- name: Run Complete QA Suite (with E2E)
114+
if: env.SKIP_E2E == '0'
95115
run: cd .cursor && task qa:all
116+
117+
- name: Run QA Suite without E2E
118+
if: env.SKIP_E2E == '1'
119+
run: cd .cursor && task qa:all:no-e2e
96120

97121
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
98122
# Implementation Notes:
99123
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
100124
#
101-
# SIMPLICITY: Single job runs `task qa:all` - same as pre-push hook
125+
# SIMPLICITY: Single job runs conditional QA suite based on credentials
126+
# - With BrowserStack: `task qa:all` (includes E2E tests)
127+
# - Without BrowserStack: `task qa:all:no-e2e` (skips E2E tests)
102128
# MIRRORS LOCAL: Exact same command developers run locally
103129
# DRY: No duplication - all logic in .cursor/commands/qa/Taskfile.yml
104130
#
@@ -108,7 +134,11 @@ jobs:
108134
# 3. qa:lint - Linting (backend + frontend)
109135
# 4. qa:typecheck - TypeScript validation (frontend)
110136
# 5. qa:unit - Unit tests (backend only - encore test)
111-
# 6. qa:e2e - E2E tests (frontend Playwright)
137+
# 6. qa:e2e - E2E tests (frontend Playwright) - REQUIRES BrowserStack
138+
#
139+
# What `task qa:all:no-e2e` runs (same as above, but WITHOUT E2E):
140+
# - Skips E2E tests when BrowserStack credentials unavailable
141+
# - Useful for early CI setup or pull requests from forks
112142
#
113143
# Note: Auto-fix (qa:fix) is intentionally excluded from qa:all
114144
# - Git hooks should validate, not modify uncommitted code
@@ -125,24 +155,32 @@ jobs:
125155
# - Uses standard ports from .env (4000 backend, 5173 frontend)
126156
# - In-memory database for tests
127157
# - ENCORE_AUTH_KEY: GitHub Secret (app-specific auth key) for Encore Cloud authentication
158+
# - BROWSERSTACK_USERNAME & BROWSERSTACK_ACCESS_KEY: Optional GitHub Secrets for E2E tests
128159
#
129160
# GitHub Secrets Setup:
161+
#
162+
# REQUIRED:
130163
# 1. Go to: https://app.encore.cloud/screengraph-ovzi → App Settings → Auth Keys
131164
# 2. Create new auth key (NOT `encore auth token` - that's different!)
132165
# 3. Go to: GitHub repo → Settings → Secrets and variables → Actions
133166
# 4. Create new secret: ENCORE_AUTH_KEY
134167
# 5. Paste the auth key from step 2
135168
#
169+
# OPTIONAL (for E2E tests):
170+
# 1. Get BrowserStack credentials (account settings or ask team)
171+
# 2. Go to: GitHub repo → Settings → Secrets and variables → Actions
172+
# 3. Create new secrets: BROWSERSTACK_USERNAME, BROWSERSTACK_ACCESS_KEY
173+
# 4. Without these, E2E tests will be skipped (not failed)
174+
#
136175
# Testing before activation:
137176
# 1. Create feature branch
138-
# 2. Rename to ci.yml
139-
# 3. Push to trigger workflow
140-
# 4. Verify qa:all passes
141-
# 5. Merge to main
142-
177+
# 2. Push to trigger workflow
178+
# 3. Verify appropriate QA suite passes (all or all:no-e2e)
179+
# 4. Merge to main after review
180+
#
143181
# Validation checklist when modifying:
144182
# 1. Create feature branch
145183
# 2. Push to trigger workflow
146-
# 3. Confirm qa:all passes in GitHub Actions
184+
# 3. Confirm appropriate QA suite passes in GitHub Actions
147185
# 4. Merge to main after review
148186

0 commit comments

Comments
 (0)