name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Lint & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Tests
run: cargo test --all-features
- name: Doc build
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate coverage
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
- name: Extract coverage percentage
id: cov
run: |
LF=$(grep '^LF:' lcov.info | awk -F: '{s+=$2} END {print s+0}')
LH=$(grep '^LH:' lcov.info | awk -F: '{s+=$2} END {print s+0}')
COVERAGE=$(awk "BEGIN {if ($LF>0) printf \"%.1f\", ($LH/$LF)*100; else print \"0\"}")
echo "percentage=$COVERAGE" >> "$GITHUB_OUTPUT"
echo "### Coverage: ${COVERAGE}%" >> "$GITHUB_STEP_SUMMARY"
- name: Update coverage badge
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: ${{ vars.COVERAGE_GIST_ID }}
filename: coverage.json
label: coverage
message: ${{ steps.cov.outputs.percentage }}%
valColorRange: ${{ steps.cov.outputs.percentage }}
minColorRange: 50
maxColorRange: 90
check-aarch64:
name: Cross-compile aarch64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
- name: Install cross-compilation toolchain
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Check (no features)
run: cargo check --target aarch64-unknown-linux-gnu
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Check (all features)
run: cargo check --target aarch64-unknown-linux-gnu --all-features
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
test-macos-arm:
name: Test macOS ARM64
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Tests
run: cargo test --all-features
security:
name: Security & Licenses
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check