Repository navigation
412 lines (393 loc) · 16.4 KB
/
Copy pathci.yml
File metadata and controls
412 lines (393 loc) · 16.4 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
name: CI
# Reproduce every job locally: `cargo xtask ci`
# Job → command map: `.claude/rules/ci.md`
# Changing a `run:` here without updating those two is a bug.
on:
push:
branches: [main, master]
pull_request:
# Cancel superseded runs on the same ref (rapid PR pushes / force-pushes).
# Always cancel here: CI never signs or publishes artifacts.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-D warnings"
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
# PR caches are isolated to refs/pull/*/merge and still consume the repo's
# 10 GB allowance. Let PRs reuse master's compiler objects without filling
# the cache with entries no other PR can read.
SCCACHE_GHA_RW_MODE: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'READ_WRITE' || 'READ_ONLY' }}
# Cache policy:
# - rust-cache keeps Cargo's registry/git inputs only; caching target/ produced
# 0.8-1.4 GB archives whose transfer often cost more than the cache saved.
# - sccache stores compiler outputs individually, so jobs fetch only objects
# they need and can share unchanged dependencies across Cargo commands.
# - only master/main writes CI caches; PR-scoped entries cannot warm other PRs.
jobs:
fmt:
name: rustfmt
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
tests: ${{ steps.changes.outputs.tests }}
steps:
- uses: actions/checkout@v7
# Reuse this runner to select test jobs without another build or runner.
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: changes
with:
# PRs compare against their base; pushes compare the entire pushed range.
token: ""
base: ${{ github.event.pull_request.base.sha || github.ref }}
predicate-quantifier: some-with-excludes
filters: |
tests:
- '**/*.rs'
- '**/Cargo.toml'
- 'Cargo.lock'
- 'crates/**'
- 'xtask/**'
- 'tests/**'
- 'fixtures/devices/**'
- 'docs/config.example.toml'
- 'design/icon/openlogi.png'
- 'design/icon/openlogi.ico'
- 'packaging/**'
- '.cargo/**'
- '.github/workflows/ci.yml'
- 'rust-toolchain.toml'
- 'rustfmt.toml'
- '.rustfmt.toml'
- 'clippy.toml'
- 'prek.toml'
- 'sgconfig.yml'
- 'release-plz.toml'
- 'devenv.*'
- '.envrc'
- 'flake.*'
- '!**/*.md'
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check
typos:
name: typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: crate-ci/typos@8a48f81b6c64dcfea44b3633223084c4be58ac5f # v1.49.0
with:
config: .config/typos.toml
# Single-source-of-truth guards stored with their owners: each names the module
# that owns a decision and fails on its ingredients anywhere else.
ast-grep:
name: ast-grep
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ast-grep/action@370e627637505696e4365db4a149af9f2311afe8 # v1.4
with:
version: 0.45.1
publish-closure:
name: publish closure
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
shared-key: linux-stable-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
- run: cargo xtask release check-publish
# The shell equivalent of `rustfmt` + `clippy`. The file set is every tracked
# file shfmt recognises as a shell script, so a new script is covered the day
# it lands — including the extensionless `.agents/*` ones, which it detects by
# shebang. shfmt's formatting options come from `.editorconfig`; passing it a
# printer flag here would silently discard that file.
shell:
name: shell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: taiki-e/install-action@v2
with:
tool: shellcheck,shfmt
- name: List tracked shell scripts
run: git ls-files -z | xargs -0 shfmt -f | tee "${RUNNER_TEMP}/shell-scripts"
- name: shellcheck
run: xargs shellcheck < "${RUNNER_TEMP}/shell-scripts"
- name: shfmt
run: xargs shfmt -d < "${RUNNER_TEMP}/shell-scripts"
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
shared-key: linux-stable-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
- run: |
sudo apt-get update
sudo apt-get install -y \
libudev-dev \
gcc g++ clang libfontconfig-dev libwayland-dev \
libxkbcommon-x11-dev libx11-xcb-dev \
libssl-dev libzstd-dev pkg-config
- run: cargo clippy --workspace --all-targets -- -D warnings
# The floor tracks current stable (see `rust-version` in the root Cargo.toml),
# so what this job buys is keeping that number honest: it fails the moment
# someone reaches for an API newer than what `cargo install` users are
# promised, which the floating-stable jobs above cannot notice. Both
# first-class platforms, because macOS and Linux compile disjoint cfg-gated
# code (evdev/zbus vs the ObjC surface) and a single runner would miss a
# too-new stabilization on the other side.
msrv:
name: MSRV (cargo check, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
# `rust-toolchain.toml` pins the channel to `stable`, and rustup honours
# that file over whatever toolchain this job installs — so for its whole
# life this check silently ran stable and never once verified the floor.
# RUSTUP_TOOLCHAIN outranks the file; keep it in step with the version
# installed above and with `rust-version`.
RUSTUP_TOOLCHAIN: "1.98"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@1.98
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
# Host OS splits Linux vs macOS; the rustc version is already in the key.
shared-key: msrv-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
- if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libudev-dev \
gcc g++ clang libfontconfig-dev libwayland-dev \
libxkbcommon-x11-dev libx11-xcb-dev \
libssl-dev libzstd-dev pkg-config
- run: cargo check --workspace --all-targets
# Stable Linux typecheck is covered by `clippy` above (clippy subsumes
# `cargo check` for the same --workspace --all-targets set — same rationale
# as clippy-windows). The declared floor stays on the `msrv` matrix.
docs:
name: rustdoc (non-GUI crates)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
# Share debug deps with clippy/test-linux; RUSTDOCFLAGS is step-scoped
# below so it does not fork the rust-cache env hash.
shared-key: linux-stable-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
- run: |
sudo apt-get update
sudo apt-get install -y \
libudev-dev \
pkg-config
# Everything except the GPUI crates, which would drag the whole graphics
# toolchain into this job. Excluding by name rather than listing the
# covered crates keeps a new crate documented by default — the hid-only
# version of this step let five broken links rot in `openlogi-core`.
- name: cargo doc
env:
RUSTDOCFLAGS: "-D warnings"
run: |
cargo doc --workspace --no-deps --document-private-items \
--exclude openlogi-ui \
--exclude openlogi-desktop \
--exclude openlogi-overlay \
--exclude openlogi-agent
# openlogi-core / openlogi-hid / openlogi-assets / openlogi / openlogi-hook
# all compile on Linux today (the hook crate has stubs for non-macOS targets).
# openlogi-desktop needs GPUI's wayland / x11 system libs; the same dependency set
# the clippy job installs is sufficient. Test workspace there as well so the
# config-roundtrip and binding suites run on a non-macOS host.
test-linux:
needs: fmt
# A formatting failure must not suppress tests after successful path detection.
if: ${{ !cancelled() && needs.fmt.outputs.tests == 'true' }}
name: tests (linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
shared-key: linux-stable-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
- run: |
sudo apt-get update
sudo apt-get install -y \
libudev-dev \
gcc g++ clang libfontconfig-dev libwayland-dev \
libxkbcommon-x11-dev libx11-xcb-dev \
libssl-dev libzstd-dev pkg-config
- run: cargo test --workspace --exclude openlogi-desktop
test-macos:
needs: fmt
# A formatting failure must not suppress tests after successful path detection.
if: ${{ !cancelled() && needs.fmt.outputs.tests == 'true' }}
name: tests (macos, ${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
runner: macos-latest
- arch: x86_64
runner: macos-15-intel
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
# Host triple already splits arm64 vs x86_64 in the final cache key.
shared-key: macos-stable-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
- name: Verify runner architecture
run: test "$(uname -m)" = "${{ matrix.arch }}"
- run: cargo test --workspace --all-targets
# Runs the workspace's tests on Windows — including the `cfg(windows)` ones,
# which `clippy (windows)` only compiles and no other host can execute. The
# same shape as the Linux job: everything but the desktop crate.
test-windows:
needs: fmt
# A formatting failure must not suppress tests after successful path detection.
if: ${{ !cancelled() && needs.fmt.outputs.tests == 'true' }}
name: tests (windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
shared-key: windows-stable-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
- run: cargo test --workspace --exclude openlogi-desktop
cargo-deny:
name: cargo-deny
runs-on: ubuntu-latest
env:
# cargo-deny calls `rustc -vV` through cargo metadata but does not compile.
# This job deliberately skips the sccache setup used by compilation jobs.
RUSTC_WRAPPER: ""
steps:
- uses: actions/checkout@v7
# Prebuilt binary install is faster than cargo-deny-action's bootstrap path
# (~100s observed); advisory DB is still fetched by `cargo deny check`.
- uses: taiki-e/install-action@v2
with:
tool: cargo-deny
# Global flags before subcommand (matches cargo-deny-action defaults).
# The graph is rooted at the CLI — i.e. exactly the crates published to
# crates.io. cargo-deny picks its roots from the manifest it is given, so
# this was implicit while `openlogi` was the workspace root package; with a
# virtual root it must be explicit, or the git-pinned gpui/zed tree enters
# the graph and the policy in `.cargo/deny.toml` no longer holds. Widening
# the scope to the app crates is tracked separately — see that file.
- run: cargo deny --config .cargo/deny.toml --all-features --manifest-path crates/openlogi/Cargo.toml check
clippy-windows:
name: clippy (windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
shared-key: windows-stable-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
# Whole workspace, matching the Linux jobs — GPUI's DirectX backend
# covers the GUI on Windows. clippy subsumes `cargo check` and
# additionally lints the Windows-only code paths (the WH_MOUSE_LL hook,
# SendInput synthesis, native HID writer, the composite HID++ channel,
# and the agent's HKCU-Run autostart) that the Linux/macOS clippy jobs
# never compile.
- run: cargo clippy --workspace --all-targets -- -D warnings
wasm:
name: wasm (portable crates)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: "v0.16.0"
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v2-cargo
# Only Cargo inputs are cached, so the host's stable registry/git
# cache is reusable even though rustc emits wasm objects via sccache.
shared-key: linux-stable-debug
cache-targets: false
save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
# A portability gate, not a deliverable: nothing here is built for the
# browser. `wasm32-unknown-unknown` has no OS under it, so a crate that
# picks up a filesystem, a randomness source or a thread stops compiling
# here and nowhere else. The crate list lives in xtask
# (`WASM_PORTABLE_CRATES`) and the drift test keeps the two in step.
- run: cargo check -p openlogi-device-registry -p openlogi-hidpp -p openlogi-device --target wasm32-unknown-unknown
# `openlogi-core` earns its place only with `fs` off: that feature is
# the config file, and a config file needs a filesystem.
- run: cargo check -p openlogi-core --no-default-features --target wasm32-unknown-unknown