|
| 1 | +# CI test gate — run the test suites on every pull request and on push to |
| 2 | +# `main`, so a red suite can't merge. |
| 3 | +# |
| 4 | +# WHY: until now the lint/test pipeline was local-only — `scripts/lint.sh` |
| 5 | +# + the pre-commit hooks, run on a contributor's laptop before the Merger |
| 6 | +# pulled a PR (the deliberate "no CI in pre-alpha" posture). With many |
| 7 | +# agents merging in parallel and only CodeQL gating server-side, test |
| 8 | +# regressions slipped onto `main` green (e.g. #401 broke |
| 9 | +# `tests/test_logentry.py`, undetected until a later full local run — |
| 10 | +# #451). This enforces the suites server-side. Resolves the core of #452 |
| 11 | +# (run the test suites in CI); the no-CI revisit is recorded in |
| 12 | +# `SECURITY.md` §8 / `docs/agents/decisions.md` / OQ-A-001. |
| 13 | +# |
| 14 | +# SCOPE: the backend job runs `pytest` (the regression that motivated |
| 15 | +# #452 was a broken test). The frontend job runs the full `pnpm` gate — |
| 16 | +# typecheck + lint + test + build — which is already self-consistent and |
| 17 | +# green. Enforcing the *Python lint* gate in CI is a deliberate near-term |
| 18 | +# follow-up: `scripts/lint.sh` currently runs two formatters (`ruff |
| 19 | +# format` + `black`) whose output conflicts, so it is not yet satisfiable |
| 20 | +# on a clean tree. That gets de-conflicted and the small existing lint |
| 21 | +# debt cleared first (follow-up off #452), then the lint step is added |
| 22 | +# here. |
| 23 | +# |
| 24 | +# SECURITY POSTURE: |
| 25 | +# - Least-privilege: top-level `contents: read`; no job needs write. |
| 26 | +# - All third-party actions are pinned to a full commit SHA (a tag can |
| 27 | +# be moved, a SHA cannot) — consistent with codeql.yml / release.yml |
| 28 | +# and the supply-chain hardening in #331. |
| 29 | +# - This is a *gate*, not a publisher: it has no access to PyPI, no |
| 30 | +# `id-token`, and no stored secrets. |
| 31 | +# |
| 32 | +# NOTE: making these checks *required* (branch protection) is a separate |
| 33 | +# owner action in repo Settings → Branches — see #452 / #331. |
| 34 | +name: ci |
| 35 | + |
| 36 | +on: |
| 37 | + push: |
| 38 | + branches: [main] |
| 39 | + pull_request: |
| 40 | + branches: [main] |
| 41 | + |
| 42 | +permissions: |
| 43 | + contents: read |
| 44 | + |
| 45 | +# A newer push to the same ref supersedes an in-flight run — don't burn |
| 46 | +# minutes finishing a run whose commit is already stale. |
| 47 | +concurrency: |
| 48 | + group: ci-${{ github.workflow }}-${{ github.ref }} |
| 49 | + cancel-in-progress: true |
| 50 | + |
| 51 | +jobs: |
| 52 | + backend: |
| 53 | + name: Backend (pytest) |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - name: Checkout |
| 57 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 58 | + |
| 59 | + - name: Set up Python |
| 60 | + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 |
| 61 | + with: |
| 62 | + python-version: "3.12" |
| 63 | + |
| 64 | + - name: Install Poetry |
| 65 | + # Poetry is pinned to the version that generated poetry.lock (see |
| 66 | + # its header). `poetry install` compares the lock's content-hash |
| 67 | + # against the one it computes from pyproject; a different Poetry |
| 68 | + # can compute it differently and reject an otherwise-valid lock. |
| 69 | + # Bump this in lockstep whenever the lock is regenerated. |
| 70 | + run: pipx install poetry==2.1.4 |
| 71 | + |
| 72 | + - name: Install dependencies (locked) |
| 73 | + run: poetry install --no-interaction |
| 74 | + |
| 75 | + # pytest with coverage (per pyproject `addopts`), including |
| 76 | + # tests/test_security.py. `filterwarnings = ["error"]` means a new |
| 77 | + # warning fails the run. |
| 78 | + - name: Tests (pytest) |
| 79 | + run: poetry run pytest |
| 80 | + |
| 81 | + frontend: |
| 82 | + name: Frontend (typecheck + lint + test + build) |
| 83 | + runs-on: ubuntu-latest |
| 84 | + defaults: |
| 85 | + run: |
| 86 | + working-directory: frontend |
| 87 | + steps: |
| 88 | + - name: Checkout |
| 89 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 90 | + |
| 91 | + - name: Set up pnpm |
| 92 | + uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 |
| 93 | + with: |
| 94 | + version: 9 |
| 95 | + |
| 96 | + - name: Set up Node |
| 97 | + uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 |
| 98 | + with: |
| 99 | + node-version: 22 |
| 100 | + cache: pnpm |
| 101 | + cache-dependency-path: frontend/pnpm-lock.yaml |
| 102 | + |
| 103 | + - name: Install dependencies (frozen lockfile) |
| 104 | + run: pnpm install --frozen-lockfile |
| 105 | + |
| 106 | + - name: Typecheck (tsc --noEmit, every package) |
| 107 | + run: pnpm -r typecheck |
| 108 | + |
| 109 | + - name: Lint (eslint --max-warnings 0 + stylelint + dark-mode coverage) |
| 110 | + run: pnpm lint |
| 111 | + |
| 112 | + - name: Unit tests (vitest) |
| 113 | + run: pnpm test |
| 114 | + |
| 115 | + - name: Build (Vite bundle, every package) |
| 116 | + run: pnpm -r build |
0 commit comments