name: Rust CI
on:
push:
branches: ['*']
paths-ignore:
- 'README.md'
- 'COPYRIGHT'
- 'LICENSE-*'
- '**/*.md'
- '**/*.txt'
- '.gitignore'
pull_request:
paths-ignore:
- 'README.md'
- 'COPYRIGHT'
- 'LICENSE-*'
- '**/*.md'
- '**/*.txt'
- '.gitignore'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
jobs:
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
continue-on-error: true
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Apply clippy lints
run: cargo clippy --all-features -- -D warnings
unit-tests:
name: unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: Swatinem/rust-cache@v2
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Test all features
timeout-minutes: 5 run: cargo nextest run --all-features
coverage:
name: cargo tarpaulin
runs-on: ubuntu-latest
needs:
- unit-tests
- clippy
- rustfmt
steps:
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin --version 0.27.3
- uses: Swatinem/rust-cache@v2
- name: Run tarpaulin
run: cargo tarpaulin --all-features --run-types tests --run-types doctests --workspace --out xml -- --test-threads 1
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
docs:
name: Generate Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: Swatinem/rust-cache@v2
- name: Generate documentation
run: cargo doc --lib --no-deps --all-features --document-private-items
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg docsrs
RUSTDOCFLAGS: --cfg docsrs -Dwarnings