Skip to content

feat: fix fork, add clippy test in CI #8

feat: fix fork, add clippy test in CI

feat: fix fork, add clippy test in CI #8

Workflow file for this run

name: Rust
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
CACHE_KEY_SUFFIX: 20240821
jobs:
rust:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust_toolchain: [stable, 1.81.0]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
components: rustfmt, clippy, llvm-tools-preview
- name: Cache Cargo home
uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ env.CACHE_KEY_SUFFIX }}-rust-test
- name: Install cargo tools
if: steps.cache.outputs.cache-hit != 'true'
run: |
cargo install cargo-sort --locked
- name: Run rust cargo-sort check
# https://github.com/DevinR528/cargo-sort/issues/56
if: matrix.os != 'windows-latest'
run: |
cargo sort -w -c
- name: Run rust format check
run: |
cargo fmt --all -- --check
- name: Run rust clippy check
run: |
cargo clippy --all-features -- -D warnings
- if: steps.cache.outputs.cache-hit != 'true'
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run rust test with coverage
env:
RUST_BACKTRACE: 1
run: |
cargo llvm-cov test --all-features
- uses: codecov/codecov-action@v4
if: runner.os == 'Linux' && matrix.rust_toolchain == 'stable'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
verbose: true