mq-bridge 0.3.5

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

on:
  push:
    branches: [main, dev]
    paths:
      - ".github/workflows/node.yml"
      - "node/mq-bridge-node/**"
      - "Cargo.toml"
      - "Cargo.lock"
      - "src/**"
  pull_request:
    branches: [main, dev]
    paths:
      - ".github/workflows/node.yml"
      - "node/mq-bridge-node/**"
      - "Cargo.toml"
      - "Cargo.lock"
      - "src/**"
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  # Fast guard: catches package.json/package-lock.json drift (e.g. a version
  # bump that only half-updates the lock) before it reaches the publish flow,
  # where `npm ci` fails after all the native builds have already run.
  lock-sync:
    name: package-lock in sync
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
        with:
          persist-credentials: false

      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: npm
          cache-dependency-path: node/mq-bridge-node/package-lock.json

      - name: Verify lock is in sync
        working-directory: node/mq-bridge-node
        run: npm ci --ignore-scripts

  test:
    name: Node binding smoke test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
        with:
          persist-credentials: false

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

      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: npm
          cache-dependency-path: node/mq-bridge-node/package-lock.json

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

      - name: Install Node dependencies
        working-directory: node/mq-bridge-node
        run: npm ci

      - name: Check Rust binding
        run: cargo check -p mq-bridge-node --no-default-features --features "http middleware schema"

      - name: Build native addon
        working-directory: node/mq-bridge-node
        run: npm run build:ci

      - name: Run Node tests
        working-directory: node/mq-bridge-node
        run: npm test