From d892e5849921f22591322b3e273b1adeaa1d37f0 Mon Sep 17 00:00:00 2001 From: Grantfox Agent <160465301+emirykl@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:30:51 +0300 Subject: [PATCH] ci: add aggregate SDK test and typecheck job --- .github/workflows/sdk.yml | 43 +++++++++++++++++++++++++++++++++++++++ docs/CI.md | 8 ++++++++ scripts/sdk-ci.test.mjs | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 .github/workflows/sdk.yml create mode 100644 scripts/sdk-ci.test.mjs diff --git a/.github/workflows/sdk.yml b/.github/workflows/sdk.yml new file mode 100644 index 00000000..56430c9e --- /dev/null +++ b/.github/workflows/sdk.yml @@ -0,0 +1,43 @@ +name: SDK checks + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + sdk: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - 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 SDK CI configuration + run: node --test scripts/sdk-ci.test.mjs + + - name: Install JS dependencies + run: pnpm install --frozen-lockfile --ignore-scripts + + - name: Test SDK + run: pnpm sdk:test + + - name: Typecheck SDK + run: pnpm sdk:typecheck diff --git a/docs/CI.md b/docs/CI.md index dabddd1a..9c58bf8f 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -24,6 +24,14 @@ 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. +## SDK checks + +The `SDK checks` workflow (`.github/workflows/sdk.yml`) runs on pushes to +`main` and on pull requests. Its blocking job installs frozen pnpm dependencies +with lifecycle scripts disabled, then runs `pnpm sdk:test` and +`pnpm sdk:typecheck`. Run those two commands locally to check `packages/sdk`; +`node --test scripts/sdk-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/sdk-ci.test.mjs b/scripts/sdk-ci.test.mjs new file mode 100644 index 00000000..5b690cfd --- /dev/null +++ b/scripts/sdk-ci.test.mjs @@ -0,0 +1,37 @@ +// 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/sdk.yml", import.meta.url), "utf8"); +const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")); + +test("SDK CI installs locked dependencies and runs both root checks in one blocking job", () => { + assert.match(workflow, /^ push:\n branches: \[main\]$/m); + assert.match(workflow, /^ pull_request:$/m); + assert.match(workflow, /^permissions:\n contents: read$/m); + + const job = workflow.match(/^ sdk:\n([\s\S]*)$/m)?.[1]; + assert.ok(job, "SDK job must exist"); + assert.doesNotMatch(job, /^ [a-z][\w-]*:/m, "checks must stay in the SDK job"); + assert.doesNotMatch(job, /\bcontinue-on-error\s*:/, "checks must block on failure"); + assert.match(job, /^ persist-credentials: false$/m); + assert.match(job, /^ version: 10\.13\.1$/m); + assert.match(job, /^ node-version: "22"$/m); + + const steps = [ + "node --test scripts/sdk-ci.test.mjs", + "pnpm install --frozen-lockfile --ignore-scripts", + "pnpm sdk:test", + "pnpm sdk:typecheck", + ]; + let previousStep = -1; + for (const command of steps) { + const step = job.indexOf(` run: ${command}\n`); + assert.ok(step > previousStep, `${command} must follow the preceding step`); + previousStep = step; + } + + assert.equal(pkg.scripts["sdk:test"], "pnpm --filter @sub-rosa/sdk test"); + assert.equal(pkg.scripts["sdk:typecheck"], "pnpm --filter @sub-rosa/sdk typecheck"); +});