@@ -85,12 +85,14 @@ jobs:
8585 name : Build and Test
8686 runs-on : ${{ matrix.os }}
8787 strategy :
88+ fail-fast : false
8889 matrix :
8990 os : [ubuntu-latest, macos-latest, windows-latest]
9091 php : ["8.0", "8.1", "8.2", "8.3", "8.4"]
9192 rust : [stable, nightly]
9293 clang : ["15", "17"]
9394 phpts : [ts, nts]
95+ target : [gnu, musl]
9496 exclude :
9597 # ext-php-rs requires nightly Rust when on Windows.
9698 - os : windows-latest
@@ -101,11 +103,26 @@ jobs:
101103 clang : " 15"
102104 - os : windows-latest
103105 clang : " 15"
106+ # musl only supported on Linux with stable Rust
107+ - os : windows-latest
108+ target : musl
109+ - os : macos-latest
110+ target : musl
111+ - target : musl
112+ rust : nightly
113+ # Skip PHP 8.0 for musl (EOL)
114+ - target : musl
115+ php : " 8.0"
104116 env :
105117 CARGO_TERM_COLOR : always
106118 steps :
107119 - name : Checkout code
108120 uses : actions/checkout@v5
121+ - name : Install musl toolchain
122+ if : matrix.target == 'musl'
123+ run : |
124+ sudo apt-get update
125+ sudo apt-get install -y musl-tools musl-dev
109126 - name : Setup PHP
110127 uses : shivammathur/setup-php@v2
111128 with :
@@ -118,6 +135,9 @@ jobs:
118135 with :
119136 toolchain : ${{ matrix.rust }}
120137 components : rustfmt, clippy
138+ - name : Add musl target
139+ if : matrix.target == 'musl'
140+ run : rustup target add x86_64-unknown-linux-musl
121141 - run : rustup show
122142 - name : Cache cargo dependencies
123143 uses : Swatinem/rust-cache@v2
@@ -162,12 +182,15 @@ jobs:
162182 - name : Build
163183 env :
164184 EXT_PHP_RS_TEST : " "
165- run : cargo build --release --features closure,anyhow,runtime --workspace ${{ matrix.php == '8.0' && '--no-default-features' || '' }}
185+ RUSTFLAGS : ${{ matrix.target == 'musl' && '-C target-feature=-crt-static' || '' }}
186+ run : cargo build --release --features closure,anyhow,runtime --workspace ${{ matrix.php == '8.0' && '--no-default-features' || '' }} ${{ matrix.target == 'musl' && '--target x86_64-unknown-linux-musl' || '' }}
166187 # Test
167188 - name : Test inline examples
168189 # Macos fails on unstable rust. We skip the inline examples test for now.
169190 if : " !(contains(matrix.os, 'macos') && matrix.rust == 'nightly')"
170- run : cargo test --release --workspace --features closure,anyhow,runtime --no-fail-fast ${{ matrix.php == '8.0' && '--no-default-features' || '' }}
191+ env :
192+ RUSTFLAGS : ${{ matrix.target == 'musl' && '-C target-feature=-crt-static' || '' }}
193+ run : cargo test --release --workspace --features closure,anyhow,runtime --no-fail-fast ${{ matrix.php == '8.0' && '--no-default-features' || '' }} ${{ matrix.target == 'musl' && '--target x86_64-unknown-linux-musl' || '' }}
171194 build-zts :
172195 name : Build with ZTS
173196 runs-on : ubuntu-latest
0 commit comments