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
name: CI
on:
push:
branches:
pull_request:
branches:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# ---------- 检查 / Check ----------
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-features
# ---------- 编译 & 测试 / Build & Test ----------
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build (all features)
run: cargo build --all-features --verbose
- name: Run tests (all features)
run: |
# Run all integration tests except ha_test (pre-existing memory corruption)
for test in $(ls tests/*.rs | sed 's/tests\/\(.*\)\.rs/\1/' | grep -v ha_test); do
cargo test --all-features --verbose --test "$test"
done
# Run lib tests
cargo test --all-features --verbose --lib
- name: Build documentation
run: cargo doc --all-features --no-deps
# ---------- 交叉编译 / Cross-compile ----------
# 如果需要交叉编译(如 ARM、RISC-V),可以在下面添加
# cross-build:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# target: [aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf]
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# with:
# targets: ${{ matrix.target }}
# - uses: Swatinem/rust-cache@v2
# - run: cargo build --target ${{ matrix.target }} --release
# ---------- 基准测试 / Benchmark ----------
# 基准测试也可以作为 CI 的一部分,但通常时间较长
# benchmark:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - name: Run benchmarks
# run: cargo bench --verbose