| 1 |
name: CI |
| 2 |
on: [push, pull_request] |
| 3 |
|
| 4 |
env: |
| 5 |
RUSTDOCFLAGS: -D warnings |
| 6 |
RUSTFLAGS: -D warnings |
| 7 |
|
| 8 |
jobs: |
| 9 |
clippy: |
| 10 |
name: clippy |
| 11 |
runs-on: ubuntu-latest |
| 12 |
steps: |
| 13 |
- uses: actions/checkout@v4 |
| 14 |
- name: Install Rust |
| 15 |
run: | |
| 16 |
rustup update beta --no-self-update |
| 17 |
rustup default beta |
| 18 |
rustup component add clippy |
| 19 |
- uses: Swatinem/rust-cache@v2 |
| 20 |
- run: cargo clippy --all-features --all-targets -- -D warnings |
| 21 |
|
| 22 |
test: |
| 23 |
name: Test |
| 24 |
runs-on: ${{ matrix.os }} |
| 25 |
strategy: |
| 26 |
matrix: |
| 27 |
os: [ubuntu-latest, macos-latest, windows-latest] |
| 28 |
rust: ["1.70", stable, beta, nightly] |
| 29 |
steps: |
| 30 |
- uses: actions/checkout@v4 |
| 31 |
- name: Install Rust |
| 32 |
run: | |
| 33 |
rustup update ${{ matrix.rust }} --no-self-update |
| 34 |
rustup default ${{ matrix.rust }} |
| 35 |
- uses: Swatinem/rust-cache@v2 |
| 36 |
- run: cargo test |
| 37 |
- name: Integration test |
| 38 |
run: cargo test --manifest-path test-crate/Cargo.toml |
| 39 |
|
| 40 |
cross_compile_test: |
| 41 |
name: Test Cross Compile - ${{ matrix.platform.target }} |
| 42 |
needs: [ test ] |
| 43 |
runs-on: ubuntu-latest |
| 44 |
strategy: |
| 45 |
fail-fast: false |
| 46 |
matrix: |
| 47 |
platform: |
| 48 |
# Testable |
| 49 |
- target: aarch64-unknown-linux-gnu |
| 50 |
test: true |
| 51 |
- target: arm-unknown-linux-gnueabihf |
| 52 |
test: true |
| 53 |
- target: powerpc-unknown-linux-gnu |
| 54 |
test: true |
| 55 |
- target: s390x-unknown-linux-gnu |
| 56 |
test: true |
| 57 |
- target: x86_64-unknown-linux-musl |
| 58 |
test: true |
| 59 |
- target: aarch64-unknown-linux-musl |
| 60 |
test: true |
| 61 |
# Build only |
| 62 |
- target: x86_64-pc-solaris |
| 63 |
test: false |
| 64 |
- target: x86_64-pc-windows-gnu |
| 65 |
test: false |
| 66 |
# FIXME: build fails, see <https://github.com/rust-lang/cmake-rs/issues/211> |
| 67 |
# - target: x86_64-unknown-freebsd |
| 68 |
# test: false |
| 69 |
- target: x86_64-unknown-netbsd |
| 70 |
test: false |
| 71 |
- target: x86_64-unknown-illumos |
| 72 |
test: false |
| 73 |
steps: |
| 74 |
- uses: actions/checkout@main |
| 75 |
- name: Install Rust |
| 76 |
run: | |
| 77 |
rustup update stable --no-self-update |
| 78 |
rustup default stable |
| 79 |
rustup target add ${{ matrix.platform.target }} |
| 80 |
- uses: taiki-e/install-action@v2 |
| 81 |
with: |
| 82 |
tool: cross |
| 83 |
- uses: Swatinem/rust-cache@v2 |
| 84 |
- name: cross test |
| 85 |
run: cross test -vv --target ${{ matrix.platform.target }} |
| 86 |
working-directory: test-crate |
| 87 |
if: ${{ matrix.platform.test }} |
| 88 |
- name: cross build |
| 89 |
run: cross build -vv --target ${{ matrix.platform.target }} |
| 90 |
working-directory: test-crate |
| 91 |
if: ${{ !matrix.platform.test }} |
| 92 |
|
| 93 |
ios_cross_compile_test: |
| 94 |
name: Test Cross Compile - ${{ matrix.platform.target }} |
| 95 |
needs: [ test ] |
| 96 |
runs-on: macos-latest |
| 97 |
strategy: |
| 98 |
fail-fast: false |
| 99 |
matrix: |
| 100 |
platform: |
| 101 |
- target: aarch64-apple-ios |
| 102 |
steps: |
| 103 |
- uses: actions/checkout@v4 |
| 104 |
- name: Install Rust |
| 105 |
run: | |
| 106 |
rustup update stable --no-self-update |
| 107 |
rustup default stable |
| 108 |
rustup target add ${{ matrix.platform.target }} |
| 109 |
- uses: Swatinem/rust-cache@v2 |
| 110 |
- name: build |
| 111 |
run: cargo build -vv --target ${{ matrix.platform.target }} |
| 112 |
working-directory: test-crate |
| 113 |
env: |
| 114 |
# If this isn't specified the default is iOS 7, for which zlib-ng will not compile due to the lack of thread-local storage. |
| 115 |
IPHONEOS_DEPLOYMENT_TARGET: 16 |
| 116 |
|
| 117 |
rustfmt: |
| 118 |
name: Rustfmt |
| 119 |
runs-on: ubuntu-latest |
| 120 |
steps: |
| 121 |
- uses: actions/checkout@main |
| 122 |
- name: Install Rust |
| 123 |
run: | |
| 124 |
rustup update stable --no-self-update |
| 125 |
rustup default stable |
| 126 |
rustup component add rustfmt |
| 127 |
- run: cargo fmt --all -- --check |
| 128 |
|
| 129 |
doc: |
| 130 |
name: docs |
| 131 |
runs-on: ubuntu-latest |
| 132 |
steps: |
| 133 |
- uses: actions/checkout@v4 |
| 134 |
- run: | |
| 135 |
rustup update nightly --no-self-update |
| 136 |
rustup default nightly |
| 137 |
- uses: Swatinem/rust-cache@v2 |
| 138 |
- run: cargo doc |
| 139 |
|
| 140 |
msrv: |
| 141 |
name: MSRV check |
| 142 |
runs-on: ubuntu-24.04 |
| 143 |
timeout-minutes: 10 |
| 144 |
env: |
| 145 |
RUSTFLAGS: # No need to check warnings on old MSRV, unset `-Dwarnings` |
| 146 |
steps: |
| 147 |
- uses: actions/checkout@main |
| 148 |
- name: Install Rust |
| 149 |
run: | |
| 150 |
msrv="$( |
| 151 |
cargo metadata --format-version=1 | |
| 152 |
jq -r '.packages[] | select(.name == "cmake") | .rust_version' |
| 153 |
)" |
| 154 |
echo "MSRV: $msrv" |
| 155 |
rustup update "$msrv" --no-self-update && rustup default "$msrv" |
| 156 |
- uses: Swatinem/rust-cache@v2 |
| 157 |
- run: cargo check |
| 158 |
|
| 159 |
success: |
| 160 |
needs: |
| 161 |
- clippy |
| 162 |
- test |
| 163 |
- cross_compile_test |
| 164 |
- ios_cross_compile_test |
| 165 |
- rustfmt |
| 166 |
- doc |
| 167 |
- msrv |
| 168 |
runs-on: ubuntu-latest |
| 169 |
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency |
| 170 |
# failed" as success. So we have to do some contortions to ensure the job fails if any of its |
| 171 |
# dependencies fails. |
| 172 |
if: always() # make sure this is never "skipped" |
| 173 |
steps: |
| 174 |
# Manually check the status of all dependencies. `if: failure()` does not work. |
| 175 |
- name: check if any dependency failed |
| 176 |
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' |