-
Notifications
You must be signed in to change notification settings - Fork 1
306 lines (265 loc) · 10.4 KB
/
ci.yml
File metadata and controls
306 lines (265 loc) · 10.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
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
- 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 --exclude cortex-gui -- -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
- 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: "rust-test-${{ matrix.name }}"
shared-key: ${{ needs.setup-cache.outputs.cache-key }}
- name: Run tests
run: cargo +nightly test --workspace --all-features --exclude cortex-gui
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
- 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: "rust-build-${{ matrix.name }}"
shared-key: ${{ needs.setup-cache.outputs.cache-key }}
- name: Check build
run: cargo +nightly check --workspace --all-features --exclude cortex-gui
env:
RUSTFLAGS: "-Zthreads=32"
# ==========================================================================
# GUI Check - All platforms (32 vCPU for compilation)
# ==========================================================================
gui-check:
name: GUI 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
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: cortex-gui/package-lock.json
- 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
- name: Cache npm (Blacksmith 4x faster cache)
uses: actions/cache@v4
with:
path: |
cortex-gui/node_modules
~/.npm
key: npm-${{ matrix.name }}-${{ hashFiles('cortex-gui/package-lock.json') }}
restore-keys: |
npm-${{ matrix.name }}-
- name: Install frontend dependencies
working-directory: cortex-gui
run: npm ci
- name: Build frontend
working-directory: cortex-gui
run: npm run build
- 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-gui-${{ 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: "rust-gui-${{ matrix.name }}"
shared-key: ${{ needs.setup-cache.outputs.cache-key }}
- name: Check GUI build
run: cargo +nightly check -p cortex-gui
env:
RUSTFLAGS: "-Zthreads=32"
# ==========================================================================
# Security Audit (lightweight - 4 vCPU)
# ==========================================================================
audit:
name: Security Audit
runs-on: blacksmith-4vcpu-ubuntu-2404
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
- 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, gui-check, audit]
if: always()
steps:
- name: Check all jobs
run: |
if [[ "${{ needs.version-check.result }}" == "failure" || \
"${{ needs.fmt.result }}" == "failure" || \
"${{ needs.clippy.result }}" == "failure" || \
"${{ needs.test.result }}" == "failure" || \
"${{ needs.build-check.result }}" == "failure" || \
"${{ needs.gui-check.result }}" == "failure" || \
"${{ needs.audit.result }}" == "failure" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All CI checks passed!"