-
Notifications
You must be signed in to change notification settings - Fork 11
238 lines (207 loc) · 8.29 KB
/
ci.yml
File metadata and controls
238 lines (207 loc) · 8.29 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
name: CI
on:
push:
branches: [master, main, develop]
pull_request:
branches: [master, main]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# Nightly multithreaded frontend for faster compilation (32 threads for 32 vCPU runners)
RUSTFLAGS: "-Zthreads=32"
# Sparse registry for faster index updates
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# Incremental compilation off for CI (more reproducible, better caching)
CARGO_INCREMENTAL: 0
# Ensure only one CI run per branch at a time - prevents overloading when many PRs merge
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ==========================================================================
# Version consistency check (lightweight - 4 vCPU)
# ==========================================================================
version-check:
name: CLI Version Check
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- name: Verify CLI version consistency
run: ./scripts/check-cli-version.sh
# ==========================================================================
# Setup job to prepare shared cache (lightweight - 4 vCPU)
# ==========================================================================
setup-cache:
name: Setup Cache
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- uses: actions/checkout@v4
- name: Generate cache key
id: cache-key
run: |
echo "key=rust-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}" >> $GITHUB_OUTPUT
# ==========================================================================
# Fast checks (fmt, clippy) - Run in parallel
# ==========================================================================
fmt:
name: Format
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Check formatting
run: cargo +nightly fmt --all -- --check
clippy:
name: Clippy
runs-on: blacksmith-32vcpu-ubuntu-2404
needs: setup-cache
steps:
- uses: actions/checkout@v4
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libglib2.0-dev libasound2-dev
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- name: Setup Rust cache (Blacksmith optimized)
uses: useblacksmith/rust-cache@v3
with:
prefix-key: "rust-clippy"
shared-key: ${{ needs.setup-cache.outputs.cache-key }}
- name: Run clippy
run: cargo +nightly clippy --workspace --all-targets --all-features -- -D warnings
# ==========================================================================
# Test jobs - Matrix for all platforms (32 vCPU for compilation)
# ==========================================================================
test:
name: Test (${{ matrix.name }})
runs-on: ${{ matrix.runner }}
needs: setup-cache
strategy:
fail-fast: false
matrix:
include:
- name: ubuntu
runner: blacksmith-32vcpu-ubuntu-2404
- name: macos
runner: macos-latest
- name: windows
runner: blacksmith-32vcpu-windows-2025
steps:
- uses: actions/checkout@v4
- name: Install Linux dependencies
if: matrix.name == 'ubuntu'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libglib2.0-dev libasound2-dev
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Setup Rust cache (Blacksmith optimized)
if: contains(matrix.runner, 'blacksmith')
uses: useblacksmith/rust-cache@v3
with:
prefix-key: "rust-test-${{ matrix.name }}"
shared-key: ${{ needs.setup-cache.outputs.cache-key }}
- name: Setup Rust cache (non-Blacksmith)
if: "!contains(matrix.runner, 'blacksmith')"
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust-test"
shared-key: "${{ matrix.name }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}"
- name: Run tests
run: cargo +nightly test --workspace --all-features
env:
RUSTFLAGS: "-Zthreads=32"
# ==========================================================================
# Build check - All platforms (32 vCPU for compilation)
# ==========================================================================
build-check:
name: Build Check (${{ matrix.name }})
runs-on: ${{ matrix.runner }}
needs: setup-cache
strategy:
fail-fast: false
matrix:
include:
- name: ubuntu
runner: blacksmith-32vcpu-ubuntu-2404
- name: macos
runner: macos-latest
- name: windows
runner: blacksmith-32vcpu-windows-2025
steps:
- uses: actions/checkout@v4
- name: Install Linux dependencies
if: matrix.name == 'ubuntu'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libglib2.0-dev libasound2-dev
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Setup Rust cache (Blacksmith optimized)
if: contains(matrix.runner, 'blacksmith')
uses: useblacksmith/rust-cache@v3
with:
prefix-key: "rust-build-${{ matrix.name }}"
shared-key: ${{ needs.setup-cache.outputs.cache-key }}
- name: Setup Rust cache (non-Blacksmith)
if: "!contains(matrix.runner, 'blacksmith')"
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust-build"
shared-key: "${{ matrix.name }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}"
- name: Check build
run: cargo +nightly check --workspace --all-features
env:
RUSTFLAGS: "-Zthreads=32"
# ==========================================================================
# Security Audit (lightweight - 4 vCPU)
# ==========================================================================
audit:
name: Security Audit
runs-on: blacksmith-4vcpu-ubuntu-2404
# Continue on error - vulnerabilities are tracked via GitHub issues, not CI failures
continue-on-error: true
permissions:
contents: read
issues: write
# Override global RUSTFLAGS - the -Zthreads flag is nightly-only and breaks cargo-audit installation on stable
env:
RUSTFLAGS: ""
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
# Known RUSTSEC advisories are configured in .cargo/audit.toml
# See that file for detailed explanations of each exception
- uses: actions-rust-lang/audit@v1
name: Audit Rust Dependencies
# ==========================================================================
# Final status check (for branch protection) - lightweight - 4 vCPU
# ==========================================================================
ci-success:
name: CI Success
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: [version-check, fmt, clippy, test, build-check, audit]
if: always()
steps:
- name: Check all jobs
run: |
# Note: audit job uses continue-on-error, so we don't check it here
# Security vulnerabilities are tracked via GitHub issues instead
if [[ "${{ needs.version-check.result }}" == "failure" || \
"${{ needs.fmt.result }}" == "failure" || \
"${{ needs.clippy.result }}" == "failure" || \
"${{ needs.test.result }}" == "failure" || \
"${{ needs.build-check.result }}" == "failure" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All CI checks passed!"