Initial release #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check PRs for formatting issues, linting issues, run tests, and check code coverage | |
name: Code Check | |
on: | |
push: | |
branches: | |
- main | |
# Perform check if Rust files or the current file are modified only | |
paths: | |
- src/** | |
- Cargo.toml | |
- Cargo.lock | |
- .github/workflows/code_check.yml | |
pull_request: | |
branches: | |
- main | |
paths: | |
- src/** | |
- Cargo.toml | |
- Cargo.lock | |
- .github/workflows/code_check.yml | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Run tests | |
run: cargo test --all-features | |
fmt: | |
name: Format | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: -D warnings | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Run cargo check | |
run: cargo check | |
- name: Check formatting | |
run: | | |
if ! cargo fmt --check ; then | |
echo "Formatting errors detected, please run `cargo fmt` to fix it"; | |
exit 1 | |
fi | |
lint: | |
name: Clippy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Check linting | |
run: cargo clippy --all-features -- -D warnings # handle clippy warnings as errors | |
coverage: | |
name: Code coverage | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
# Install cargo-tarpaulin for code coverage | |
- name: Install tarpaulin | |
run: cargo install cargo-tarpaulin | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Check code coverage | |
run: cargo tarpaulin --verbose --workspace |