name: CI
on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]
schedule:
- cron: '0 2 * * *'
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, beta, nightly]
exclude:
- os: windows-latest
rust: beta
- os: macos-latest
rust: beta
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo build
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with:
path: target
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.rust }}-cargo-build-target-
- name: Check code formatting
run: cargo fmt -- --check
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
if: matrix.rust == 'stable'
- name: Build with default features
run: cargo build --verbose
- name: Build with all features
run: cargo build --all-features --verbose
- name: Build with no default features
run: cargo build --no-default-features --verbose
- name: Run tests with default features
run: cargo test --verbose
- name: Run tests with all features
run: cargo test --all-features --verbose
- name: Run tests with no default features
run: cargo test --no-default-features --verbose
- name: Run examples
run: |
cargo run --example basic_usage
cargo run --example custom_entry
cargo run --example file_scanner_migration
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'
benchmarks:
name: Benchmarks
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target
key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
- name: Install criterion
run: cargo install cargo-criterion || true
- name: Run benchmarks
run: cargo criterion --message-format=json > benchmark-results.json || true
continue-on-error: true
- name: Upload benchmark results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with:
name: benchmark-results
path: benchmark-results.json
if: always()
coverage:
name: Code Coverage
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b with:
toolchain: stable
components: llvm-tools-preview
- name: Cache cargo
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@7afa10ed9b269c561c2336fd862446844e0cbf71 with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
msrv:
name: Minimum Supported Rust Version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: Install Rust toolchain (1.81.0 - prometheus requirement)
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b with:
toolchain: 1.81.0
- name: Cache cargo
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target
key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.lock') }}
- name: Check MSRV
run: cargo check --all-features
check-dependencies:
name: Check Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-deps-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-deny
run: cargo install cargo-deny || true
- name: Check dependencies
run: cargo deny check || true
continue-on-error: true
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target
key: ${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}
- name: Run integration tests
run: |
# Check if any integration tests exist
if ls tests/*.rs 2>/dev/null | grep -q .; then
cargo test --test '*' --all-features -- --nocapture
else
echo "No integration tests found in tests/ directory"
fi
build-status:
name: Build Status
runs-on: ubuntu-latest
needs: [test, coverage, msrv, check-dependencies]
if: always()
steps:
- name: Check build status
run: |
if [ "${{ needs.test.result }}" = "success" ] && [ "${{ needs.msrv.result }}" = "success" ]; then
echo "✅ All required checks passed"
exit 0
else
echo "❌ Some required checks failed"
exit 1
fi