Skip to content

Commit ca5b95d

Browse files
authored
Merge pull request #18 from rhyek/ci/parallel-jobs
Run CI's suites side by side, and drop CI from the release
2 parents 607a02c + aebf4c6 commit ca5b95d

16 files changed

Lines changed: 2381 additions & 2181 deletions

‎.github/workflows/ci.yaml‎

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
name: ci
22

3-
# Runs on every pull request, where the `check` job is a required status check for merging
4-
# into `main` (.github/rulesets/main.json), and again from release.yaml before a release is
5-
# published, so the merged result is tested too.
3+
# Runs on every pull request. The jobs run side by side; `check` waits for all of them, and it is
4+
# the required status check for merging into `main` (.github/rulesets/main.json), so a job can be
5+
# added or split without touching the ruleset.
66
on:
77
pull_request:
88
branches: [main]
9-
workflow_call:
109

1110
permissions: {}
1211

1312
concurrency:
14-
group: ci-${{ github.event.pull_request.number || github.run_id }}
13+
group: ci-${{ github.event.pull_request.number }}
1514
cancel-in-progress: true
1615

1716
jobs:
18-
check:
17+
lint:
18+
name: build and lint
1919
runs-on: ubuntu-latest
2020
permissions:
2121
contents: read
@@ -45,8 +45,8 @@ jobs:
4545
- run: pnpm --dir example install --frozen-lockfile
4646

4747
# Build first: the lint's type-aware rules read `stackctl`'s types in `example/` (and
48-
# `postinstall.js`'s import) from the package's compiled `dist/`, and some tests import it.
49-
# The build also builds the docs site, which fails on a dead link, and packages its llms.txt.
48+
# `postinstall.js`'s import) from the package's compiled `dist/`. The build also builds the
49+
# docs site, which fails on a dead link, and packages its llms.txt.
5050
- run: pnpm build
5151

5252
# The source maps name the package's own sources, so a build change that would publish the
@@ -56,11 +56,66 @@ jobs:
5656
# The root lint covers `example/` too.
5757
- run: pnpm lint
5858

59-
- run: pnpm test
59+
# Type-level assertions (`*.test-d.ts`), which only the type checker enforces.
60+
- run: pnpm test:types
6061

61-
# The real CLI on a pseudo-terminal (python3's stdlib `pty`, which the runner has). It
62-
# compiles its own copy of the CLI, so it needs nothing from the build above.
63-
- run: pnpm test:e2e
62+
test:
63+
name: test (${{ matrix.suite }})
64+
runs-on: ubuntu-latest
65+
permissions:
66+
contents: read
67+
strategy:
68+
# One suite failing doesn't cancel the others, so a run reports every suite that fails.
69+
fail-fast: false
70+
matrix:
71+
# The Vitest projects in vitest.config.ts, and the end-to-end suite.
72+
suite: [unit, cli, e2e]
73+
env:
74+
SKIP_SIMPLE_GIT_HOOKS: 1
75+
SUITE: ${{ matrix.suite }}
76+
steps:
77+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
78+
with:
79+
persist-credentials: false
6480

65-
# Type-level assertions (`*.test-d.ts`) are only enforced under --typecheck.
66-
- run: pnpm test:types
81+
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
82+
with:
83+
version: 12.15.0
84+
85+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
86+
with:
87+
node-version-file: '.tool-versions'
88+
89+
- run: pnpm install --frozen-lockfile
90+
91+
# Some unit specs import the package's compiled `dist/`. The CLI specs and the end-to-end
92+
# suite compile their own copy of the CLI, so they need no build.
93+
- if: matrix.suite == 'unit'
94+
run: pnpm --filter stackctl build
95+
96+
# The end-to-end suite runs the real CLI on a pseudo-terminal (python3's stdlib `pty`, which
97+
# the runner has).
98+
- run: |
99+
if [ "$SUITE" = e2e ]; then
100+
pnpm test:e2e
101+
else
102+
pnpm test --project "$SUITE"
103+
fi
104+
105+
# The required status check: passes only when every job above did. It runs always, cancelled
106+
# runs included, so it fails rather than being skipped, which a required check would let through.
107+
check:
108+
needs: [lint, test]
109+
if: always()
110+
runs-on: ubuntu-latest
111+
permissions: {}
112+
steps:
113+
- env:
114+
RESULTS: ${{ join(needs.*.result, ' ') }}
115+
run: |
116+
for result in $RESULTS; do
117+
if [ "$result" != success ]; then
118+
echo "::error::a job did not succeed: $RESULTS"
119+
exit 1
120+
fi
121+
done

‎.github/workflows/release.yaml‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,11 @@ jobs:
6161
echo "on_github=false" >> "$GITHUB_OUTPUT"
6262
fi
6363
64-
ci:
64+
# No CI run here: `main` takes changes only through pull requests, whose CI must pass
65+
# (.github/rulesets/main.json). The build below still has to succeed before anything publishes.
66+
publish:
6567
needs: detect
6668
if: needs.detect.outputs.on_npm == 'false' || needs.detect.outputs.on_github == 'false'
67-
permissions:
68-
contents: read
69-
# `./`, not zizmor's `$/`: actionlint rejects `$/`, and `./` is the documented form.
70-
uses: ./.github/workflows/ci.yaml # zizmor: ignore[self-repository]
71-
72-
publish:
73-
needs: [detect, ci]
7469
runs-on: ubuntu-latest
7570
# npm's trusted publisher for stackctl is bound to this environment.
7671
environment: release

