| 1 |
name: Rust CI |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: [ main ] |
| 5 |
pull_request: |
| 6 |
branches: [ main ] |
| 7 |
jobs: |
| 8 |
build: |
| 9 |
runs-on: ubuntu-latest |
| 10 |
strategy: |
| 11 |
matrix: |
| 12 |
rust: ["1.74.0", stable, beta, nightly] |
| 13 |
steps: |
| 14 |
- uses: actions/checkout@v2 |
| 15 |
|
| 16 |
- uses: dtolnay/rust-toolchain@nightly |
| 17 |
if: ${{ matrix.rust == '1.74.0' }} |
| 18 |
- name: Generate Cargo.lock with minimal-version dependencies |
| 19 |
if: ${{ matrix.rust == '1.74.0' }} |
| 20 |
run: cargo -Zminimal-versions generate-lockfile |
| 21 |
|
| 22 |
- uses: dtolnay/rust-toolchain@v1 |
| 23 |
with: |
| 24 |
toolchain: ${{ matrix.rust }} |
| 25 |
- name: Cache Cargo Dependencies |
| 26 |
uses: Swatinem/rust-cache@v2 |
| 27 |
with: |
| 28 |
cache-on-failure: true |
| 29 |
- name: build |
| 30 |
run: cargo build -v |
| 31 |
- name: test |
| 32 |
if: ${{ matrix.rust != '1.74.0' }} |
| 33 |
run: cargo test -v && cargo doc -v |
| 34 |
|
| 35 |
features: |
| 36 |
runs-on: ubuntu-latest |
| 37 |
strategy: |
| 38 |
matrix: |
| 39 |
feature: ["", deflate, jpeg, lzw, zstd, default, "default,zstd"] |
| 40 |
steps: |
| 41 |
- uses: actions/checkout@v2 |
| 42 |
- uses: dtolnay/rust-toolchain@stable |
| 43 |
with: |
| 44 |
components: clippy |
| 45 |
- name: Cargo check |
| 46 |
run: cargo check --features "${{ matrix.feature }}" --no-default-features |
| 47 |
|
| 48 |
- name: Cargo clippy |
| 49 |
if: ${{ matrix.feature != '' }} |
| 50 |
run: cargo clippy --no-deps --all-features --all-targets -- -D warnings |
| 51 |
|
| 52 |
other_archs: |
| 53 |
# github actions does not support 32-bit or big endian systems directly, but |
| 54 |
# it does support QEMU. so we install qemu, then build and run the tests on |
| 55 |
# emulated systems. NOTE: you can also use this approach to test locally. |
| 56 |
runs-on: ubuntu-latest |
| 57 |
strategy: |
| 58 |
fail-fast: false |
| 59 |
matrix: |
| 60 |
arch: [powerpc-unknown-linux-gnu, i686-unknown-linux-gnu] |
| 61 |
steps: |
| 62 |
- uses: actions/checkout@v4 |
| 63 |
- name: Install or use cached cross-rs/cross |
| 64 |
uses: baptiste0928/cargo-install@v2 |
| 65 |
with: |
| 66 |
crate: cross |
| 67 |
- name: Cache Cargo Dependencies |
| 68 |
uses: Swatinem/rust-cache@v2 |
| 69 |
with: |
| 70 |
cache-on-failure: true |
| 71 |
key: ${{ matrix.arch }} |
| 72 |
- name: Start Docker (required for cross-rs) |
| 73 |
run: sudo systemctl start docker |
| 74 |
- name: Cross-Run Tests using QEMU |
| 75 |
run: cross test --target ${{ matrix.arch }} |
| 76 |
|
| 77 |
rustfmt: |
| 78 |
runs-on: ubuntu-latest |
| 79 |
steps: |
| 80 |
- uses: actions/checkout@v2 |
| 81 |
- uses: dtolnay/rust-toolchain@stable |
| 82 |
with: |
| 83 |
components: rustfmt |
| 84 |
- name: Run rustfmt check |
| 85 |
run: cargo fmt -- --check |
| 86 |
|
| 87 |
clippy: |
| 88 |
runs-on: ubuntu-latest |
| 89 |
steps: |
| 90 |
- uses: actions/checkout@v2 |
| 91 |
- uses: dtolnay/rust-toolchain@stable |
| 92 |
with: |
| 93 |
components: clippy |
| 94 |
- run: cargo clippy --all-features # TODO: enable "-- -D warnings" once all outstanding clippy lints are fixed |