-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (82 loc) · 2.24 KB
/
rust-ci.yml
File metadata and controls
100 lines (82 loc) · 2.24 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
name: Rust CI
on:
push:
branches: [ main ]
paths:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/rust-ci.yml'
- '.github/actions/**'
pull_request:
branches: [ main ]
paths:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/rust-ci.yml'
- '.github/actions/**'
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
rust-test:
name: Rust Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
components: rustfmt, clippy
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run Rust tests
run: cargo test --verbose
- name: Build library
run: cargo build --release
cross-compile:
name: Cross compile ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux GNU targets
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
# Linux MUSL targets
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
# macOS targets
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
# Windows targets
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
targets: ${{ matrix.target }}
cache-key-suffix: ${{ matrix.target }}
- name: Setup cross-compilation
if: matrix.os == 'ubuntu-latest'
uses: ./.github/actions/setup-cross-compilation
- name: Build Rust library
uses: ./.github/actions/build-rust-library
with:
target: ${{ matrix.target }}
# use-cross defaults to 'auto' which automatically uses cross on Linux