‎CLAUDE.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ pnpm build
141141
The root `build` script runs `pnpm --filter stackctl build`, which cleans
142142
`dist/`, compiles with `tsc -p tsconfig.build.json`, and marks the compiled CLI
143143
(`dist/cli.js`) executable, then `pnpm docs:package`, which builds the docs site and copies
144-
its `llms.txt` and pages into `packages/stackctl/docs/`. CI (`.github/workflows/ci.yaml`, which `release.yaml` also
145-
calls) uses this same command.
144+
its `llms.txt` and pages into `packages/stackctl/docs/`. CI (`.github/workflows/ci.yaml`) and `release.yaml` use this same
145+
command.
146146

147147
## Changelog and releases
148148

@@ -187,12 +187,13 @@ is asserted in `packages/stackctl/src/config.test-d.ts` with vitest's `expectTyp
187187
(`expect-type`, already a vitest dependency — nothing to install):
188188

189189
```sh
190-
pnpm test:types # vitest --typecheck.only --run
190+
pnpm test:types # vitest run --project types
191191
```
192192

193-
**`expectTypeOf` is a no-op without `--typecheck`** — it compiles and "passes" under plain
194-
`pnpm test`, which is why the assertions live in `*.test-d.ts` and get their own script and CI
195-
step. `vitest.config.ts` points `typecheck.tsconfig` at `packages/stackctl/tsconfig.typecheck.json`,
193+
**`expectTypeOf` is a no-op without the type checker** — it compiles and "passes" in a runtime
194+
test, which is why the assertions live in `*.test-d.ts`, in a Vitest project of their own (`types`
195+
in `vitest.config.ts`, which `pnpm test` runs too). That project points `typecheck.tsconfig` at
196+
`packages/stackctl/tsconfig.typecheck.json`,
196197
which is the normal tsconfig minus three spec files that already fail typecheck on main — so a
197198
real type error anywhere else still fails the run rather than being blanket-ignored.
198199

‎RELEASING.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ Publishing uses npm **trusted publishing** (OIDC): no npm token is stored anywhe
2929
label, `beta`, and marked as a prerelease on GitHub, so `npm install stackctl` keeps
3030
resolving to the latest stable version. A stable version goes to `latest`.
3131

32-
2. Open the pull request. CI's `check` job runs `node maintenance/scripts/changelog.ts check`,
32+
2. Open the pull request. CI runs `node maintenance/scripts/changelog.ts check`,
3333
which fails if the top section is empty, its version isn't newer than the latest release, or it adds
3434
an entry to a version already released (rewording one, or fixing its link, is fine). A
3535
new entry always goes under a new heading. It also fails if any link in `CHANGELOG.md`
3636
points at a file or heading that doesn't exist, as one does after a page moves.
3737

3838
3. Merge it. `.github/workflows/release.yaml` reads the top heading and, if that version
39-
isn't out yet, runs CI again on the merged result, then:
39+
isn't out yet, builds the package, then:
4040
- publishes the package to npm, tokenless over OIDC;
4141
- creates the GitHub release and its `vX.Y.Z` tag, with the section as its notes and its
4242
relative links pinned to the tag.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "oxlint --disable-nested-config && oxfmt --check --disable-nested-config && node maintenance/scripts/format-docs-snippets.ts --check",
1111
"focus": "pnpm --filter stackctl focus",
1212
"palette": "pnpm --filter stackctl palette",
13-
"test:types": "vitest --typecheck.only --run",
13+
"test:types": "vitest run --project types",
1414
"format": "oxfmt --disable-nested-config && node maintenance/scripts/format-docs-snippets.ts",
1515
"prepare": "simple-git-hooks",
1616
"test": "vitest run",

‎packages/stackctl/e2e/cli.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* The CLI the e2e suite runs: compiled from the current source once per run (by the global setup),
3-
* as `cli.spec.ts` does, so no test runs against a stale `dist/` and nothing touches it. It goes
4-
* under the package's own `node_modules`, so its imports resolve the package's dependencies, in a
5-
* directory of its own: `cli.spec.ts` deletes its `cli-spec` copy as it starts, and may be running
6-
* at the same time. It is laid out as the published package is, `dist/` beside `assets/` and
3+
* as the `src/cli-spec/` files do, so no test runs against a stale `dist/` and nothing touches it.
4+
* It goes under the package's own `node_modules`, so its imports resolve the package's
5+
* dependencies, in a directory of its own: each `cli-spec` file deletes its own copy as it starts,
6+
* and may be running at the same time. It is laid out as the published package is, `dist/` beside `assets/` and
77
* `skills/`, which the compiled code reads from its own directory's parent.
88
*/
99
import { execFile } from 'node:child_process';

0 commit comments

Comments
 (0)