name: Build, Check and Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: "1"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deny:
name: Check dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@1.62.0
- name: Cache/Restore cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: deny-cargo-registry
- uses: taiki-e/install-action@cargo-deny
- uses: taiki-e/install-action@just
- name: Check advisories
run: just args='--deny warnings' deny advisories
- name: Check bans licenses sources
run: just deny bans licenses sources
minimal_versions:
name: Check minimal version requirements of dependencies
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- stable
- nightly
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
if: ${{ startsWith(matrix.toolchain, 'nightly') }}
with:
toolchain: ${{ matrix.toolchain }}
- uses: dtolnay/rust-toolchain@master
if: ${{ ! startsWith(matrix.toolchain, 'nightly') }}
with:
toolchain: nightly
- uses: dtolnay/rust-toolchain@master
if: ${{ ! startsWith(matrix.toolchain, 'nightly') }}
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
with:
key: ubuntu-latest_${{ matrix.toolchain }}
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
- uses: taiki-e/install-action@just
- name: Check build with minimal versions
run: just minimal-versions
format:
name: Check format and spelling
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: taiki-e/install-action@cargo-binstall
- uses: taiki-e/install-action@just
- name: Cache/Restore rust cache
uses: Swatinem/rust-cache@v2
- run: cargo binstall --no-confirm --no-symlinks taplo-cli
- run: just check-fmt-all
base:
needs: [deny, minimal_versions, format]
name: Build, check and test
strategy:
fail-fast: false
matrix:
toolchain:
- "1.62.0" - stable
- nightly
include:
- toolchain: stable
components: clippy, llvm-tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: ${{ matrix.components }}
- name: "Prepare: Install stable toolchain with clippy"
if: matrix.toolchain != 'stable'
run: |
rustup toolchain install stable --no-self-update --component clippy
- name: Lock msrv dependencies
if: matrix.toolchain == '1.62.0'
run: cargo +stable generate-lockfile
env:
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: fallback
- name: "Prepare: Run cargo update"
if: matrix.toolchain == 'stable' || matrix.toolchain == 'nightly'
run: |
cargo update
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@grcov
- name: Info
run: |
set -x
uname -a
pwd
rustup --version
rustup show
rustup component list --installed
printenv
- name: Set cargo registry protocol if the toolchain is MSRV
if: matrix.toolchain == '1.62.0'
run: |
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git >> $GITHUB_ENV
- name: Cache/Restore cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ matrix.toolchain }}
- name: Lint
run: just lint
- name: Build hack all packages
if: matrix.toolchain == 'stable' || matrix.toolchain == 'nightly'
run: just build-hack
- name: Build hack just simplematch
if: matrix.toolchain == '1.62.0'
run: just build-hack-simplematch
- name: Run tests for all packages
if: matrix.toolchain == 'stable' || matrix.toolchain == 'nightly'
run: just test-hack
- name: Run tests just for simplematch
if: matrix.toolchain == '1.62.0'
run: just test-hack-simplematch
- name: Coverage
if: matrix.toolchain == 'stable'
run: just coverage-lcov
- name: Upload coverage reports to Codecov
if: matrix.toolchain == 'stable'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fuzz:
name: Fuzzy testing
needs: [deny, minimal_versions, format]
runs-on: ubuntu-latest
env:
FUZZ_TIME: 300
strategy:
fail-fast: false
matrix:
include:
- fuzz_target: dowild
- fuzz_target: dowild_with
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@nightly
with:
targets: "x86_64-unknown-linux-musl"
- uses: taiki-e/install-action@just
- name: Cache/Restore rust cache
uses: Swatinem/rust-cache@v2
with:
key: "workflow-cicd-fuzz"
workspaces: |
. -> target
fuzz -> target
cache-directories: |
fuzz/corpus
- run: cargo install cargo-fuzz --locked
- run: just args='-- -max_total_time=${{ env.FUZZ_TIME }}' fuzz ${{ matrix.fuzz_target }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: fuzzing-artifacts-${{ matrix.fuzz_target }}-${{ github.sha }}
path: fuzz/artifacts