11name : 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 .
66on :
77 pull_request :
88 branches : [main]
9- workflow_call :
109
1110permissions : {}
1211
1312concurrency :
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
1716jobs :
18- check :
17+ lint :
18+ name : build and lint
1919 runs-on : ubuntu-latest
2020 permissions :
2121 contents : read
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
0 commit comments