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
name: Cross-platform CI
on:
push:
branches:
pull_request:
branches:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Job 1: Linux, Windows, macOS (x86_64 and ARM64)
test-mainstream:
name: ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
- os: windows-latest
arch: x86_64
- os: macos-15-intel # Intel x86_64
arch: x86_64
- os: macos-latest # Apple Silicon ARM64
arch: arm64
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --verbose
- name: Run Tests
run: cargo test --verbose -- --nocapture
# Job 2: FreeBSD (Runs in a VM on top of Linux)
test-freebsd:
name: FreeBSD (x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests in FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
usesh: true
prepare: |
pkg install -y rust
run: |
cargo test --verbose -- --nocapture
# Job 3: Linux ARM64 (Cross-compile check)
# This verifies that the code compiles for Linux on ARM.
# We use 'cross' to simplify cross-compilation.
test-linux-arm64:
name: Linux (ARM64 cross-compile)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-gnu
- name: Install cross
run: cargo install cross
- name: Build for ARM64
run: cross build --target aarch64-unknown-linux-gnu --verbose
# Note: Running tests for ARM64 on x86_64 requires QEMU via cross.
# If you want to actually run the tests:
- name: Run tests for ARM64
run: cross test --target aarch64-unknown-linux-gnu --verbose -- --nocapture