refactor: split tests #146
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: "Test Suite" | |
on: | |
push: | |
branches-ignore: | |
- 'dependabot/**' #avoid duplicates: only run the PR, not the push | |
- 'renovate/**' #avoid duplicates: only run the PR, not the push | |
- 'gh-pages' #github pages do not trigger all tests | |
tags-ignore: | |
- 'v*' #avoid rerun existing commit on release | |
pull_request: | |
branches: | |
- 'main' | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/') || startsWith(github.head_ref, 'renovate/') || startsWith(github.head_ref, 'release-plz'))) | |
name: cargo test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: nightly | |
components: llvm-tools-preview | |
- name: Install grcov | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: grcov | |
- name: Build | |
run: cargo build --all-targets | |
env: | |
RUSTFLAGS: "-Cinstrument-coverage" | |
- name: Start minio | |
run: ./ci/minio_start.sh | |
- name: Test | |
run: cargo test --all-features -- -Z unstable-options --format json --report-time | tee results.json | |
env: | |
LLVM_PROFILE_FILE: "target/coverage/prof/%p-%m.profraw" | |
RUSTFLAGS: "-Cinstrument-coverage" | |
- name: Stop minio | |
run: ./ci/minio_stop.sh | |
- name: Prepare junit report | |
id: cargo_reporter | |
uses: innoq/action-cargo-test-report@v1 | |
with: | |
cargo-test-report-json: 'results.json' | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v4 | |
if: always() # always run even if the previous step fails | |
with: | |
check_name: Test Report | |
fail_on_failure: true | |
require_tests: true | |
annotate_only: true | |
summary: ${{ steps.cargo_reporter.outputs.summary }} | |
- name: Create coverage report | |
run: | | |
grcov \ | |
--source-dir . \ | |
--binary-path target/debug \ | |
--branch \ | |
--excl-start 'mod tests \{' \ | |
--ignore 'tests/*' \ | |
-t lcov \ | |
-o lcov.info \ | |
target/coverage/prof | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
files: lcov.info | |
fail_ci_if_error: false | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# Check formatting with rustfmt | |
formatting: | |
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/') || startsWith(github.head_ref, 'renovate/') || startsWith(github.head_ref, 'release-plz'))) | |
name: cargo fmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Ensure rustfmt is installed and setup problem matcher | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
components: rustfmt | |
- name: Rustfmt Check | |
uses: actions-rust-lang/rustfmt@v1 | |
lint: | |
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/') || startsWith(github.head_ref, 'renovate/') || startsWith(github.head_ref, 'release-plz'))) | |
name: cargo clippy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- run: cargo clippy --all-features --all-targets --workspace -- -D warnings |