CI improvements #897
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust CI | |
on: | |
push: | |
branches: [ master, main, next ] | |
pull_request: | |
branches: [ master, main, next ] | |
jobs: | |
build: | |
name: Run tests and doctests on ubuntu | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust: [stable] | |
features: ['', default, gif, jpeg, png, tiff, ico, pnm, tga, webp, bmp, hdr, dxt, dds, farbfeld, openexr, jpeg_rayon, webp-encoder] | |
include: | |
- rust: beta | |
features: ['', default, webp, webp-encoder] | |
- rust: nightly | |
features: ['', default, webp, webp-encoder] | |
- rust: "1.61.0" | |
features: ['', default, webp, webp-encoder] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Cache Cargo Dependencies | |
uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
- name: Install MSRV Cargo.lock | |
if: ${{ matrix.rust == '1.61.0' }} | |
run: mv Cargo.lock.msrv Cargo.lock | |
- name: build | |
run: cargo build -v --no-default-features --features "$FEATURES" | |
env: | |
FEATURES: ${{ matrix.features }} | |
- name: test | |
if: ${{ matrix.rust == 'stable' || matrix.rust == 'beta' || matrix.rust == 'nightly' }} | |
run: > | |
cargo test -v --no-default-features --features "$FEATURES" && | |
cargo doc -v --no-default-features --features "$FEATURES" | |
env: | |
FEATURES: ${{ matrix.features }} | |
build_big_endian: | |
name: Run tests on big endian architecture | |
# github actions does not support big endian systems directly, but it does support QEMU. | |
# so we install qemu, then build and run the tests in an emulated mips system. | |
# note: you can also use this approach to test for big endian locally. | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
features: ['', default, webp, webp-encoder] | |
# we are using the cross project for cross compilation to mips: | |
# https://github.com/cross-rs/cross | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install or use cached cross-rs/cross | |
uses: baptiste0928/cargo-install@v1 | |
with: | |
crate: cross | |
- name: Cache Cargo Dependencies | |
uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
- name: Start Docker (required for cross-rs) | |
run: sudo systemctl start docker | |
- name: Cross-Compile project to mips-unknown-linux-gnu | |
run: | | |
cross build --target=mips-unknown-linux-gnu --verbose -v --no-default-features --features "$FEATURES" | |
env: | |
FEATURES: ${{ matrix.features }} | |
# https://github.com/cross-rs/cross#supported-targets | |
- name: Cross-Run Tests in mips-unknown-linux-gnu using Qemu | |
continue-on-error: true | |
run: | | |
cross test --target mips-unknown-linux-gnu --verbose -v --no-default-features --features "$FEATURES" | |
env: | |
FEATURES: ${{ matrix.features }} | |
test_defaults: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: build | |
run: cargo build -v --release | |
- name: test | |
run: cargo test -v --release | |
test_avif: | |
runs-on: ubuntu-latest | |
steps: | |
- name: install-dependencies | |
run: sudo apt update && sudo apt install nasm | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: build | |
run: cargo build -v --no-default-features --features="avif" | |
test_avif_decoding: | |
runs-on: ubuntu-latest | |
steps: | |
- name: install-dependencies | |
run: sudo apt update && sudo apt install ninja-build meson nasm | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: build | |
run: cargo build -v --no-default-features --features="avif-decoder" | |
env: | |
SYSTEM_DEPS_DAV1D_BUILD_INTERNAL: always | |
clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: install-dependencies | |
run: sudo apt update && sudo apt install ninja-build meson nasm | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
- run: cargo clippy --all-features -- -D warnings | |
env: | |
SYSTEM_DEPS_DAV1D_BUILD_INTERNAL: always | |
build_fuzz_afl: | |
name: "Fuzz targets (afl)" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@nightly | |
- name: install-deps | |
run: sudo apt-get -y install clang llvm | |
- name: build | |
run: | | |
cargo install afl | |
cd fuzz-afl | |
cargo check --bin reproduce_webp | |
cargo check --bin reproduce_pnm | |
cargo afl check --bin fuzz_webp | |
cargo afl check --bin fuzz_pnm | |
env: | |
RUSTFLAGS: "" | |
build_fuzz_cargo-fuzz: | |
name: "Fuzz targets (cargo-fuzz)" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@nightly | |
- name: build | |
run: | | |
cargo install cargo-fuzz | |
cargo fuzz build | |
- name: fuzz | |
run: | | |
for format in $(cargo fuzz list); do | |
cargo fuzz run "$format" -- -runs=0; | |
done | |
public_private_dependencies: | |
name: "Public private dependencies" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@nightly | |
- name: build | |
run: | | |
mv ./Cargo.toml.public-private-dependencies ./Cargo.toml | |
echo "#![deny(exported_private_dependencies)]" | cat - src/lib.rs > src/lib.rs.0 | |
mv src/lib.rs.0 src/lib.rs | |
cargo check | |
build_benchmarks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@nightly | |
- name: build | |
run: cargo build -v --benches --features=benchmarks | |
rustfmt: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: Run rustfmt check | |
run: cargo fmt -- --check | |
cargo-deny: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: EmbarkStudios/cargo-deny-action@v1 | |
verify_msrv: | |
name: Verify Minimum Supported Rust Version in Cargo.toml | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install or use cached `cargo-msrv` | |
uses: baptiste0928/cargo-install@v1 | |
with: | |
crate: cargo-msrv | |
- name: Install MSRV Cargo.lock | |
run: mv Cargo.lock.msrv Cargo.lock | |
- name: Verify Minimum Rust Version | |
run: cargo-msrv verify |