name: Reusable / Test
on:
workflow_call:
inputs:
os_matrix:
description: 'JSON array of runner OSes to test on'
type: string
default: '["ubuntu-latest"]'
upload_codecov:
description: 'Upload nextest JUnit results to Codecov'
type: boolean
default: false
skip_codecov_for_fork_prs:
description: 'When true, skip the Codecov upload if this run is a PR from a fork'
type: boolean
default: false
secrets:
CODECOV_TOKEN:
required: false
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_PROFILE_RELEASE_LTO: true
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
permissions:
contents: read
jobs:
test:
name: Cargo CI Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(inputs.os_matrix) }}
steps:
- uses: actions/checkout@v7
- uses: taiki-e/install-action@nextest
- name: Install Rust Toolchain
run: rustup toolchain install stable
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
- name: Cargo Test
run: cargo nextest run --profile ci --all-features
- name: Upload nextest JUnit test results to Codecov
if: >-
${{ inputs.upload_codecov && !cancelled() &&
(!inputs.skip_codecov_for_fork_prs ||
github.event.pull_request.head.repo.full_name == github.repository) }}
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/nextest/ci/junit.xml
disable_search: true
report_type: test_results
flags: nextest
name: nextest-junit