Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
name: Rust CI

on:
workflow_call:
inputs:
# What MSRV to use for the tests.
msrv:
required: true
type: string

# The list of feature combinations to test, as a JSON array.
features:
required: false
type: string
default: '["default"]'

# Whether to build cargo-fuzz targets.
cargo-fuzz:
required: false
type: boolean
default: false

# An optional extra feature to enable for benchmarks.
benchmark-feature:
required: false
type: string
default: ""

# List of dependencies to pin to specific versions when generating the Cargo.lock file for the MSRV.
msrv-pinned-dependencies:
required: false
type: string
default: '[]'

jobs:
test_features:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features: ${{ fromJSON(inputs.features) }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: build
run: cargo build -v --no-default-features --features "$FEATURES"
env:
FEATURES: ${{ matrix.features }}
- name: test
run: >
cargo test -v --no-default-features --features "$FEATURES" &&
cargo doc -v --no-default-features --features "$FEATURES"
env:
FEATURES: ${{ matrix.features }}

test_toolchains:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust:
- ${{ inputs.msrv }}
- nightly
- beta
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@nightly
if: ${{ matrix.rust == inputs.msrv }}
- name: Generate Cargo.lock with minimal-version dependencies
if: ${{ matrix.rust == inputs.msrv }}
run: |
cargo -Zminimal-versions generate-lockfile
echo '${{ inputs.msrv-pinned-dependencies }}' | jq -r '.[]' | while IFS= read -r dep; do
package_name=$(echo "$dep" | cut -d'@' -f1)
version=$(echo "$dep" | cut -d'@' -f2)
cargo update --precise "$version" "$package_name"
done

- uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: build
run: cargo build -v
- name: test
if: ${{ matrix.rust != inputs.msrv }}
run: cargo test -v && cargo doc -v

test_other_archs:
# github actions does not support 32-bit or 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:
fail-fast: false
matrix:
arch: [powerpc64-unknown-linux-gnu, i686-unknown-linux-gnu]
steps:
- uses: actions/checkout@v4
- name: Install or use cached cross-rs/cross
uses: baptiste0928/cargo-install@v2
with:
crate: cross
- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: ${{ matrix.arch }}
- name: Start Docker (required for cross-rs)
run: sudo systemctl start docker
- name: Cross-Run Tests using QEMU
run: cross test --target ${{ matrix.arch }}

clippy:
runs-on: ubuntu-latest
steps:
- name: install-dependencies
run: sudo apt update && sudo apt install ninja-build meson nasm
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- run: cargo clippy --all-features --all-targets -- -D warnings
env:
SYSTEM_DEPS_DAV1D_BUILD_INTERNAL: always

rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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@v4
- uses: EmbarkStudios/cargo-deny-action@v2

cargo-semver-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: obi1kenobi/cargo-semver-checks-action@v2
with:
feature-group: default-features
release-type: minor

build_benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: build
run: cargo build -v --benches --features="${{ inputs.benchmarks-feature }}"

build_fuzz_cargo-fuzz:
name: "Fuzz targets (cargo-fuzz)"
runs-on: ubuntu-latest
if: ${{ inputs.cargo-fuzz }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-fuzz
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-fuzz
- name: check
run: cargo fuzz check
env:
CARGO_INCREMENTAL: 0
152 changes: 8 additions & 144 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,14 @@ on:
- cron: '5 16 * * 6'

jobs:
test_features:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features: ['', default, rayon, avif, bmp, dds, exr, ff, gif, hdr, ico, jpeg, png, pnm, qoi, tga, tiff, webp]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: build
run: cargo build -v --no-default-features --features "$FEATURES"
env:
FEATURES: ${{ matrix.features }}
- name: test
run: >
cargo test -v --no-default-features --features "$FEATURES" &&
cargo doc -v --no-default-features --features "$FEATURES"
env:
FEATURES: ${{ matrix.features }}

test_toolchains:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: ["1.74.0", nightly, beta]
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@nightly
if: ${{ matrix.rust == '1.74.0' }}
- name: Generate Cargo.lock with minimal-version dependencies
if: ${{ matrix.rust == '1.74.0' }}
run: |
cargo -Zminimal-versions generate-lockfile
cargo update num-bigint --precise 0.4.2

- uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: build
run: cargo build -v
- name: test
if: ${{ matrix.rust != '1.74.0' }}
run: cargo test -v && cargo doc -v

test_other_archs:
# github actions does not support 32-bit or 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:
fail-fast: false
matrix:
arch: [powerpc64-unknown-linux-gnu, i686-unknown-linux-gnu]
steps:
- uses: actions/checkout@v4
- name: Install or use cached cross-rs/cross
uses: baptiste0928/cargo-install@v2
with:
crate: cross
- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: ${{ matrix.arch }}
- name: Start Docker (required for cross-rs)
run: sudo systemctl start docker
- name: Cross-Run Tests using QEMU
run: cross test --target ${{ matrix.arch }}
base:
uses: ./.github/workflows/base.yml
with:
msrv: '1.74.0'
features: '["", "default", "rayon", "avif", "bmp", "dds", "exr", "ff", "gif", "hdr", "ico", "jpeg", "png", "pnm", "qoi", "tga", "tiff", "webp"]'
cargo-fuzz: true
benchmark-feature: 'benchmarks'
msrv-pinned-dependencies: '["[email protected]"]'

test_avif_decoding:
runs-on: ubuntu-latest
Expand All @@ -101,19 +30,6 @@ jobs:
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@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- run: cargo clippy --all-features --all-targets -- -D warnings
env:
SYSTEM_DEPS_DAV1D_BUILD_INTERNAL: always

build_fuzz_afl:
name: "Fuzz targets (afl)"
runs-on: ubuntu-latest
Expand All @@ -140,21 +56,6 @@ jobs:
env:
RUSTFLAGS: ""

build_fuzz_cargo-fuzz:
name: "Fuzz targets (cargo-fuzz)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-fuzz
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-fuzz
- name: check
run: cargo fuzz check
env:
CARGO_INCREMENTAL: 0

public_private_dependencies:
runs-on: ubuntu-latest
steps:
Expand All @@ -172,40 +73,3 @@ jobs:
sed -i 's/num-traits = { ver/num-traits = { public = true, ver/' Cargo.toml
# cargo +nightly check
cargo check

build_benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: build
run: cargo build -v --benches --features=benchmarks

rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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@v4
- uses: EmbarkStudios/cargo-deny-action@v2

cargo-semver-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: obi1kenobi/cargo-semver-checks-action@v2
with:
feature-group: default-features
release-type: minor
Loading