name: CI # Real CI for the repo: lint + tests + frontend build + both prod Docker images + a dependency # audit. Complements `tracely-gate.yml` (the regression-gate dogfood) — this gates *the code*. on: pull_request: push: branches: [master] workflow_dispatch: permissions: contents: read concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: backend: name: backend · ruff + pytest runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: astral-sh/setup-uv@v5 with: enable-cache: true # --frozen installs exactly what uv.lock pins (incl. the tracelyai-sdk[all] provider extras), # so CI also catches lock/extra drift — the "transitive-conflict minefield" risk. # --all-packages is required: the dev group pulls in tracelyai-sdk (the SDK) but NOT # tracely-backend, so without it `backend/tests/conftest.py` dies on `import tracely`. # Matches `make install`. - name: Install (uv sync --frozen --all-packages) run: uv sync --frozen --all-packages --all-extras - name: Lint (ruff check) run: uv run ruff check . - name: Test (pytest) run: uv run pytest -q backend/tests sdk/tests frontend: name: frontend · next build runs-on: ubuntu-latest defaults: run: working-directory: frontend steps: - uses: actions/checkout@v7 - uses: pnpm/action-setup@v4 with: version: 9 - uses: actions/setup-node@v7 with: node-version: 22 cache: pnpm cache-dependency-path: frontend/pnpm-lock.yaml # Matches the prod Dockerfile (Dockerfile.railway) — its lockfile is installed non-frozen. - name: Install deps run: pnpm install --no-frozen-lockfile # Vitest unit/component tests (pure trace-table helpers + a TraceTable render guard). - name: Test run: pnpm test # `next build` type-checks (tsc) + lints + compiles — the frontend's fast feedback gate. # Retried: `next/font/google` downloads the three font families from fonts.gstatic.com at # BUILD time, and a transient fetch failure there fails the whole build with a `next/font` # error (Next's own 3 internal retries fire within a second, so they don't outlast a blip). # That is a network flake, not a code failure. A real compile error fails all three attempts # in seconds. If this starts firing often, self-host the woff2 files with `next/font/local` # and the build stops touching the network at all. - name: Build run: | for i in 1 2 3; do if pnpm build; then exit 0; fi echo "::warning::next build failed (attempt $i/3) — retrying in 15s" sleep 15 done exit 1 env: NEXT_PUBLIC_AUTH_MODE: dev NEXT_TELEMETRY_DISABLED: "1" docker: name: docker · build prod images runs-on: ubuntu-latest # Build both production images so a broken Dockerfile fails CI instead of the deploy — the # frontend prod image (Dockerfile.railway) was previously never built until Railway deploy. steps: - uses: actions/checkout@v7 - uses: docker/setup-buildx-action@v4 - name: Backend image uses: docker/build-push-action@v6 with: context: . file: Dockerfile.backend push: false cache-from: type=gha,scope=backend cache-to: type=gha,mode=max,scope=backend - name: Frontend image (prod) uses: docker/build-push-action@v6 with: context: . file: frontend/Dockerfile.railway push: false cache-from: type=gha,scope=frontend cache-to: type=gha,mode=max,scope=frontend audit: name: deps · security audit (informational) runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: astral-sh/setup-uv@v5 with: enable-cache: true - name: pip-audit (python deps) continue-on-error: true # advisory: surfaces CVEs in transitive deps; doesn't block PRs run: | uv export --frozen --no-emit-workspace --format requirements-txt -o requirements.txt uvx pip-audit -r requirements.txt - uses: pnpm/action-setup@v4 with: version: 9 - name: pnpm audit (frontend deps) continue-on-error: true working-directory: frontend run: pnpm audit --audit-level=high