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: |
# integration-tests features doesn't compile unit tests
cargo check --release --tests
cargo check --features integration-tests --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 -- -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 --lib
integration-tests:
runs-on: ubuntu-latest
needs: [check, fmt]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: "./.github/actions/init"
- name: Run integration tests
run: |
# The integration tests modifies some system env variables, they should run sequentially
# to avoid race conditions
cargo test --features integration-tests --tests -- --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 --doc
coverage:
runs-on: ubuntu-latest
needs: [unit-tests, integration-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 \
--codecov \
--ignore-filename-regex ".*test.*\.rs$" \
--output-path cov_unit.json
cargo llvm-cov \
--features integration-tests \
--codecov \
--ignore-filename-regex ".*test.*\.rs$" \
--output-path cov_integration.json \
-- \
--test-threads=1
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: cov_unit.json, cov_integration.json