Debian Codegraph @

.github/workflows/ci.yml

raw
1 name: ci
2
3 on:
4 pull_request:
5 merge_group:
6
7 concurrency:
8 group: >-
9 ${{ github.workflow }}-${{
10 github.event.pull_request.number
11 || github.event.merge_group.head_ref
12 }}
13 cancel-in-progress: true
14
15 permissions: {}
16
17 jobs:
18 test:
19 strategy:
20 fail-fast: ${{ github.event_name == 'merge_group' }}
21 matrix:
22 build: [linux-x86_64-gnu, linux-aarch64-gnu, macos-x86_64, macos-aarch64, windows-x86_64, windows-aarch64]
23 include:
24 - build: linux-x86_64-gnu
25 os: ubuntu-24.04
26 cargo_flags: "--all-features"
27 extra_targets: ""
28 - build: linux-aarch64-gnu
29 os: ubuntu-24.04-arm
30 cargo_flags: "--all-features"
31 extra_targets: ""
32 - build: macos-x86_64
33 os: macos-26
34 cargo_flags: "--target x86_64-apple-darwin"
35 extra_targets: "x86_64-apple-darwin"
36 - build: macos-aarch64
37 os: macos-15
38 cargo_flags: ""
39 extra_targets: ""
40 - build: windows-x86_64
41 os: windows-2022
42 cargo_flags: ""
43 extra_targets: ""
44 - build: windows-aarch64
45 os: windows-11-arm
46 cargo_flags: ""
47 extra_targets: ""
48 runs-on: ${{ matrix.os }}
49
50 # macos-x86_64 runners are inconsistent and prone to hitting the timeout
51 continue-on-error: ${{ matrix.os == 'macos-x86_64' }}
52
53 # TODO FIXME (aseipp): keep the timeout limit to ~20 minutes. this is long
54 # enough to give us runway for the future, but also once we hit it, we're at
55 # the "builds are taking too long" stage and we should start looking at ways
56 # to optimize the CI, or the CI is flaking out on some weird spiked machine
57 #
58 # at the same time, this avoids some issues where some flaky, bugged tests
59 # seem to be causing multi-hour runs on Windows (GPG signing issues), which
60 # is a problem we should fix. in the mean time, this will make these flakes
61 # less harmful, as it won't cause builds to spin for multiple hours, requiring
62 # manual cancellation.
63 #
64 # keep a log of updates (along with committed date) below:
65 #
66 # 2025-03-20 (aseipp): peak p99 builds seemed to be long, bump 15m -> 20m
67 # 2025-10-06 (aseipp): x86 macos runners consistently slower, bump 20m -> 25m
68 # 2026-08-28 (slerpy): x86 macos & arm windows are timing out, bump 25m -> 30m
69 #
70 # The "nix flake" jobs below use the same timeout, so update there too if
71 # you update here.
72 timeout-minutes: 30
73
74 steps:
75 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
76 with:
77 persist-credentials: false
78 - name: Set up Windows Builders
79 if: startswith(matrix.build, 'windows-x86_64') # FIXME: aarch64 doesn't have D:\ yet
80 uses: ./.github/actions/setup-windows
81 - name: Install Rust
82 uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
83 with:
84 toolchain: 1.89
85 # comma-separated list of extra targets to install
86 targets: ${{ matrix.extra_targets }}
87 - uses: taiki-e/install-action@67729d5c413db75907f0ad1e39bb04b9c868ff60
88 with:
89 tool: nextest
90 - name: Install mold
91 uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444
92 with:
93 make-default: false
94 - name: Build
95 run: >-
96 cargo build
97 --config .cargo/config-ci.toml
98 --workspace
99 --all-targets
100 --verbose
101 ${{ matrix.cargo_flags }}
102 - name: Test
103 run: >-
104 cargo nextest run
105 --config .cargo/config-ci.toml
106 --workspace
107 --all-targets
108 --verbose
109 --profile ci
110 ${{ matrix.cargo_flags }}
111 env:
112 RUST_BACKTRACE: 1
113 CARGO_TERM_COLOR: always
114
115 no-git:
116 name: build (no git)
117 runs-on: ubuntu-24.04
118 steps:
119 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
120 with:
121 persist-credentials: false
122 - name: Install Rust
123 uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
124 with:
125 toolchain: 1.89
126 - name: Build
127 run: cargo build -p jj-cli --no-default-features --verbose
128
129 build-nix:
130 name: nix flake
131 strategy:
132 fail-fast: ${{ github.event_name == 'merge_group' }}
133 matrix:
134 os: [ubuntu-24.04, ubuntu-24.04-arm, macos-14]
135 runs-on: ${{ matrix.os }}
136 timeout-minutes: 25
137
138 steps:
139 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
140 with:
141 fetch-depth: 0
142 persist-credentials: false
143 - uses: cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342
144 - run: nix flake check -L --show-trace
145
146 check-protos:
147 name: check (protos)
148 runs-on: ubuntu-24.04
149 steps:
150 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
151 with:
152 persist-credentials: false
153 - uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
154 with:
155 toolchain: stable
156 - run: sudo apt update && sudo apt-get -y install protobuf-compiler
157 - name: Generate Rust code from .proto files
158 run: cargo run -p gen-protos
159 - name: Check for uncommitted changes
160 run: git diff --exit-code
161
162 check-rustfmt:
163 name: check (rustfmt)
164 runs-on: ubuntu-24.04
165 steps:
166 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
167 with:
168 persist-credentials: false
169 - uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
170 with:
171 toolchain: nightly
172 components: rustfmt
173 - run: cargo +nightly fmt --all -- --check
174
175 check-clippy:
176 name: check (clippy)
177 permissions:
178 checks: write
179 runs-on: ubuntu-24.04
180 steps:
181 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
182 with:
183 persist-credentials: false
184 - uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
185 with:
186 toolchain: stable
187 components: clippy
188 - run: cargo +stable clippy --all-features --workspace --all-targets -- -D warnings
189
190 check-cargo-deny:
191 runs-on: ubuntu-24.04
192 strategy:
193 matrix:
194 checks:
195 - advisories
196 - bans
197 - licenses
198 - sources
199
200 # Prevent sudden announcement of a new advisory from failing ci:
201 continue-on-error: ${{ matrix.checks == 'advisories' }}
202
203 name: check (cargo-deny, ${{ matrix.checks }})
204 steps:
205 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
206 with:
207 persist-credentials: false
208 - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25
209 with:
210 command: check ${{ matrix.checks }}
211
212 check-codespell:
213 name: check (codespell)
214 runs-on: ubuntu-24.04
215 steps:
216 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
217 with:
218 persist-credentials: false
219 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
220 with:
221 python-version: 3.11
222 - name: Install uv
223 uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
224 with:
225 # If you bump the version, also update docs/contributing.md
226 # and all other workflows that install uv
227 version: "0.5.1"
228 - name: Run Codespell
229 run: uv run -- codespell && echo Codespell exited successfully
230
231 check-doctests:
232 name: check (doctests)
233 runs-on: ubuntu-24.04
234 steps:
235 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
236 with:
237 persist-credentials: false
238 - uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
239 with:
240 toolchain: 1.89
241 # NOTE: We need to run `cargo test --doc` separately from normal tests:
242 # - `cargo build --all-targets` specifies: "Build all targets"
243 # - `cargo test --all-targets` specifies: "Test all targets (does not include doctests)"
244 - name: Run doctests
245 run: cargo test --workspace --doc
246 env:
247 RUST_BACKTRACE: 1
248 - name: Check `cargo doc` for lint issues
249 env:
250 RUSTDOCFLAGS: "--deny warnings"
251 run: cargo doc --workspace --no-deps
252
253 check-mkdocs:
254 name: check (mkdocs)
255 runs-on: ubuntu-24.04
256 steps:
257 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
258 with:
259 persist-credentials: false
260 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
261 with:
262 python-version: 3.11
263 - name: Install uv
264 uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
265 with:
266 # If you bump the version, also update docs/contributing.md
267 # and all other workflows that install uv
268 version: "0.5.1"
269 - name: Check that `mkdocs` can build the docs
270 run: uv run -- mkdocs build --strict
271
272 # An optional job to alert us when uv updates break the build
273 check-mkdocs-latest:
274 name: check (latest mkdocs, optional)
275 runs-on: ubuntu-24.04
276 steps:
277 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
278 with:
279 persist-credentials: false
280 - name: Install uv
281 uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
282 # 'only-managed' means that uv will always download Python, even
283 # if the runner happens to provide a compatible version
284 - name: Check that `mkdocs` can build the docs
285 run: uv run --python-preference=only-managed -- mkdocs build --strict
286
287 check-zizmor:
288 name: check (zizmor)
289 runs-on: ubuntu-latest
290 permissions:
291 security-events: write
292 steps:
293 - name: Checkout repository
294 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
295 with:
296 persist-credentials: false
297
298 - name: Install the latest version of uv
299 uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
300
301 - name: Run zizmor
302 run: uvx zizmor --format sarif . > results.sarif
303 env:
304 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
305
306 - name: Upload SARIF file
307 uses: github/codeql-action/upload-sarif@d1ba80a13dd99fba24a470575428917156a28b43
308 with:
309 sarif_file: results.sarif
310 category: zizmor
311
312 # Count the (very approximate) number of dependencies in Cargo.lock and bail at a certain limit.
313 check-cargo-lock-bloat:
314 name: check (Cargo.lock dependency count)
315 runs-on: ubuntu-24.04
316 steps:
317 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
318 with:
319 persist-credentials: false
320 - name: Check total dependency count in Cargo.lock
321 run: |
322 total_deps=$(./.github/scripts/count-cargo-lock-packages)
323 if [ "$total_deps" -gt "${TOTAL_DEP_LIMIT}" ]; then
324 ./.github/scripts/dragon-bureaucrat \
325 "Cargo.lock has too many dependencies ($total_deps > ${TOTAL_DEP_LIMIT}). The Dragon banishes thee!
326
327 You can raise the limit in \`.github/workflows/ci.yml\` if necessary, but
328 consider whether it’s possible to trim things down first."
329 else
330 echo "Counted $total_deps Cargo.lock dependencies." \
331 "This is within the allowed limit of ${TOTAL_DEP_LIMIT}."
332 fi
333 env:
334 # This limit *can* be raised, we just want to be aware if we exceed it
335 TOTAL_DEP_LIMIT: 550
336
337 # Block the merge if required checks fail, but only in the merge
338 # queue. See also `required-checks-hack.yml`.
339 required-checks:
340 name: required checks (merge queue)
341 if: ${{ always() && github.event_name == 'merge_group' }}
342 needs:
343 - test
344 - no-git
345 - build-nix
346 - check-protos
347 - check-rustfmt
348 - check-clippy
349 - check-cargo-deny
350 - check-codespell
351 - check-doctests
352 - check-mkdocs
353 # - check-mkdocs-latest
354 # - check-zizmor
355 - check-cargo-lock-bloat
356 runs-on: ubuntu-latest
357 steps:
358 - name: Block merge if required checks fail
359 if: >-
360 ${{
361 contains(needs.*.result, 'failure')
362 || contains(needs.*.result, 'cancelled')
363 }}
364 run: exit 1