mq-bridge 0.3.5

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@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
        with:
          components: rustfmt, clippy
      
      - name: Cache cargo build
        uses: Swatinem/rust-cache@v2
        with:
          # Differentiates the matrix `check` job per feature set; evaluates to an
          # empty string (no-op) in non-matrix jobs. rust-cache already keys on the
          # job id, OS, rustc version, and lockfiles automatically.
          key: ${{ matrix.features }}
      
      - 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@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
      
      - name: Cache cargo build
        uses: Swatinem/rust-cache@v2
        with:
          # Differentiates the matrix `check` job per feature set; evaluates to an
          # empty string (no-op) in non-matrix jobs. rust-cache already keys on the
          # job id, OS, rustc version, and lockfiles automatically.
          key: ${{ matrix.features }}
      
      - name: Check
        run: |
          if [ -z "${{ matrix.features }}" ]; then
            cargo check --all-targets
          else
            cargo check --all-targets --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@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
      
      - name: Cache cargo build
        uses: Swatinem/rust-cache@v2
        with:
          # Differentiates the matrix `check` job per feature set; evaluates to an
          # empty string (no-op) in non-matrix jobs. rust-cache already keys on the
          # job id, OS, rustc version, and lockfiles automatically.
          key: ${{ matrix.features }}
      
      - 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

      - name: Run non-Docker integration tests
        run: cargo test --test ref_test --test sqlite_test --test tls_example --test websocket_test --features=full

      - name: Memory leak soak (route commit-task JoinSet)
        run: cargo test --test memory_leak_test --features=full -- --ignored --nocapture

  # Compile the integration test binaries ONCE (release, full,test-utils) and
  # publish them as a nextest archive. The three run jobs below download this
  # archive instead of each recompiling the same binaries.
  integration-build:
    name: Integration — Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest

      - name: Cache cargo build
        uses: Swatinem/rust-cache@v2
        with:
          # Shared with the benchmark job so the full-feature dependency compile
          # is reused across jobs/runs.
          shared-key: release-full

      - name: Build nextest archive
        run: |
          cargo nextest archive \
            --release --features full,test-utils \
            --test integration_test --test armature_integration \
            --archive-file nextest-archive.tar.zst

      - name: Upload nextest archive
        uses: actions/upload-artifact@v4
        with:
          name: integration-nextest-archive
          path: nextest-archive.tar.zst
          retention-days: 1

  # Integration tests (requires Docker) split into parallel jobs. Each runs the
  # prebuilt nextest archive from integration-build — no recompilation.
  integration-others:
    name: Integration — Others
    runs-on: ubuntu-latest
    needs: integration-build
    services:
      docker:
        image: docker:dind
        options: --privileged
    steps:
      - uses: actions/checkout@v4

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest

      - name: Download nextest archive
        uses: actions/download-artifact@v4
        with:
          name: integration-nextest-archive

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

      - 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 nextest run --archive-file nextest-archive.tar.zst \
            --run-ignored all --no-capture \
            -E 'binary(integration_test) & test(=test_all_chaos)'

      - name: Run remaining integration tests (excluding chaos & performance)
        run: |
          cargo nextest run --archive-file nextest-archive.tar.zst \
            --run-ignored all --no-capture \
            -E 'binary(integration_test) & not test(=test_all_chaos) & not test(=test_all_performance_pipeline) & not test(=test_all_performance_direct)'

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

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest

      - name: Download nextest archive
        uses: actions/download-artifact@v4
        with:
          name: integration-nextest-archive

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

      - 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 nextest run --archive-file nextest-archive.tar.zst \
            --run-ignored all --no-capture \
            -E 'binary(integration_test) & test(=test_all_performance_pipeline)'

      - name: Run other performance tests
        run: |
          cargo nextest run --archive-file nextest-archive.tar.zst \
            --run-ignored all --no-capture \
            -E 'binary(integration_test) & test(=test_all_performance_direct)'

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

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest

      - name: Download nextest archive
        uses: actions/download-artifact@v4
        with:
          name: integration-nextest-archive

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

      - 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 nextest run --archive-file nextest-archive.tar.zst \
            --run-ignored all --no-capture \
            -E 'binary(armature_integration)'

  # Documentation
  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
      
      - name: Cache cargo build
        uses: Swatinem/rust-cache@v2
        with:
          # Differentiates the matrix `check` job per feature set; evaluates to an
          # empty string (no-op) in non-matrix jobs. rust-cache already keys on the
          # job id, OS, rustc version, and lockfiles automatically.
          key: ${{ matrix.features }}
      
      - name: Build documentation (deny warnings)
        run: RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps