# Everything that has to be true before a branch is merged. # # Three jobs, deliberately separate: when one goes red you know which kind of # thing broke without opening a log. The unit suites are fast and run on every # push; the end-to-end job builds a whole stack, so it runs on the branches # that matter — dev and main — and on any pull request into them. name: Tests on: push: branches: [dev, main, master] pull_request: branches: [dev, main, master] workflow_dispatch: jobs: backend: runs-on: forgejo-local steps: - uses: https://github.com/actions/checkout@v4 - name: Build the backend image run: docker compose build backend # SQLite in memory and a fake Redis: no network, no database to clean up, # and the whole suite in under two minutes. - name: Unit tests run: | docker compose run --rm --no-deps \ -e DATABASE_URL=sqlite:// -e PYTHONPATH=/app -w /app/tests \ backend python -m unittest discover -s . -p 'test_*.py' # The published surface, against the file in the repository. A route that # changes shape without the snapshot changing with it is a client # somewhere that stops working. - name: API contract run: | docker compose run --rm --no-deps \ -e DATABASE_URL=sqlite:// -e PYTHONPATH=/app -w /app/tests \ backend python -m unittest test_api_contract frontend: runs-on: forgejo-local steps: - uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/setup-node@v4 with: node-version: '20' cache: npm cache-dependency-path: frontend/package-lock.json - run: npm ci working-directory: frontend - run: npx vitest run working-directory: frontend # A build failure is a deploy failure found four hours early. - run: npm run build working-directory: frontend e2e: runs-on: forgejo-local steps: - uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/setup-node@v4 with: node-version: '20' cache: npm cache-dependency-path: e2e/package-lock.json - name: Bring up a throwaway stack run: | docker compose -f docker-compose.test.yml up -d --build docker compose -f docker-compose.test.yml run --rm seed - name: Install Playwright working-directory: e2e run: | npm ci npx playwright install --with-deps chromium webkit - name: End to end working-directory: e2e env: CI: '1' run: npx playwright test - name: Keep the evidence if: always() uses: https://github.com/actions/upload-artifact@v4 with: name: playwright-report path: | e2e/playwright-report e2e/results retention-days: 14 # `-v` matters: the volumes go too, so the next run starts from nothing # rather than from whatever the last one left behind. - name: Take the stack down if: always() run: docker compose -f docker-compose.test.yml down -v