Skip to content

fix(metrics): correct storage backend label and doubled _total suffix #315

fix(metrics): correct storage backend label and doubled _total suffix

fix(metrics): correct storage backend label and doubled _total suffix #315

Workflow file for this run

name: Tests
permissions:
contents: read
on:
push:
branches: [main, develop]
paths:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'Dockerfile'
- '.github/workflows/**'
pull_request:
branches: [main]
paths:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'Dockerfile'
- '.github/workflows/**'
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Fast checks - runs first to fail fast on simple issues
check:
name: Check & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
components: clippy, rustfmt
# Required by the `gssapi` cargo feature (pulled in via `--all-features`).
# `libgssapi-sys`'s build.rs needs the krb5 development headers to
# generate bindings; only the runtime `.so` ships on default runners.
- name: Install krb5 development headers
run: sudo apt-get install -y libkrb5-dev
- name: Cache cargo registry
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-check-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-check-
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Check compilation
run: cargo check --all-targets
# Unit tests - fast, no external dependencies
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Install krb5 development headers
run: sudo apt-get install -y libkrb5-dev
- name: Cache cargo registry
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-unit-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-unit-
- name: Run unit tests (lib)
run: cargo test --lib --all-features
env:
RUST_LOG: debug
- name: Run unit test suite
run: cargo test --test unit_tests --all-features
env:
RUST_LOG: debug
# Integration tests - require Docker
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: unit-tests
services:
# Docker-in-Docker for testcontainers
dind:
image: docker:dind
options: --privileged
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Install krb5 development headers
run: sudo apt-get install -y libkrb5-dev
- name: Cache cargo registry
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-integration-
- name: Run integration tests
run: cargo test --test integration --all-features -- --nocapture
env:
DOCKER_HOST: unix:///var/run/docker.sock
RUST_LOG: debug
TESTCONTAINERS: "true"
- name: Run integration test suite
# --include-ignored runs ignored tests. We skip suites whose fixtures
# aren't brought up in this workflow:
# - tls: requires local certificate setup (tests/tls-test-infra/)
# - sasl_: requires SASL Docker compose fixtures
# (tests/sasl-oauth-test-infra/, tests/sasl-gssapi-test-infra/)
# These are run manually or in dedicated workflows.
run: cargo test --test integration_suite_tests --all-features -- --nocapture --include-ignored --skip tls --skip sasl_
env:
DOCKER_HOST: unix:///var/run/docker.sock
RUST_LOG: debug
TESTCONTAINERS: "true"
timeout-minutes: 15
# Chaos tests - slower, may require special setup
chaos-tests:
name: Chaos Tests
runs-on: ubuntu-latest
needs: integration-tests
# Only run on main branch or when explicitly requested
if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run-chaos-tests')
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Install krb5 development headers
run: sudo apt-get install -y libkrb5-dev
- name: Cache cargo registry
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-chaos-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-chaos-
- name: Run chaos tests (non-ignored only)
run: cargo test --test chaos_tests --all-features -- --nocapture
env:
DOCKER_HOST: unix:///var/run/docker.sock
RUST_LOG: debug
timeout-minutes: 20
# Coverage reporting
coverage:
name: Code Coverage
runs-on: ubuntu-latest
needs: unit-tests
# Only run on main branch pushes
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Install cargo-tarpaulin
uses: taiki-e/install-action@b22dd82fe1ad4419f5be5ea5e741291929a74bbe # cargo-tarpaulin
with:
tool: cargo-tarpaulin
- name: Cache cargo registry
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-coverage-
- name: Generate coverage report
run: |
cargo tarpaulin \
--out Xml \
--out Html \
--timeout 300 \
--ignore-panics \
--ignore-tests \
--workspace \
--exclude-files "*/tests/*"
continue-on-error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
with:
files: ./cobertura.xml
fail_ci_if_error: false
verbose: true
- name: Upload coverage HTML report
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: coverage-report
path: tarpaulin-report.html
retention-days: 7
# Security audit
security-audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Run security audit
run: cargo audit
continue-on-error: true
# Docker build validation - ensures the image builds and runs correctly
docker-build:
name: Docker Build & Smoke Test
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Build Docker image
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .
load: true
tags: kafka-backup:test
cache-from: type=gha
cache-to: type=gha,mode=max
# Smoke test: verify glibc compatibility and binary execution
# This catches issues like rust:latest using newer glibc than runtime image
- name: Smoke test - verify binary runs
run: |
echo "Verifying glibc version in runtime image..."
docker run --rm --entrypoint ldd kafka-backup:test --version
echo ""
echo "Testing binary execution..."
docker run --rm kafka-backup:test --version
docker run --rm kafka-backup:test --help > /dev/null
echo "Docker smoke test passed!"
# Summary job for branch protection
tests-complete:
name: Tests Complete
runs-on: ubuntu-latest
needs: [check, unit-tests, integration-tests, docker-build]
if: always()
steps:
- name: Check all tests passed
run: |
if [ "${{ needs.check.result }}" != "success" ] || \
[ "${{ needs.unit-tests.result }}" != "success" ] || \
[ "${{ needs.integration-tests.result }}" != "success" ] || \
[ "${{ needs.docker-build.result }}" != "success" ]; then
echo "One or more required jobs failed"
exit 1
fi
echo "All required tests passed!"