name: CI on: push: branches: [master] pull_request: branches: [master] workflow_dispatch: jobs: ci: name: build + unit + e2e runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 # The runner provides a working docker CLI out of the box (full-dind) — no endpoint # resolution needed. Job and app containers share the daemon, so put them on one # user-defined network and reach the app by service DNS (the job's netns has no # default route here, so host-IP URLs are unreliable). The alias `app` is declared # in docker-compose.ci.yml. - name: Prepare e2e network run: | set -u docker network inspect flight-ci-e2e >/dev/null 2>&1 || docker network create flight-ci-e2e if ! docker network connect flight-ci-e2e "$(hostname)"; then echo "::error::failed to attach job container '$(hostname)' to flight-ci-e2e — the job must run in a container on the shared daemon (check runner config)" >&2 exit 1 fi docker network inspect flight-ci-e2e --format 'containers on flight-ci-e2e: {{range .Containers}}{{.Name}} {{end}}' echo "E2E_BASE_URL=http://app:3000" >> "$GITHUB_ENV" - name: Setup Node uses: actions/setup-node@v4 with: node-version: 22 # bun drives installs (repo ships bun.lock, no package-lock.json); pinned to 1.4.2. # Retried: the runner's outbound network/DNS is flaky (transient EAI_AGAIN seen in CI). - name: Install bun run: | set -u ok=0 for i in 1 2 3; do if npm i -g bun@1.4.2; then ok=1; break; fi echo "::warning::bun install attempt $i/3 failed (likely transient network) — retrying in 5s" >&2 sleep 5 done [ "$ok" = "1" ] || { echo "::error::bun install failed after 3 attempts" >&2; exit 1; } bun --version # Job-level dep cache via the runner's built-in cache server. continue-on-error on # both steps: an unreachable/broken cache server must never break the run. - name: Restore deps cache uses: actions/cache@v4 continue-on-error: true with: path: | node_modules $HOME/.bun/install/cache key: ${{ runner.os }}-deps-bun-${{ hashFiles('bun.lock') }} # Retried: the runner's outbound network/DNS is flaky (transient EAI_AGAIN seen in CI). - name: Install dependencies run: | set -u ok=0 for i in 1 2 3; do if bun install --frozen-lockfile; then ok=1; break; fi echo "::warning::dependency install attempt $i/3 failed (likely transient network) — retrying in 5s" >&2 sleep 5 done [ "$ok" = "1" ] || { echo "::error::dependency install failed after 3 attempts" >&2; exit 1; } - name: Save deps cache uses: actions/cache@v4 continue-on-error: true with: path: | node_modules $HOME/.bun/install/cache key: ${{ runner.os }}-deps-bun-${{ hashFiles('bun.lock') }} - name: Build run: npm run build - name: Unit tests run: npx vitest run # Browsers run locally in CI (PW_REMOTE_BROWSER=0 below): the shared remote browser # server at 192.168.1.4 cannot reach a stack inside dind, and local chromium keeps # the job self-contained. - name: Install browsers (local) run: npx playwright install --with-deps chromium # Cache the base image on the shared daemon up front: a single loud failure here # beats a 6-minute BuildKit "failed to solve" when the daemon's outbound net is down. - name: Pull e2e base image run: docker pull node:22-slim # Pre-build the e2e image with retries (flaky runner network); the E2E step's own # build then becomes a fast no-op. Plain progress keeps BuildKit output visible. - name: Build e2e image (retries) run: | set -u ok=0 for i in 1 2 3; do if docker compose -f docker-compose.ci.yml -p flight-ci build --progress=plain; then ok=1; break; fi echo "::warning::e2e image build attempt $i/3 failed (likely transient network) — retrying in 5s" >&2 sleep 5 done [ "$ok" = "1" ] || { echo "::error::e2e image build failed after 3 attempts" >&2; exit 1; } # E2E against an isolated stack on the shared daemon — never the production instance. # docker-compose.ci.yml joins the flight-ci-e2e network prepared above; project name # flight-ci keeps it distinct from production. E2E_DEPLOY_CMD makes the config's # webServer block deploy + wait for readiness (http://app:3000 via service DNS); # E2E_COMPOSE_ARGS points state.spec.ts' mid-run `docker compose restart flight` at # the same file + project. E2E_BASE_URL comes from GITHUB_ENV (Prepare e2e network). - name: E2E (isolated stack in dind) env: PW_REMOTE_BROWSER: "0" # Build separately with plain progress so BuildKit step output is visible in the # job log (auto progress hides it), then start without rebuilding. E2E_DEPLOY_CMD: "docker compose -f docker-compose.ci.yml -p flight-ci build --progress=plain && docker compose -f docker-compose.ci.yml -p flight-ci up -d" E2E_COMPOSE_ARGS: "-f docker-compose.ci.yml -p flight-ci" run: npx playwright test # The daemon is shared with production — never leave our stack or network behind. # -v drops the named DB volume so every run seeds fresh (no schema drift between PRs). - name: Cleanup e2e stack + network if: always() run: | docker compose -f docker-compose.ci.yml -p flight-ci down --remove-orphans -v || true docker network remove flight-ci-e2e 2>/dev/null || true