From c0a53039f510767876c22a35a65e88516b934829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Ccaneryy=E2=80=9D?= Date: Mon, 23 Nov 2026 21:00:26 +0300 Subject: [PATCH] ci(appraisal): run tests and typecheck on every PR --- .github/workflows/appraisal.yml | 44 +++++++++++++++++++++++++++++++++ docs/CI.md | 9 +++++++ scripts/appraisal-ci.test.mjs | 31 +++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 .github/workflows/appraisal.yml create mode 100644 scripts/appraisal-ci.test.mjs diff --git a/.github/workflows/appraisal.yml b/.github/workflows/appraisal.yml new file mode 100644 index 00000000..5d84a664 --- /dev/null +++ b/.github/workflows/appraisal.yml @@ -0,0 +1,44 @@ +name: Appraisal API checks + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + appraisal: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + # Read-only workflow: downstream steps do not push + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - uses: pnpm/action-setup@v4 + with: + version: 10.13.1 + + - uses: actions/setup-node@v4 + with: + node-version: "22" + cache: pnpm + + - name: Check appraisal CI configuration + run: node --test scripts/appraisal-ci.test.mjs + + - name: Install JS dependencies + run: pnpm install --frozen-lockfile --ignore-scripts + + - name: Test appraisal API + run: pnpm appraisal:test + + - name: Typecheck appraisal API + run: pnpm appraisal:typecheck diff --git a/docs/CI.md b/docs/CI.md index dabddd1a..d3f0d42e 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -24,6 +24,15 @@ dependencies without lifecycle scripts, then runs `pnpm web:test`, locally to check `apps/web`; `node --test scripts/web-ci.test.mjs` verifies the CI job configuration. +## Appraisal API checks + +The `Appraisal API checks` workflow (`.github/workflows/appraisal.yml`) runs on +pushes to `main` and on pull requests. Its single blocking job installs locked +JS dependencies without lifecycle scripts, then runs `pnpm appraisal:test` and +`pnpm appraisal:typecheck` in order. Run the same two commands locally to check +`services/appraisal-api`; `node --test scripts/appraisal-ci.test.mjs` verifies +the CI job configuration. + Repository-level GitHub Actions settings, including the approval policy for fork pull request workflows, are recorded in [GITHUB_ACTIONS_SECURITY.md](./GITHUB_ACTIONS_SECURITY.md). diff --git a/scripts/appraisal-ci.test.mjs b/scripts/appraisal-ci.test.mjs new file mode 100644 index 00000000..61fad048 --- /dev/null +++ b/scripts/appraisal-ci.test.mjs @@ -0,0 +1,31 @@ +// Copyright (c) 2026 Sub Rosa contributors +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { test } from "node:test"; + +const workflow = readFileSync( + new URL("../.github/workflows/appraisal.yml", import.meta.url), + "utf8", +); +const scripts = JSON.parse( + readFileSync(new URL("../package.json", import.meta.url), "utf8"), +).scripts; + +test("appraisal CI runs test and typecheck as blocking steps in one job", () => { + assert.match(workflow, /^ push:\n branches: \[main\]$/m); + assert.match(workflow, /^ pull_request:$/m); + + const job = workflow.match(/^ appraisal:\n([\s\S]*)$/m)?.[1]; + assert.ok(job, "appraisal job must exist"); + assert.doesNotMatch(job, /^ [a-z][\w-]*:/m, "checks must stay in the appraisal job"); + assert.doesNotMatch(job, /\bcontinue-on-error\s*:/, "checks must block on failure"); + assert.match(job, /^ run: pnpm install --frozen-lockfile --ignore-scripts$/m); + + let previousStep = -1; + for (const script of ["appraisal:test", "appraisal:typecheck"]) { + assert.ok(scripts[script], `root script ${script} must exist`); + const step = job.indexOf(` run: pnpm ${script}\n`); + assert.ok(step > previousStep, `${script} must run after the preceding check`); + previousStep = step; + } +});