mq-bridge 0.2.13

An asynchronous message bridging library connecting Kafka, MQTT, AMQP, NATS, MongoDB, HTTP, and more.
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main, dev]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # Linting and formatting checks
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      
      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-
      
      - name: Check formatting
        run: cargo fmt --all -- --check
      
      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

  # Build with all features
  build:
    name: Build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        features:
          - ""
          - "full"
          - "kafka"
          #  "amqp" # no recent changes, already included in full
          - "nats"
          - "grpc"
          - "mqtt"
          - "mongodb"
          - "http"
          # - "aws"  # needs too long, already included in full
          # - "zeromq" # no recent changes, already included in full
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      
      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-
      
      - name: Build
        run: |
          if [ -z "${{ matrix.features }}" ]; then
            cargo build --release
          else
            cargo build --release --features "${{ matrix.features }}"
          fi

  # Unit tests
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      
      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-
      
      - name: Run unit tests
        run: cargo test --lib --features=full 
# currently - just random panic test
#      - name: Run long-running unit tests
#        run: cargo test --lib --features=full -- --ignored --nocapture

  # Integration tests (requires Docker) split into parallel jobs
  integration-others:
    name: Integration — Others
    runs-on: ubuntu-latest
    services:
      docker:
        image: docker:dind
        options: --privileged
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      
      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-
      
      - name: Pre-pull docker images
        run: |
          find tests/integration/docker-compose -name "*.yml" | xargs -P 5 -I {} docker compose -f {} pull -q
      - name: Install JDK (for keytool)
        run: |
          sudo apt-get update
          sudo apt-get install -y default-jdk

      - name: Generate TLS certs for integration services
        run: |
          chmod +x tests/integration/scripts/gen_certs.sh
          ./tests/integration/scripts/gen_certs.sh mongodb
          ./tests/integration/scripts/gen_certs.sh kafka
          ./tests/integration/scripts/gen_certs.sh ibm-mq

      - name: Run chaos/stability tests
        run: |
          cargo test --test integration_test --release --features full,test-utils -- --ignored --nocapture --test-threads=1 --exact test_all_chaos

      - name: Run remaining integration tests (excluding chaos & performance)
        run: |
          cargo test --test integration_test --release --features full,test-utils -- --ignored --nocapture --test-threads=1 --skip test_all_chaos --skip test_all_performance_pipeline --skip test_all_performance_direct

  integration-performance:
    name: Integration — Performance
    runs-on: ubuntu-latest
    services:
      docker:
        image: docker:dind
        options: --privileged
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Pre-pull docker images
        run: |
          find tests/integration/docker-compose -name "*.yml" | xargs -P 5 -I {} docker compose -f {} pull -q
      - name: Install JDK (for keytool)
        run: |
          sudo apt-get update
          sudo apt-get install -y default-jdk

      - name: Generate TLS certs for integration services
        run: |
          chmod +x tests/integration/scripts/gen_certs.sh
          ./tests/integration/scripts/gen_certs.sh mongodb
          ./tests/integration/scripts/gen_certs.sh kafka
          ./tests/integration/scripts/gen_certs.sh ibm-mq

      - name: Run pipeline performance tests
        run: |
          cargo test --test integration_test --release --features full,test-utils -- --ignored --nocapture --test-threads=1 --exact test_all_performance_pipeline

      - name: Run other performance tests
        run: |
          cargo test --test integration_test --release --features full,test-utils -- --ignored --nocapture --test-threads=1 --exact test_all_performance_direct

  integration-armature:
    name: Integration — Armature
    runs-on: ubuntu-latest
    services:
      docker:
        image: docker:dind
        options: --privileged
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Pre-pull docker images
        run: |
          find tests/integration/docker-compose -name "*.yml" | xargs -P 5 -I {} docker compose -f {} pull -q
      - name: Install JDK (for keytool)
        run: |
          sudo apt-get update
          sudo apt-get install -y default-jdk

      - name: Generate TLS certs for integration services
        run: |
          chmod +x tests/integration/scripts/gen_certs.sh
          ./tests/integration/scripts/gen_certs.sh mongodb
          ./tests/integration/scripts/gen_certs.sh kafka
          ./tests/integration/scripts/gen_certs.sh ibm-mq

      - name: Run armature integration tests
        run: |
          cargo test --test armature_integration --release --features full,test-utils -- --ignored --nocapture --test-threads=1

  # Documentation
  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      
      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-
      
      - name: Build documentation
        run: cargo doc --all-features --no-deps
      
      - name: Check for broken links
        run: cargo doc --all-features --no-deps 2>&1 | grep -i "warning\|error" && exit 1 || exit 0