-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (166 loc) · 5.32 KB
/
Copy pathci.yml
File metadata and controls
176 lines (166 loc) · 5.32 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
# CI: fmt / clippy / test / build across the workspace.
#
# Triggered on PRs + pushes to main. Fast path (fmt/clippy) fails
# first — no point running the full build if formatting is off.
#
# Cost: ~4-6 min per run on ubuntu-latest with dependency caching.
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: # manual trigger for post-migration sanity + ad-hoc reruns
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
RUST_BACKTRACE: short
jobs:
fmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain (stable + rustfmt)
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: cargo fmt --all --check
run: cargo fmt --all --check
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain (stable + clippy)
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install libudev (Linux serialport dep)
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ci-clippy-${{ hashFiles('Cargo.lock') }}
- name: clippy (default features)
run: cargo clippy --all-targets -- -D warnings
- name: clippy (--features tui)
run: cargo clippy --features tui --all-targets -- -D warnings
test:
name: test (${{ matrix.name }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: default-features
features: ""
- name: tui
features: "--features tui"
- name: no-default
features: "--no-default-features"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install libudev
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ci-test-${{ matrix.name }}-${{ hashFiles('Cargo.lock') }}
- name: cargo test
run: cargo test ${{ matrix.features }} --workspace
build:
name: release build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install libudev (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ci-build-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}
- name: cargo build --release --features tui
# RUSTFLAGS=-D warnings above → any warning breaks the build.
run: cargo build --release --features tui
audit:
name: cargo audit + deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo install --locked cargo-audit
- name: cargo audit
# Non-blocking for now (warns on advisories, doesn't fail CI).
# Flip to `cargo audit --deny warnings` once we've triaged the
# baseline.
run: cargo audit || true
- name: Install cargo-deny
run: cargo install --locked cargo-deny
- name: cargo deny check
# deny.toml enforces our supply-chain policy: license
# allowlist, wildcard-dep policy, duplicate skiplist,
# crates.io-only sources. Blocking — any new dep with an
# unknown license or from an unallowed source fails CI.
run: cargo deny check
msrv:
name: MSRV (rust-version) build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract rust-version from Cargo.toml
id: msrv
run: |
v=$(grep -oP '^rust-version = "\K[^"]+' Cargo.toml | head -1)
echo "version=$v" >> "$GITHUB_OUTPUT"
echo "MSRV declared: $v"
- name: Install pinned toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.msrv.outputs.version }}
- name: Install libudev
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ci-msrv-${{ steps.msrv.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- name: cargo build (MSRV)
# Proves rust-version = "X.Y" in Cargo.toml is actually true.
# Users doing `cargo install --locked` on the declared MSRV
# get a real build, not a "method not found" surprise.
run: cargo build --features tui