name: CI
on:
push:
branches: [main]
paths-ignore:
- '*.md'
- 'docs/**'
- 'LICENSE'
pull_request:
branches: [main]
paths-ignore:
- '*.md'
- 'docs/**'
- 'LICENSE'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets --features daemon -- -D warnings
test:
runs-on: ubuntu-latest
needs: [fmt, clippy]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --verbose --features daemon
coverage:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install tarpaulin
run: cargo install cargo-tarpaulin
- name: Check coverage (90% minimum)
run: |
OUTPUT=$(cargo tarpaulin --skip-clean --features daemon --lib --test cli_test --test diff_test --test overview_test --test scanner_test --test trace_test --timeout 300 2>&1) || true
echo "$OUTPUT"
COVERAGE=$(echo "$OUTPUT" | grep -oP '[\d.]+(?=% coverage)' | tail -1)
echo "Coverage: ${COVERAGE}%"
if [ -z "$COVERAGE" ]; then
echo "❌ Could not determine coverage from tarpaulin output"
exit 1
fi
if [ "$(echo "$COVERAGE < 90" | bc -l)" -eq 1 ]; then
echo "❌ Coverage ${COVERAGE}% is below 90% threshold"
exit 1
fi
echo "✅ Coverage ${COVERAGE}% meets 90% threshold"