name: CI
on:
push:
branches:
- main
paths-ignore:
- 'README'
- 'COPYRIGHT'
- 'LICENSE-*'
- '**.md'
- '**.txt'
pull_request:
paths-ignore:
- 'README'
- 'COPYRIGHT'
- 'LICENSE-*'
- '**.md'
- '**.txt'
workflow_dispatch:
schedule:
- cron: "0 1 1 * *"
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
nightly: nightly
stable: stable
jobs:
rustfmt:
name: rustfmt
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: clippy
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Apply clippy lints
run: cargo hack clippy --each-feature --include-features sync,async --exclude-no-default-features
cross:
name: cross
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- aarch64-linux-android
- aarch64-unknown-linux-musl
- i686-linux-android
- x86_64-linux-android
- i686-pc-windows-gnu
- x86_64-pc-windows-gnu
- i686-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Cache cargo build and registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cross-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cross-
- name: Install Rust
run: rustup update stable && rustup default stable
- name: cross build --target ${{ matrix.target }}
run: |
cargo install cross
cross build --target ${{ matrix.target }}
build:
name: build
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Cache cargo build and registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Cache ~/.cargo
uses: actions/cache@v5
with:
path: ~/.cargo
key: ${{ runner.os }}-coverage-dotcargo
- name: Run build
run: cargo hack build --feature-powerset --include-features sync,async --exclude-no-default-features
test:
name: test
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Cache cargo build and registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-test-
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Cache ~/.cargo
uses: actions/cache@v5
with:
path: ~/.cargo
key: ${{ runner.os }}-coverage-dotcargo
- name: Run test
run: cargo hack test --feature-powerset --include-features sync,async --exclude-no-default-features
coverage:
name: coverage
runs-on: ubuntu-latest
needs:
- rustfmt
- clippy
- build
- cross
- test
steps:
- uses: actions/checkout@v6
- name: Install Rust
run: rustup update nightly && rustup default nightly
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Cache cargo build and registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-coverage-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-coverage-
- name: Run tarpaulin
env:
RUSTFLAGS: "--cfg tarpaulin"
run: cargo tarpaulin --engine llvm --all-features --run-types lib --run-types tests --run-types doctests --workspace --out xml --out html
- name: Upload coverage report as workflow artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
cobertura.xml
tarpaulin-report.html
if-no-files-found: error
- name: Upload to codecov.io
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
fail_ci_if_error: true