name: Test
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
lint:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Set Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Run check
run: cargo check
- name: Run rustfmt
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
test:
needs: [lint]
name: test (${{ matrix.job.target }})
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
job:
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu }
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl }
- { os: ubuntu-latest , target: armv7-unknown-linux-gnueabihf }
- { os: ubuntu-latest , target: armv7-unknown-linux-musleabihf }
- { os: ubuntu-latest , target: aarch64-unknown-linux-gnu }
- { os: ubuntu-latest , target: aarch64-unknown-linux-musl }
- { os: macos-latest , target: x86_64-apple-darwin }
- { os: windows-latest , target: x86_64-pc-windows-msvc }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.job.target }}
- name: Test
run: cargo test
coverage:
needs: [test]
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Set Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@cargo-nextest
- uses: taiki-e/install-action@cargo-make
- name: Generate code coverage
run: cargo make coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: target/codecov.json
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true