name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: "default features"
features: ""
- name: "simd feature"
features: "--features simd"
- name: "decimal feature"
features: "--features decimal"
- name: "all features"
features: "--all-features"
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and build
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Run tests (${{ matrix.name }})
run: cargo test ${{ matrix.features }} --verbose
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo registry and build
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-clippy-
- name: Run Clippy (all features)
run: cargo clippy --all-features -- -D warnings
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and build
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-docs-
- name: Check documentation
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --all-features --no-deps
msrv:
name: Minimum Supported Rust Version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain (MSRV)
uses: dtolnay/rust-toolchain@1.85
- name: Cache cargo registry and build
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-msrv-
- name: Check MSRV compatibility
run: cargo check --all-features
coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Cache cargo registry and build
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-cov-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-cov-
- name: Generate coverage report
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: lcov.info
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
slug: paradedb/buff-rs
- name: Generate coverage summary
run: |
# Run coverage and capture output
COVERAGE_OUTPUT=$(cargo llvm-cov --all-features 2>&1)
# Get the TOTAL line and extract percentages
TOTAL_LINE=$(echo "$COVERAGE_OUTPUT" | grep "^TOTAL")
LINE_COV=$(echo "$TOTAL_LINE" | grep -oE '[0-9]+\.[0-9]+%' | tail -1)
FUNC_COV=$(echo "$TOTAL_LINE" | grep -oE '[0-9]+\.[0-9]+%' | head -2 | tail -1)
REGION_COV=$(echo "$TOTAL_LINE" | grep -oE '[0-9]+\.[0-9]+%' | head -1)
# Get file-level line coverage
CODEC_COV=$(echo "$COVERAGE_OUTPUT" | grep "codec.rs" | grep -oE '[0-9]+\.[0-9]+%' | tail -1)
PRECISION_COV=$(echo "$COVERAGE_OUTPUT" | grep "precision.rs" | grep -oE '[0-9]+\.[0-9]+%' | tail -1)
BITPACK_COV=$(echo "$COVERAGE_OUTPUT" | grep "bitpack.rs" | grep -oE '[0-9]+\.[0-9]+%' | tail -1)
# Write formatted summary
echo "## 📊 Code Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Coverage |" >> $GITHUB_STEP_SUMMARY
echo "|--------|----------|" >> $GITHUB_STEP_SUMMARY
echo "| **Lines** | $LINE_COV |" >> $GITHUB_STEP_SUMMARY
echo "| **Functions** | $FUNC_COV |" >> $GITHUB_STEP_SUMMARY
echo "| **Regions** | $REGION_COV |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Per-File Coverage" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| File | Line Coverage |" >> $GITHUB_STEP_SUMMARY
echo "|------|---------------|" >> $GITHUB_STEP_SUMMARY
echo "| \`codec.rs\` | $CODEC_COV |" >> $GITHUB_STEP_SUMMARY
echo "| \`precision.rs\` | $PRECISION_COV |" >> $GITHUB_STEP_SUMMARY
echo "| \`bitpack.rs\` | $BITPACK_COV |" >> $GITHUB_STEP_SUMMARY