1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Test
# Mirror the local pre-push hook's test and coverage gates in CI, so they are
# enforced on every PR even when a contributor (or a fork) hasn't installed the
# git hooks. Previously CI ran only fmt + clippy (see lint.yml); `cargo test`
# and the 100% line-coverage floor lived solely in the pre-push hook, so a PR
# that skipped hook setup could break tests or drop coverage and still go
# green.
#
# This relies on the committed `prebuilt.html` (build.rs falls back to it when
# pnpm is absent), so no pnpm step is needed to build and test the server
# crate. Both commands mirror CONTRIBUTING.md's documented pre-push gate —
# keep the hook, CONTRIBUTING.md, and this workflow in lockstep.
#
# `client/` isn't a Cargo workspace member, so `cargo test` never runs its
# Vitest suite. The `client-test` job below mirrors the pre-push hook's
# `pnpm --filter client test` step in CI.
# Restrict the default GITHUB_TOKEN to read-only; this workflow only needs to
# read repository contents to check out and run the test suite.
permissions:
contents: read
on:
pull_request:
push:
branches:
workflow_call:
inputs:
ref:
description: >
Git ref to check out. Empty (the default) means "use the ref that
triggered this run" — set only by changeset-release.yml, which
calls this workflow directly to test a branch (changeset-release/main)
other than the one that triggered it.
required: false
type: string
# Cancel a stale run when a PR gets a new push, matching lint.yml's behavior
# so superseded test runs don't pile up and burn CI minutes. Literal "test"
# prefix, not ${{ github.workflow }} — see lint.yml's comment: workflow_call
# callers (cut-release.yml) would otherwise collide lint and test onto the
# same concurrency group and race-cancel each other.
concurrency:
group: test-${{ inputs.ref || github.ref }}
cancel-in-progress: true
jobs:
test:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref }}
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Cache cargo registry and target/
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
# Scoped so the `test` and `clippy` jobs' target/ artifacts (built
# with different flags: plain build vs --all-targets clippy) don't
# clobber each other's cache entry.
shared-key: test
- name: Run tests
run: cargo test
coverage:
name: cargo llvm-cov (100% line floor)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust (with llvm-tools-preview)
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
components: llvm-tools-preview
- name: Cache cargo registry (registry only, not target)
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov --locked
- name: Enforce 100% line coverage (excluding main.rs)
run: cargo llvm-cov --fail-under-lines 100 --ignore-filename-regex 'src/main\.rs'
client-test:
name: client (vitest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref }}
- name: Install pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- name: Install Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm --filter client test