Skip to content

Commit b1d285e

Browse files
authored
chore: unify qa automation (#25)
* chore: unify qa automation * ci: activate qa workflow * ci: add encore auth token for cloud secrets * ci: install playwright browser binaries for e2e tests * ci: fix encore cloud authentication with proper login flow * ci: fix encore auth flag from --token to --auth-key * ci: fix encore auth - use ENCORE_AUTH_KEY instead of token - Changed from ENCORE_AUTH_TOKEN to ENCORE_AUTH_KEY (app-specific) - Updated docs to clarify auth key vs personal token difference - Auth key must be created in Encore dashboard, not via 'encore auth token' - Fixes 500 error caused by using wrong credential type * fix(frontend): add missing tailwind-variants dependency - badge.svelte imports tailwind-variants but it wasn't in package.json - Passed locally due to persistent node_modules - Failed in CI with fresh install - Fixes typecheck error in CI workflow * fix(qa): remove auto-fix from qa:all to prevent unstaged changes in hooks Problem: Running qa:fix inside qa:all during git hooks causes auto-fixes without staging changes, leading to commits without the fixes. Solution: - qa:all now validation-only (no code modification) - Created qa:all:fix for manual workflow (fix → validate) - Updated hooks and CI docs to clarify validation-only behavior Rationale: - Git hooks should validate, not modify uncommitted code - CI should validate, not modify code (anti-pattern) - Manual workflow: run qa:all:fix, review changes, stage, commit Files: - .cursor/commands/qa/Taskfile.yml - Split validation from fixing - .github/workflows/ci.yml - Updated docs - .husky/pre-commit - Clarified validation-only - .husky/pre-push - Clarified validation-only
1 parent 01277a4 commit b1d285e

File tree

8 files changed

+312
-245
lines changed

8 files changed

+312
-245
lines changed

.cursor/commands/qa/Taskfile.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,41 @@ tasks:
110110
- cd ../../../frontend && bun run test:e2e:ui
111111
silent: false
112112

113-
# Complete test suite
113+
# Validation-only QA suite (for git hooks and CI)
114+
# Does NOT modify code - only validates
114115
all:
115-
desc: "Complete test suite (smoke + lint + typecheck + unit + e2e)"
116+
desc: "Validation QA suite (rules + smoke + lint + typecheck + unit + e2e)"
116117
cmds:
118+
- echo "🎯 Running validation QA suite (no auto-fix)..."
119+
- echo ""
120+
- task: rules:check
121+
- echo ""
117122
- task: smoke
123+
- echo ""
118124
- task: lint
125+
- echo ""
119126
- task: typecheck
127+
- echo ""
120128
- task: unit
129+
- echo ""
121130
- task: e2e
122-
- echo "🎉 All tests passed!"
131+
- echo ""
132+
- echo "🎉 All validation checks passed!"
133+
silent: false
134+
135+
# Complete QA workflow (fix THEN validate)
136+
# Use this manually before committing
137+
all:fix:
138+
desc: "Complete workflow - auto-fix then validate (manual use only)"
139+
cmds:
140+
- echo "Step 1 - Auto-fixing issues..."
141+
- task: fix
142+
- echo ""
143+
- echo "Auto-fix complete. Review changes with git diff"
144+
- echo "Stage changes with git add . if satisfied"
145+
- echo ""
146+
- echo "Step 2 - Running validation suite..."
147+
- task: all
123148
silent: false
124149

125150
# Appium (mobile testing)

.github/workflows/ci.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# GitHub Actions CI Workflow
2+
#
3+
# Status: ACTIVE
4+
# Purpose: Run comprehensive QA suite on every push/PR
5+
#
6+
# This workflow uses the unified `task qa:all` command.
7+
# Mirrors Husky pre-push hook exactly (same commands, same checks).
8+
9+
name: CI
10+
11+
on:
12+
push:
13+
branches: [ main, develop ]
14+
pull_request:
15+
branches: [ main, develop ]
16+
17+
jobs:
18+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
19+
# Comprehensive QA Suite (mirrors pre-push hook)
20+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
21+
# Command: cd .cursor && task qa:all
22+
# Includes: fix, rules, smoke, lint, typecheck, unit, e2e
23+
24+
qa-all:
25+
name: QA Suite (fix + rules + smoke + lint + typecheck + unit + e2e)
26+
runs-on: ubuntu-latest
27+
env:
28+
ENCORE_AUTH_KEY: ${{ secrets.ENCORE_AUTH_KEY }}
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Install go-task
35+
run: |
36+
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
37+
task --version
38+
39+
- name: Setup bun
40+
uses: oven-sh/setup-bun@v1
41+
with:
42+
bun-version: latest
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: '20'
48+
49+
- name: Install Encore CLI
50+
run: |
51+
curl -L https://encore.dev/install.sh | bash
52+
echo "$HOME/.encore/bin" >> $GITHUB_PATH
53+
54+
- name: Authenticate with Encore Cloud
55+
run: |
56+
if [ -z "$ENCORE_AUTH_KEY" ]; then
57+
echo "⚠️ WARNING: ENCORE_AUTH_KEY not set in GitHub Secrets"
58+
echo " Encore builds requiring secrets will fail"
59+
echo " To fix:"
60+
echo " 1. Go to https://app.encore.cloud/screengraph-ovzi"
61+
echo " 2. Navigate to: App Settings → Auth Keys"
62+
echo " 3. Create new auth key"
63+
echo " 4. Add as GitHub Secret named 'ENCORE_AUTH_KEY'"
64+
exit 1
65+
else
66+
echo "🔐 Authenticating with Encore Cloud..."
67+
encore auth login --auth-key "$ENCORE_AUTH_KEY"
68+
echo "✅ Encore authentication successful"
69+
fi
70+
71+
- name: Install Backend Dependencies
72+
run: cd backend && bun install
73+
74+
- name: Install Frontend Dependencies
75+
run: cd frontend && bun install
76+
77+
- name: Install Playwright Browser Binaries
78+
run: cd frontend && bunx playwright install --with-deps chromium
79+
80+
- name: Start Backend
81+
run: |
82+
cd backend
83+
encore run &
84+
echo "Waiting for backend to be ready..."
85+
timeout 60 bash -c 'until curl -sf http://localhost:4000/health > /dev/null; do sleep 2; done'
86+
87+
- name: Start Frontend
88+
run: |
89+
cd frontend
90+
bun run dev &
91+
echo "Waiting for frontend to be ready..."
92+
timeout 60 bash -c 'until curl -sf http://localhost:5173 > /dev/null; do sleep 2; done'
93+
94+
- name: Run Complete QA Suite
95+
run: cd .cursor && task qa:all
96+
97+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
98+
# Implementation Notes:
99+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
100+
#
101+
# SIMPLICITY: Single job runs `task qa:all` - same as pre-push hook
102+
# MIRRORS LOCAL: Exact same command developers run locally
103+
# DRY: No duplication - all logic in .cursor/commands/qa/Taskfile.yml
104+
#
105+
# What `task qa:all` runs (VALIDATION ONLY - no code modification):
106+
# 1. qa:rules - Validate founder rules (no console.log, no any, American spelling)
107+
# 2. qa:smoke - Health checks (backend + frontend)
108+
# 3. qa:lint - Linting (backend + frontend)
109+
# 4. qa:typecheck - TypeScript validation (frontend)
110+
# 5. qa:unit - Unit tests (backend only - encore test)
111+
# 6. qa:e2e - E2E tests (frontend Playwright)
112+
#
113+
# Note: Auto-fix (qa:fix) is intentionally excluded from qa:all
114+
# - Git hooks should validate, not modify uncommitted code
115+
# - CI should validate, not modify code (anti-pattern)
116+
# - Manual workflow: `task qa:all:fix` (fix → validate) before committing
117+
#
118+
# Dependencies:
119+
# - go-task - Taskfile runner
120+
# - bun - Package manager
121+
# - Node.js - Automation scripts
122+
# - Encore CLI - Backend runtime
123+
#
124+
# Environment:
125+
# - Uses standard ports from .env (4000 backend, 5173 frontend)
126+
# - In-memory database for tests
127+
# - ENCORE_AUTH_KEY: GitHub Secret (app-specific auth key) for Encore Cloud authentication
128+
#
129+
# GitHub Secrets Setup:
130+
# 1. Go to: https://app.encore.cloud/screengraph-ovzi → App Settings → Auth Keys
131+
# 2. Create new auth key (NOT `encore auth token` - that's different!)
132+
# 3. Go to: GitHub repo → Settings → Secrets and variables → Actions
133+
# 4. Create new secret: ENCORE_AUTH_KEY
134+
# 5. Paste the auth key from step 2
135+
#
136+
# Testing before activation:
137+
# 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+
143+
# Validation checklist when modifying:
144+
# 1. Create feature branch
145+
# 2. Push to trigger workflow
146+
# 3. Confirm qa:all passes in GitHub Actions
147+
# 4. Merge to main after review
148+

.github/workflows/ci.yml.scaffold

Lines changed: 0 additions & 176 deletions
This file was deleted.

0 commit comments

Comments
 (0)