Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions docs/CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## Appraisal API checks

The `Appraisal API checks` workflow (`.github/workflows/appraisal.yml`) runs on
Expand Down
37 changes: 37 additions & 0 deletions scripts/sdk-ci.test.mjs
Original file line number Diff line number Diff line change
@@ -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");
});
Loading