mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
feat: local E2E stack (fake workers + test API) + email-code sign-in (v0.275.0) (#1165)
## Summary - **Local stack:** `scripts/local-stack.sh up --frontend` runs the **real** backend on the Firestore + GCS emulators with `FAKE_WORKERS=1`. In-process fake workers move jobs through their real states in seconds, using tiny real media, so web Playwright and mobile Maestro full-journey tests can run offline against the same endpoints. - **Email-code sign-in** (nomad-mobile spec §4.1): `POST /api/users/auth/send-code` + `verify-code`. The code logic is shared with kjbox via `LoginCodeStore`, and sends are throttled per email and per IP. - **Bug fix found by the new suite:** `confirm-duration` moved jobs to `separating_stage1`, from which they can never reach review. It now resumes at `downloading`. No prod job had taken this path yet. ## Changes - `backend/services/fake_workers/`: dispatch seam in `WorkerService.trigger_*`, plus fake search, download, checkout and outbox, scenarios, and per-user config. The real stem upload, transcode, backing-vocals analysis and preview render are reused. Every check is strict (`is True`), so a MagicMock settings object never enables the fakes, and startup **refuses FAKE_WORKERS in production**. - `/api/test/*` router (mounted only in that mode): `status`, `scenario`, `fake-config`, `emails`, `reset`, plus the fake Stripe checkout page. Paying it runs the real webhook handler. - `frontend/e2e/local-stack/` (9 specs, ~50s): - sign-up → make → review → instrumental → download - buy and cancel credits - duration confirm, failed, complete and review states - code sign-in and lockout - New required CI job `local-stack-e2e`. - Docs: TESTING.md § Local stack, DEVELOPMENT.md, API.md, README, LESSONS-LEARNED. - `MAX_SIGNUPS_PER_IP` can now be set by env. Only the local stack raises it; production keeps the default of 2. ## Testing - [x] Backend unit: 6175 passed - [x] Emulator: 152 passed - [x] Frontend Jest: 1706 passed - [x] Local-stack Playwright: 9/9 passed (CI mode) ## Review - [x] CodeRabbit CLI review completed locally. 1 minor finding declined: it suggested swallowing infrastructure errors in send-code as fake "sent" responses, which would hide real outages from users. @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01AGuxtgoscF6RJGtpjHPg3W --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eeb08578c9
commit
c277bc8ee3
84 files changed
+4698
-204
No files matched your search
+115
-1
@@ -772,6 +772,118 @@ jobs:
|
||||
path: backend/htmlcov/
|
||||
retention-days: 7
|
||||
|
||||
local-stack-e2e:
|
||||
name: "Local Stack - Full-Journey E2E"
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
# The real backend on the Firestore + GCS emulators with fake workers
|
||||
# (scripts/local-stack.sh), driven through the real web UI by
|
||||
# frontend/e2e/local-stack. Fully offline: no secrets, no real services.
|
||||
if: github.ref != 'refs/heads/main' && (needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend == 'true' || needs.changes.outputs.deps == 'true')
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- name: Free disk space (only if low)
|
||||
run: |
|
||||
df -h /
|
||||
AVAIL_GB=$(df -BG --output=avail / | tail -1 | tr -dc '0-9')
|
||||
if [ "$AVAIL_GB" -lt 30 ]; then
|
||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc \
|
||||
/usr/local/.ghcup /opt/hostedtoolcache/CodeQL
|
||||
df -h /
|
||||
fi
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Set up Python 3.13
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.13"
|
||||
|
||||
- name: Install Poetry
|
||||
uses: snok/install-poetry@v1
|
||||
with:
|
||||
virtualenvs-create: true
|
||||
virtualenvs-in-project: true
|
||||
|
||||
- name: Cache Poetry dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .venv
|
||||
key: venv-backend-hosted-${{ runner.os }}-py3.13-${{ hashFiles('poetry.lock') }}
|
||||
restore-keys: |
|
||||
venv-backend-hosted-${{ runner.os }}-py3.13-
|
||||
|
||||
- name: Set up Java 21 (required by Firestore emulator)
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "21"
|
||||
|
||||
- name: Install Firestore emulator + ffmpeg
|
||||
run: |
|
||||
if ! grep -rq "packages.cloud.google.com" /etc/apt/sources.list.d/ 2>/dev/null; then
|
||||
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | \
|
||||
sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
|
||||
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
|
||||
sudo gpg --dearmor --yes -o /usr/share/keyrings/cloud.google.gpg
|
||||
fi
|
||||
# Same "Hash Sum mismatch" retry as backend-emulator-tests.
|
||||
for attempt in 1 2 3 4 5; do
|
||||
sudo rm -rf /var/lib/apt/lists/*
|
||||
if sudo apt-get update -y && \
|
||||
sudo apt-get install -y google-cloud-cli-firestore-emulator ffmpeg; then
|
||||
break
|
||||
fi
|
||||
echo "apt install attempt ${attempt} failed; retrying in 15s..."
|
||||
sleep 15
|
||||
done
|
||||
dpkg -s google-cloud-cli-firestore-emulator >/dev/null 2>&1
|
||||
ffmpeg -version | head -1
|
||||
|
||||
- name: Install backend dependencies
|
||||
run: poetry install
|
||||
|
||||
- name: Pull GCS emulator image
|
||||
run: docker pull fsouza/fake-gcs-server:latest
|
||||
|
||||
- name: Setup Node.js with caching
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install frontend dependencies
|
||||
working-directory: frontend
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Install Playwright browsers
|
||||
working-directory: frontend
|
||||
run: npx playwright install --with-deps chromium
|
||||
|
||||
- name: Run local-stack E2E
|
||||
working-directory: frontend
|
||||
run: |
|
||||
chmod +x ../scripts/*.sh
|
||||
npx playwright test -c playwright.local-stack.config.ts --reporter=list
|
||||
|
||||
- name: Backend log (on failure)
|
||||
if: failure()
|
||||
run: tail -300 .local-stack/backend.log || true
|
||||
|
||||
- name: Upload Playwright report
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: playwright-local-stack-report
|
||||
path: |
|
||||
frontend/playwright-report-local-stack/
|
||||
frontend/test-results/
|
||||
retention-days: 7
|
||||
|
||||
backend-lint:
|
||||
name: "Backend - Code Quality"
|
||||
runs-on: ubuntu-latest
|
||||
@@ -805,7 +917,8 @@ jobs:
|
||||
# frontend-lint IS required - catches React hooks violations that cause runtime crashes
|
||||
# frontend-e2e-happy-path is required ONLY when 'e2e-happy-path' label is present
|
||||
# frontend-e2e-full is optional (requires 'e2e' label) so not enforced here
|
||||
needs: [frontend-lint, frontend-unit-tests, frontend-e2e-smoke, frontend-build, package-unit-tests, package-integration-tests, backend-unit-tests, backend-emulator-tests, backend-lint, frontend-e2e-happy-path, translation-check]
|
||||
# local-stack-e2e IS required when backend/frontend changed (offline, deterministic)
|
||||
needs: [frontend-lint, frontend-unit-tests, frontend-e2e-smoke, frontend-build, package-unit-tests, package-integration-tests, backend-unit-tests, backend-emulator-tests, local-stack-e2e, backend-lint, frontend-e2e-happy-path, translation-check]
|
||||
if: github.ref != 'refs/heads/main' && always()
|
||||
steps:
|
||||
- name: Check results
|
||||
@@ -820,6 +933,7 @@ jobs:
|
||||
"${{ needs.package-integration-tests.result }}"
|
||||
"${{ needs.backend-unit-tests.result }}"
|
||||
"${{ needs.backend-emulator-tests.result }}"
|
||||
"${{ needs.local-stack-e2e.result }}"
|
||||
"${{ needs.backend-lint.result }}"
|
||||
)
|
||||
for result in "${results[@]}"; do
|
||||
|
||||
Reference in new issue
Block a user