fix: remediate audited tech debt and close functional test gaps #99
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| secret-scan: | |
| name: Secret scanning | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: gitleaks/gitleaks-action@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| backend-test: | |
| name: Backend tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: package-lock.json | |
| - run: npm ci | |
| - run: npm --workspace backend run check | |
| - run: npm --workspace backend run test:run | |
| - run: npm --workspace backend run test:migration-sql | |
| frontend-test: | |
| name: Frontend tests + build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: package-lock.json | |
| - run: npm ci | |
| - run: npm --workspace web run lint | |
| - run: npm --workspace web run test:run | |
| - run: npm --workspace web run build | |
| env: | |
| NEXT_PUBLIC_API_URL: http://localhost:8787 | |
| NEXT_PUBLIC_CHAT_WORKER_URL: http://localhost:8788 | |
| NEXT_PUBLIC_DEFAULT_LOCALE: it | |
| e2e-test: | |
| name: E2E tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: package-lock.json | |
| - run: npm ci | |
| - run: npx playwright install --with-deps chromium | |
| - name: Migrate local D1 | |
| run: | | |
| rm -rf backend/.wrangler/e2e | |
| cat > backend/wrangler.toml <<'EOF' | |
| name = "menu-backend-e2e" | |
| main = "src/index.ts" | |
| compatibility_date = "2025-04-11" | |
| [vars] | |
| APP_ENV = "development" | |
| API_VERSION = "v1" | |
| SERVICE_NAME = "menu-backend" | |
| DEMO_MODE = "true" | |
| [[d1_databases]] | |
| binding = "DB" | |
| database_name = "menu-db" | |
| database_id = "00000000-0000-0000-0000-000000000000" | |
| migrations_dir = "drizzle" | |
| EOF | |
| cd backend | |
| npx wrangler d1 migrations apply menu-db --local --persist-to .wrangler/e2e | |
| - name: Start backend and seed demo data | |
| run: | | |
| cd backend | |
| npx wrangler dev --port 8787 --persist-to .wrangler/e2e > ../backend-e2e.log 2>&1 & | |
| echo $! > ../backend-e2e.pid | |
| for i in {1..60}; do | |
| curl -fsS http://localhost:8787/ready && break | |
| sleep 1 | |
| done | |
| curl -fsS -X POST http://localhost:8787/admin/demo/reset | |
| curl -fsS http://localhost:8787/catalog | node -e "let s='';process.stdin.on('data',c=>s+=c).on('end',()=>{const c=JSON.parse(s); const entries=c.categories.flatMap(x=>x.entries); if (!entries.length) throw new Error('seed produced no entries'); console.log(`seeded ${entries.length} entries`)})" | |
| - name: Run Playwright E2E (full non-live suite) | |
| # The chat specs mock /session and /chat at the browser level, so no chat | |
| # worker process is needed — NEXT_PUBLIC_CHAT_WORKER_URL only has to be set | |
| # for the chat FAB to mount. chat-live and auth-setup are excluded via the | |
| # playwright config testIgnore. | |
| run: npm --workspace web run test:e2e -- --project=chromium | |
| env: | |
| NEXT_PUBLIC_API_URL: http://localhost:8787 | |
| NEXT_PUBLIC_CHAT_WORKER_URL: http://localhost:8788 | |
| NEXT_PUBLIC_DEFAULT_LOCALE: it | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: web/playwright-report/ | |
| if-no-files-found: ignore | |
| - name: Show backend log on failure | |
| if: failure() | |
| run: cat backend-e2e.log || true | |
| demo-frontend-build: | |
| name: Demo frontend build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: package-lock.json | |
| - run: npm ci | |
| - run: npm --workspace web run build:cf | |
| env: | |
| NEXT_PUBLIC_API_URL: https://risto-menu-api.andreabaccega.com | |
| NEXT_PUBLIC_CHAT_WORKER_URL: https://risto-menu-demo-chat.vekexasia.workers.dev | |
| NEXT_PUBLIC_DEFAULT_LOCALE: en | |
| - name: Assert demo build has Tony and no private chat URL | |
| run: | | |
| grep -R "https://risto-menu-demo-chat.vekexasia.workers.dev" web/out/_next/static | |
| ! grep -R "http://localhost\|http://127\.0\.0\.1\|:8787\|:8788" web/out/_next/static | |
| grep -R "Tony" web/out/_next/static | |
| chat-test: | |
| name: Chat worker tests | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: web/workers/chat | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: web/workers/chat/package-lock.json | |
| - run: npm ci | |
| - run: npm run test:run |