| # Licensed to the Apache Software Foundation (ASF) under one | |
| # or more contributor license agreements. See the NOTICE file | |
| # distributed with this work for additional information | |
| # regarding copyright ownership. The ASF licenses this file | |
| # to you under the Apache License, Version 2.0 (the | |
| # "License"); you may not use this file except in compliance | |
| # with the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, | |
| # software distributed under the License is distributed on an | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| # KIND, either express or implied. See the License for the | |
| # specific language governing permissions and limitations | |
| # under the License. | |
| name: CI | |
| on: | |
| push: | |
| # Release branches too, so that a release candidate is tested where it's tagged (RELEASE.md). | |
| branches: [main, "branch-*"] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # The broker the integration checks run against. | |
| PULSAR_IMAGE: apachepulsar/pulsar:5.0.1 | |
| # The protoc that generated the committed code in crates/apache-pulsar-protocol/src/proto. | |
| PROTOC_VERSION: "33.1" | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup toolchain install stable --profile minimal --component clippy,rustfmt && rustup default stable | |
| - run: cargo fmt --all --check | |
| - run: cargo clippy --workspace --all-targets -- -D warnings | |
| # The codecs are features: a build without them must stay clean too. | |
| - run: cargo clippy -p apache-pulsar --no-default-features -- -D warnings | |
| - run: cargo test --workspace | |
| # Windows is built, not tested, at first (docs/8-quality.md §4): the crates and the workspace's binaries, without | |
| # the tests, which don't build there yet: the integration tests' testcontainers watchdog uses Unix signals. | |
| windows: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup toolchain install stable --profile minimal && rustup default stable | |
| - run: cargo build --locked --workspace --all-features | |
| codegen: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup toolchain install stable --profile minimal && rustup default stable | |
| - name: Install protoc | |
| run: | | |
| curl -sSfL -o /tmp/protoc.zip \ | |
| "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip" | |
| sudo unzip -q -o /tmp/protoc.zip -d /usr/local bin/protoc 'include/*' | |
| protoc --version | |
| - name: Generated protobuf code is up to date | |
| run: cargo run -p xtask -- codegen --check | |
| # Every file carries the ASF license header, except those .rat-excludes lists (docs/8-quality.md §5). Apache RAT | |
| # runs through jbang, as Pulsar's Helm chart runs it, but at 0.16.1: from 0.17, RAT takes Rust sources and shell | |
| # scripts for binary files (Apache Tika types .rs as application/rls-services+xml) and skips them. RAT exits 0 | |
| # whatever it finds, so the step fails unless its summary reports no unknown licenses. | |
| license: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check license headers with Apache RAT | |
| run: | | |
| curl -Ls https://sh.jbang.dev | bash -s - run org.apache.rat:apache-rat:0.16.1 -E .rat-excludes -d . 2>&1 \ | |
| | tee "$RUNNER_TEMP/rat.txt" | |
| grep -q '^0 Unknown Licenses$' "$RUNNER_TEMP/rat.txt" | |
| deny: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup toolchain install stable --profile minimal && rustup default stable | |
| - run: cargo install --locked cargo-deny | |
| - run: cargo deny check | |
| # The published crates build with the minimum supported Rust version, the one Cargo.toml states. | |
| msrv: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install the minimum supported Rust version | |
| run: | | |
| msrv=$(sed -n 's/^rust-version = "\(.*\)"$/\1/p' Cargo.toml) | |
| rustup toolchain install "$msrv" --profile minimal && rustup default "$msrv" | |
| - run: cargo check --locked -p apache-pulsar -p apache-pulsar-protocol --all-features | |
| # The crates as the release manager publishes them: packaged from an unpacked source archive, as a release's | |
| # source tarball holds the code (RELEASE.md). cargo builds each package, apache-pulsar against the | |
| # apache-pulsar-protocol it has just packaged, since that version isn't on crates.io yet. | |
| package: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup toolchain install stable --profile minimal && rustup default stable | |
| - name: Unpack a source archive of the commit | |
| run: mkdir "$RUNNER_TEMP/src" && git archive HEAD | tar -x -C "$RUNNER_TEMP/src" | |
| - name: What the packages hold | |
| working-directory: ${{ runner.temp }}/src | |
| run: cargo package --list -p apache-pulsar-protocol -p apache-pulsar | |
| - name: Package and verify, without uploading | |
| working-directory: ${{ runner.temp }}/src | |
| run: cargo publish --dry-run --locked -p apache-pulsar-protocol -p apache-pulsar | |
| compio-checks: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: ubuntu-latest, driver: io-uring } | |
| - { os: ubuntu-latest, driver: polling } | |
| - { os: macos-latest, driver: auto } | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup toolchain install stable --profile minimal && rustup default stable | |
| - run: cargo build --locked --release -p compio-checks | |
| - run: ./target/release/compio-checks --driver ${{ matrix.driver }} | |
| first-contact: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup toolchain install stable --profile minimal && rustup default stable | |
| - name: Start a standalone broker | |
| run: docker run -d --name pulsar -p 6650:6650 -p 8080:8080 "$PULSAR_IMAGE" bin/pulsar standalone | |
| - run: cargo build -p first-contact | |
| - name: Wait for the broker | |
| run: | | |
| for i in $(seq 1 90); do | |
| curl -sf http://127.0.0.1:8080/admin/v2/clusters && exit 0 | |
| sleep 2 | |
| done | |
| docker logs pulsar | |
| exit 1 | |
| - name: CONNECT handshake, with scalable topics advertised | |
| run: cargo run -p first-contact -- 127.0.0.1:6650 | |
| integration: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup toolchain install stable --profile minimal && rustup default stable | |
| - name: Integration tests, against a broker and a proxy that the harness starts in Docker | |
| run: cargo test -p apache-pulsar --test integration |