name: Rust
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
env:
CARGO_TERM_COLOR: always
RUST_TEST_THREADS: 1
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- KAFKA_VER: 3.4.0
COMPRESSIONS: NONE
SECURES: ""
- KAFKA_VER: 3.4.0
COMPRESSIONS: NONE
SECURES: secure
- KAFKA_VER: 3.4.0
COMPRESSIONS: SNAPPY
SECURES: ""
- KAFKA_VER: 3.4.0
COMPRESSIONS: SNAPPY
SECURES: secure
- KAFKA_VER: 3.4.0
COMPRESSIONS: GZIP
SECURES: ""
- KAFKA_VER: 3.4.0
COMPRESSIONS: GZIP
SECURES: secure
- KAFKA_VER: 3.8.0
COMPRESSIONS: NONE
SECURES: ""
- KAFKA_VER: 3.8.0
COMPRESSIONS: NONE
SECURES: secure
- KAFKA_VER: 3.8.0
COMPRESSIONS: SNAPPY
SECURES: ""
- KAFKA_VER: 3.8.0
COMPRESSIONS: SNAPPY
SECURES: secure
- KAFKA_VER: 3.8.0
COMPRESSIONS: GZIP
SECURES: ""
- KAFKA_VER: 3.8.0
COMPRESSIONS: GZIP
SECURES: secure
steps:
- uses: actions/checkout@v6
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USER }}" --password-stdin
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install cargo-nextest
uses: taiki-e/install-action@cargo-nextest
- name: Run unit tests
run: |
cargo nextest run --all
cargo test --all --doc
- name: Check code formatting
run: cargo fmt --all --check
- name: Run clippy lints
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build
- name: Make the test script executable
run: chmod +x ./tests/run-all-tests
- name: Run integration tests
run: ./tests/run-all-tests ${{ matrix.KAFKA_VER }}
env:
KAFKA_VER: ${{ matrix.KAFKA_VER }}
COMPRESSIONS: ${{ matrix.COMPRESSIONS }}
SECURES: ${{ matrix.SECURES }}
- name: Generate documentation
run: cargo doc
typos:
name: Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Typos check with custom config file
uses: crate-ci/typos@master
tls-backends:
name: Test TLS Backends
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
include:
- name: "Default (aws-lc-rs)"
features: ""
extra_args: ""
- name: "Explicit aws-lc-rs"
features: "security"
extra_args: "--no-default-features --features=snappy,gzip,security"
- name: "ring"
features: "security-ring"
extra_args: "--no-default-features --features=snappy,gzip,security-ring"
- name: "No security"
features: ""
extra_args: "--no-default-features --features=snappy,gzip"
steps:
- uses: actions/checkout@v6
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Build - ${{ matrix.name }}
run: |
if [ -z "${{ matrix.extra_args }}" ]; then
cargo build --verbose
else
cargo build --verbose ${{ matrix.extra_args }}
fi
- name: Test - ${{ matrix.name }}
run: |
if [ -z "${{ matrix.extra_args }}" ]; then
cargo test --verbose
else
cargo test --verbose ${{ matrix.extra_args }}
fi
musl-build:
name: Test musl build (pure Rust)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: x86_64-unknown-linux-musl
- name: Install musl tools
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build for musl with rustls
run: cargo build --target x86_64-unknown-linux-musl --verbose