Skip to content

Commit 2411fae

Browse files
committed
ci: add full build matrix across all GitHub-hosted runners
1 parent 264e691 commit 2411fae

1 file changed

Lines changed: 160 additions & 13 deletions

File tree

.github/workflows/rust.yml

Lines changed: 160 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,173 @@
1-
name: Rust
1+
name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
8+
workflow_dispatch:
89

910
env:
1011
CARGO_TERM_COLOR: always
1112

1213
jobs:
14+
# ──────────────────────────────────────────────
15+
# Lint: rustfmt + clippy
16+
# ──────────────────────────────────────────────
17+
lint:
18+
name: Lint
19+
runs-on: ubuntu-24.04
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- uses: dtolnay/rust-toolchain@stable
26+
with:
27+
components: rustfmt, clippy
28+
29+
- uses: Swatinem/rust-cache@v2
30+
31+
- name: Check formatting
32+
run: cargo fmt --check
33+
34+
- name: Clippy
35+
run: cargo clippy -- -D warnings
36+
37+
# ──────────────────────────────────────────────
38+
# Native build + test matrix
39+
# 6 runners × 2 profiles = 12 jobs
40+
# ──────────────────────────────────────────────
1341
build:
42+
name: ${{ matrix.name }} (${{ matrix.profile }})
43+
runs-on: ${{ matrix.runner }}
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
include:
48+
# Linux x64
49+
- name: Linux x64
50+
runner: ubuntu-24.04
51+
target: x86_64-unknown-linux-gnu
52+
profile: debug
53+
- name: Linux x64
54+
runner: ubuntu-24.04
55+
target: x86_64-unknown-linux-gnu
56+
profile: release
1457

15-
runs-on: ubuntu-latest
58+
# Linux arm64
59+
- name: Linux arm64
60+
runner: ubuntu-24.04-arm
61+
target: aarch64-unknown-linux-gnu
62+
profile: debug
63+
- name: Linux arm64
64+
runner: ubuntu-24.04-arm
65+
target: aarch64-unknown-linux-gnu
66+
profile: release
67+
68+
# Windows x64
69+
- name: Windows x64
70+
runner: windows-latest
71+
target: x86_64-pc-windows-msvc
72+
profile: debug
73+
- name: Windows x64
74+
runner: windows-latest
75+
target: x86_64-pc-windows-msvc
76+
profile: release
77+
78+
# Windows arm64
79+
- name: Windows arm64
80+
runner: windows-11-arm
81+
target: aarch64-pc-windows-msvc
82+
profile: debug
83+
- name: Windows arm64
84+
runner: windows-11-arm
85+
target: aarch64-pc-windows-msvc
86+
profile: release
87+
88+
# macOS x64 (Intel)
89+
- name: macOS x64
90+
runner: macos-15-intel
91+
target: x86_64-apple-darwin
92+
profile: debug
93+
- name: macOS x64
94+
runner: macos-15-intel
95+
target: x86_64-apple-darwin
96+
profile: release
97+
98+
# macOS arm64 (Apple Silicon)
99+
- name: macOS arm64
100+
runner: macos-15
101+
target: aarch64-apple-darwin
102+
profile: debug
103+
- name: macOS arm64
104+
runner: macos-15
105+
target: aarch64-apple-darwin
106+
profile: release
16107

17108
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@v4
20-
with:
21-
submodules: recursive
22-
23-
- name: Build
24-
run: cargo build --verbose
25-
- name: Run tests
26-
run: cargo test --verbose
109+
- uses: actions/checkout@v4
110+
with:
111+
submodules: recursive
112+
113+
- uses: dtolnay/rust-toolchain@stable
114+
with:
115+
targets: ${{ matrix.target }}
116+
117+
- uses: Swatinem/rust-cache@v2
118+
with:
119+
key: ${{ matrix.target }}-${{ matrix.profile }}
120+
121+
# Linux: install libclang for bindgen
122+
- name: Install libclang (Linux)
123+
if: runner.os == 'Linux'
124+
run: sudo apt-get update && sudo apt-get install -y libclang-dev
125+
126+
- name: Build
127+
run: cargo build --target ${{ matrix.target }} --verbose ${{ matrix.profile == 'release' && '--release' || '' }}
128+
129+
- name: Test
130+
run: cargo test --target ${{ matrix.target }} --verbose ${{ matrix.profile == 'release' && '--release' || '' }}
131+
132+
# ──────────────────────────────────────────────
133+
# Cross-compilation via zigbuild (musl targets)
134+
# 2 targets × 2 profiles = 4 jobs
135+
# ──────────────────────────────────────────────
136+
cross:
137+
name: Cross ${{ matrix.target }} (${{ matrix.profile }})
138+
runs-on: ubuntu-24.04
139+
strategy:
140+
fail-fast: false
141+
matrix:
142+
include:
143+
- target: aarch64-unknown-linux-musl
144+
profile: debug
145+
- target: aarch64-unknown-linux-musl
146+
profile: release
147+
- target: x86_64-unknown-linux-musl
148+
profile: debug
149+
- target: x86_64-unknown-linux-musl
150+
profile: release
151+
152+
steps:
153+
- uses: actions/checkout@v4
154+
with:
155+
submodules: recursive
156+
157+
- uses: dtolnay/rust-toolchain@stable
158+
with:
159+
targets: ${{ matrix.target }}
160+
161+
- uses: mlugg/setup-zig@v2
162+
163+
- uses: Swatinem/rust-cache@v2
164+
with:
165+
key: cross-${{ matrix.target }}-${{ matrix.profile }}
166+
167+
- name: Install libclang and cargo-zigbuild
168+
run: |
169+
sudo apt-get update && sudo apt-get install -y libclang-dev
170+
cargo install cargo-zigbuild
171+
172+
- name: Build (zigbuild)
173+
run: cargo zigbuild --target ${{ matrix.target }} --verbose ${{ matrix.profile == 'release' && '--release' || '' }}

0 commit comments

Comments
 (0)