name: GitHub CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
rustfmt:
name: Check code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo fmt --all -- --check
clippy:
name: Lint with cargo clippy
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings steps:
- uses: actions/checkout@v3
- name: Cache
id: cache-cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }}
- run: cargo clippy --workspace --all-targets --verbose --no-default-features
- run: cargo clippy --workspace --all-targets --verbose --all-features
test:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache
id: cache-cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-build-and-test-${{ hashFiles('**/Cargo.toml') }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: |
cargo test --lib --verbose
cargo test --doc --verbose
coverage:
name: Measure code coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache
id: cache-cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-measure-coverage-${{ hashFiles('**/Cargo.toml') }}
- uses: dtolnay/rust-toolchain@nightly
- name: Create code coverage report
run: |
rustup component add llvm-tools-preview
sudo apt-get install -y lcov
cargo install grcov
cargo clean # coverage does not seem to update without clean
python3 scripts/measure_coverage.py
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: |
target/debug/lcov.info
target/debug/coverage/**
- name: Report coverage to Coveralls
uses: coverallsapp/github-action@master
with:
path-to-lcov: target/debug/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}