name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
merge_group:
jobs:
check:
name: Format & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all --check
- run: cargo clippy --workspace --all-features -- -D warnings -D clippy::pedantic
- run: cargo clippy --no-default-features -- -D warnings -D clippy::pedantic
linear-history:
name: Linear PR History
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Check for merge commits
run: |
merge_commits=$(git rev-list --merges origin/main..HEAD)
if [ -n "$merge_commits" ]; then
echo "::error::PR branch contains merge commits. Please rebase instead."
echo "$merge_commits"
exit 1
fi
semver:
name: SemVer Check
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: obi1kenobi/cargo-semver-checks-action@v2
test:
name: Build, Test & Coverage
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov, cargo-nextest
- run: cargo test --no-default-features
- run: cargo llvm-cov nextest --all-features --lcov --output-path ./target/lcov.info
- name: Upload Coverage report
uses: codecov/codecov-action@v5
with:
report_type: coverage
files: ./target/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Upload test results to Codecov
uses: codecov/codecov-action@v5
with:
report_type: test_results
files: ./target/nextest/default/junit.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
test-windows:
name: Build & Test (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --all-features --no-run
- run: cargo test --all-features --lib