name: CI
on:
push:
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: "./.github/actions/init"
- name: Check
run: |
cargo check --all-features --release --tests
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: "./.github/actions/init"
- name: Install nightly rustfmt
run: rustup toolchain install nightly --component rustfmt
- name: Fmt
run: |
cargo +nightly fmt --all --check
clippy:
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: "./.github/actions/init"
- name: Clippy
run: |
cargo clippy --all-features -- -D warnings
unit-tests:
runs-on: ubuntu-latest
needs: [check, fmt]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: "./.github/actions/init"
- name: Run unit tests
run: |
cargo test --features paths,parsing --lib
# This feature's test play with the toolchain, so they must run in a single thread to avoid race conditions
cargo test --features fmt,manifest --lib -- --test-threads=1
doc-tests:
runs-on: ubuntu-latest
needs: [check, fmt]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: "./.github/actions/init"
- name: Run doc tests
run: |
cargo test --all-features --doc
coverage:
runs-on: ubuntu-latest
needs: unit-tests
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: "./.github/actions/init"
- name: Install nightly llvm-tools-preview
run: rustup toolchain install nightly --component llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: |
cargo llvm-cov \
--features paths,parsing \
--codecov \
--ignore-filename-regex "/tests\.rs$" \
--output-path cov_no_fmt.json
cargo llvm-cov \
--features fmt,manifest \
--codecov \
--ignore-filename-regex "/tests\.rs$" \
--output-path cov_fmt.json \
-- \
--test-threads=1
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: cov_no_fmt.json, cov_fmt.json
fail_ci_if_error: true