@@ -19,7 +19,7 @@ name: "Rust checks"
1919on :
2020 pull_request :
2121 paths :
22- - " rs/**"
22+ - " rs/**" # TODO: Add python/handlebarrz after fixing linker errors.
2323 - " Cargo.toml"
2424 - " Cargo.lock"
2525 - " .github/workflows/rust.yml"
4141 - name : Checkout code
4242 uses : actions/checkout@v4
4343
44- - name : Install Rust toolchain (${{ matrix.toolchain }})
45- uses : dtolnay/rust-toolchain@master
46- with :
47- toolchain : ${{ matrix.toolchain }}
48-
4944 - name : Cache Cargo registry and index
5045 uses : actions/cache@v4
5146 with :
6863 continue-on-error : ${{ matrix.toolchain == 'nightly' }}
6964
7065 - name : Run tests
66+ env :
67+ RUST_BACKTRACE : 1
7168 run : cargo test --all-targets --workspace
7269 # Allow nightly tests to fail
7370 continue-on-error : ${{ matrix.toolchain == 'nightly' }}
71+
72+ check-build-test-musl-matrix :
73+ name : Check, Build & Test (${{ matrix.toolchain }}, alpine-${{ matrix.arch }}-musl)
74+ runs-on : ubuntu-latest # Runner OS
75+ container : # Run steps inside this container
76+ image : rust:alpine # Use official Rust image based on Alpine (multi-arch)
77+ strategy :
78+ fail-fast : false
79+ matrix :
80+ include :
81+ - arch : x86_64
82+ target : x86_64-unknown-linux-musl
83+ - arch : aarch64
84+ target : aarch64-unknown-linux-musl
85+ toolchain : [stable, nightly]
86+ steps :
87+ - name : Checkout code
88+ uses : actions/checkout@v4
89+
90+ - name : Install musl build dependencies
91+ run : |
92+ apk add --no-cache musl-dev gcc bash docker-cli
93+
94+ - name : Set up QEMU
95+ uses : docker/setup-qemu-action@v3
96+
97+ - name : Install Rust toolchain (${{ matrix.toolchain }}) via rustup
98+ shell : bash
99+ run : |
100+ # Determine host triple based on architecture
101+ if [ "${{ matrix.arch }}" == "aarch64" ]; then
102+ HOST_TRIPLE="aarch64-unknown-linux-musl"
103+ else
104+ HOST_TRIPLE="x86_64-unknown-linux-musl"
105+ fi
106+
107+ echo "Setting default host: ${HOST_TRIPLE}"
108+ rustup set default-host ${HOST_TRIPLE}
109+
110+ echo "Installing toolchain: ${{ matrix.toolchain }} for host ${HOST_TRIPLE}"
111+ # Install the toolchain for the determined host, add the target, use minimal profile
112+ rustup toolchain install ${{ matrix.toolchain }} --profile minimal --target ${{ matrix.target }}
113+ rustup default ${{ matrix.toolchain }}
114+
115+ # Add target again just in case (should be included by toolchain install)
116+ # rustup target add ${{ matrix.target }}
117+
118+ echo "Rust toolchain info:"
119+ rustc --version --verbose
120+ cargo --version --verbose
121+
122+ - name : Cache Cargo registry and index (musl)
123+ uses : actions/cache@v4
124+ with :
125+ path : |
126+ /usr/local/cargo/registry/index/
127+ /usr/local/cargo/registry/cache/
128+ /usr/local/cargo/git/db/
129+ target/
130+ # Include architecture and toolchain in cache key
131+ key : linux-musl-${{ matrix.arch }}-cargo-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}
132+
133+ - name : Check code (musl, ${{ matrix.arch }}, ${{ matrix.toolchain }})
134+ shell : bash
135+ run : cargo check --all-targets --workspace --target ${{ matrix.target }}
136+ # Allow nightly check to fail
137+ continue-on-error : ${{ matrix.toolchain == 'nightly' }}
138+
139+ - name : Build code (musl, ${{ matrix.arch }}, ${{ matrix.toolchain }})
140+ shell : bash
141+ run : cargo build --all-targets --workspace --target ${{ matrix.target }}
142+ # Allow nightly build to fail
143+ continue-on-error : ${{ matrix.toolchain == 'nightly' }}
144+
145+ - name : Run tests (musl, ${{ matrix.arch }}, ${{ matrix.toolchain }})
146+ shell : bash
147+ env :
148+ RUST_BACKTRACE : 1 # Keep the backtrace env var
149+ run : cargo test --all-targets --workspace --target ${{ matrix.target }}
150+ # Allow nightly tests to fail
151+ continue-on-error : ${{ matrix.toolchain == 'nightly' }}
0 commit comments