name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
MSRV: "1.75"
jobs:
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Check formatting
run: cargo +nightly fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install protobuf compiler
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler
protoc --version
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: clippy
- name: Run clippy (default features)
run: cargo clippy --workspace --all-targets -- -D warnings
- name: Run clippy (all features)
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Run clippy (no default features)
run: cargo clippy --workspace --all-targets --no-default-features -- -D warnings
msrv:
name: MSRV (${{ matrix.msrv }})
runs-on: ubuntu-latest
strategy:
matrix:
msrv: ["1.88"]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust ${{ matrix.msrv }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.msrv }}
- name: Install protobuf compiler
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: msrv-${{ matrix.msrv }}
- name: Check compilation
run: cargo check --workspace --all-features
test:
name: Test (${{ matrix.os }})
needs: [fmt, clippy]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install protobuf compiler (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler
protoc --version
- name: Install protobuf compiler (macOS)
if: runner.os == 'macOS'
run: |
brew install protobuf
protoc --version
- name: Install protobuf compiler (Windows)
if: runner.os == 'Windows'
run: |
choco install protoc
protoc --version
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: test-${{ matrix.os }}
- name: Run unit tests (default features)
run: cargo test --lib
- name: Run unit tests (all features)
run: cargo test --lib --all-features
- name: Run doc tests
run: cargo test --doc --all-features
features:
name: Feature Combinations
needs: [fmt, clippy]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install protobuf compiler
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: features
- name: Test no default features
run: cargo test --lib --no-default-features
- name: Test gRPC only
run: cargo test --lib --no-default-features --features grpc,rustls
- name: Test REST only
run: cargo test --lib --no-default-features --features rest,rustls
- name: Test with native-tls
run: cargo test --lib --no-default-features --features rest,native-tls
- name: Test with tracing
run: cargo test --lib --features tracing
- name: Test with derive macros
run: cargo test --lib --features derive
- name: Test with blocking
run: cargo test --lib --features blocking
coverage:
name: Code Coverage
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install protobuf compiler
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: coverage
- name: Generate coverage
run: |
cargo llvm-cov --lib \
--ignore-filename-regex 'proto|inferadb\.v1' \
--codecov \
--output-path codecov.json
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./codecov.json
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Install protobuf compiler
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: docs
- name: Build documentation
env:
RUSTDOCFLAGS: -D warnings --cfg docsrs
run: cargo +nightly doc --workspace --no-deps --all-features
examples:
name: Examples
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install protobuf compiler
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: examples
- name: Check examples compile
run: cargo check --examples --all-features
ci-success:
name: CI Success
needs: [fmt, clippy, msrv, test, features, coverage, docs, examples]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check all jobs
env:
FMT_RESULT: ${{ needs.fmt.result }}
CLIPPY_RESULT: ${{ needs.clippy.result }}
MSRV_RESULT: ${{ needs.msrv.result }}
TEST_RESULT: ${{ needs.test.result }}
FEATURES_RESULT: ${{ needs.features.result }}
DOCS_RESULT: ${{ needs.docs.result }}
EXAMPLES_RESULT: ${{ needs.examples.result }}
COVERAGE_RESULT: ${{ needs.coverage.result }}
run: |
results="$FMT_RESULT $CLIPPY_RESULT $MSRV_RESULT $TEST_RESULT $FEATURES_RESULT $DOCS_RESULT $EXAMPLES_RESULT"
for result in $results; do
if [[ "$result" != "success" && "$result" != "skipped" ]]; then
echo "One or more jobs failed"
exit 1
fi
done
# Coverage is optional
if [[ "$COVERAGE_RESULT" == "failure" ]]; then
echo "Coverage failed (non-blocking)"
fi
echo "All required checks passed!"