ci: codecov integration #74
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
name: Rust | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Build | |
run: cargo build --workspace --all-features --all-targets | |
lint: | |
name: Lint using clippy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Clippy exclude cpast | |
run: cargo clippy --workspace --all-features --all-targets -- -D warnings | |
format: | |
name: Format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Format | |
run: cargo fmt --all --check | |
tests: | |
name: Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Run tests | |
run: cargo test --all-features --all-targets | |
coverage: | |
name: Code coverage | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
components: llvm-tools-preview | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Generate code coverage | |
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info | |
- name: Generate report | |
run: cargo llvm-cov report --html --output-dir coverage | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: "Coverage report" | |
path: coverage/ | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos | |
files: lcov.info | |
fail_ci_if_error: true |