Open History to see the last commit
1// The `ci` job of .github/workflows/ci.yml, on the forge. Runs on every pull
2// request, whatever its base, so a stacked pull request (never opened on
3// GitHub) gets checks too. GitHub CI stays as it is; zizmor stays there.
4//
5// No secrets and no variables: a pull request run is someone's code.
6import {
7 defineWorkflow,
8 manual,
9 pullRequest,
10 push,
11 setup,
12} from '@tanstack-source/ci'
13
14export default defineWorkflow('ci', {
15 // manual(): run a branch by hand (`src ci start ci --ref <branch>`).
16 on: [pullRequest(), push({ branches: ['main'] }), manual()],
17}).job('ci', {
18 // Full history, so the changeset check finds the merge base with main.
19 checkout: { depth: 0 },
20 egress: ['registry.npmjs.org'],
21 timeoutMinutes: 30,
22 steps: [
23 // Node from .node-version.
24 setup.node(),
25 setup.pnpm(),
26 { name: 'Install', run: 'pnpm install --frozen-lockfile' },
27 { name: 'Format check', run: 'pnpm run check' },
28 { name: 'Lint', run: 'pnpm run lint' },
29 { name: 'Typecheck', run: 'pnpm run typecheck' },
30 // A PR that changes a published package needs a changeset (or
31 // `pnpm exec changeset --empty`). The checkout has no remote branches:
32 // fetch main from the forge's internal git host (no egress needed).
33 {
34 name: 'Changeset check',
35 if: (ctx) => ctx.event === 'pull_request',
36 run: 'git fetch --no-tags origin main:refs/remotes/origin/main && pnpm exec changeset status --since=origin/main',
37 },
38 // The committed client must match the spec.
39 { name: 'Client drift check', run: 'pnpm run check:client' },
40 { name: 'Test', run: 'pnpm run test' },
41 { name: 'Build', run: 'pnpm run build' },
42 ],
43})