From 6a77930b0d1c507be20fcbf306937472212b8126 Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Wed, 4 Mar 2026 14:17:08 +0800 Subject: [PATCH 1/7] fix clang tidy check does not fail for failures --- build-support/run_clang_tidy.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build-support/run_clang_tidy.sh b/build-support/run_clang_tidy.sh index d6e068b9..7a967b84 100755 --- a/build-support/run_clang_tidy.sh +++ b/build-support/run_clang_tidy.sh @@ -33,9 +33,11 @@ done SCRIPT=$(which run-clang-tidy) set +e nproc -if [[ $? == 0 ]]; then - python3 $SCRIPT -p build -j$(nproc) $(cat files.txt) +if [[ $? == 0]]; then + NUM_THREADS=$(nproc) else - python3 $SCRIPT -p build -j8 $(cat files.txt) + NUM_THREADS=8 fi +set -e +python3 $SCRIPT -p build -j$(nproc) $(cat files.txt) rm -f files.txt From 3932b137df5453bfc4fdd5878a0ce4e8f7b0ddff Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Wed, 4 Mar 2026 14:23:40 +0800 Subject: [PATCH 2/7] fix script --- build-support/run_clang_tidy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-support/run_clang_tidy.sh b/build-support/run_clang_tidy.sh index 7a967b84..33419309 100755 --- a/build-support/run_clang_tidy.sh +++ b/build-support/run_clang_tidy.sh @@ -33,11 +33,11 @@ done SCRIPT=$(which run-clang-tidy) set +e nproc -if [[ $? == 0]]; then +if [[ $? == 0 ]]; then NUM_THREADS=$(nproc) else NUM_THREADS=8 fi set -e -python3 $SCRIPT -p build -j$(nproc) $(cat files.txt) +python3 $SCRIPT -p build -j$NUM_THREADS $(cat files.txt) rm -f files.txt From 62e93efa6dcb2e01f044150528de29da1cb44017 Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Wed, 4 Mar 2026 14:24:37 +0800 Subject: [PATCH 3/7] [DEBUG] Verify lint workflow --- .github/workflows/ci-pr-validation.yaml | 335 +----------------------- .github/workflows/codeql-analysis.yml | 73 ------ 2 files changed, 1 insertion(+), 407 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/ci-pr-validation.yaml b/.github/workflows/ci-pr-validation.yaml index 8d14e7de..8ab72013 100644 --- a/.github/workflows/ci-pr-validation.yaml +++ b/.github/workflows/ci-pr-validation.yaml @@ -29,57 +29,8 @@ concurrency: jobs: - formatting-check: - name: Formatting Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Run clang-format style check for C/C++/Protobuf programs. - uses: jidicula/clang-format-action@v4.11.0 - with: - clang-format-version: '11' - exclude-regex: '.*\.(proto|hpp)' - - wireshark-dissector-build: - name: Build the Wireshark dissector - needs: formatting-check - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - strategy: - matrix: - # TODO: support build on macos-14 - os: [ubuntu-latest] - - steps: - - name: checkout - uses: actions/checkout@v3 - - - name: Install deps (Ubuntu) - if: ${{ startsWith(matrix.os, 'ubuntu') }} - run: | - sudo apt-get update -y - sudo apt-get install -y protobuf-compiler libprotobuf-dev wireshark-dev - - - name: Install deps (macOS) - if: ${{ startsWith(matrix.os, 'macos') }} - run: | - # See https://github.com/Homebrew/homebrew-core/issues/157142 - export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 - cd /usr/local/bin - rm -f 2to3* idle3* pydoc* python3* - rm -f /usr/local/share/man/man1/python3.1 /usr/local/lib/pkgconfig/python3* - cd /usr/local/Frameworks/Python.framework - rm -rf Headers Python Resources Versions/Current - brew update - brew install pkg-config wireshark protobuf - - name: Build wireshark plugin - run: | - cmake -S wireshark -B build-wireshark - cmake --build build-wireshark - lint: name: Lint - needs: formatting-check runs-on: ubuntu-24.04 timeout-minutes: 120 @@ -111,295 +62,11 @@ jobs: exit 1 fi - unit-tests: - name: Run unit tests - needs: formatting-check - runs-on: ubuntu-24.04 - timeout-minutes: 120 - - steps: - - name: checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - submodules: recursive - - - name: Restore vcpkg installed cache - uses: actions/cache@v4 - with: - path: | - build/vcpkg_installed - build-boost-asio/vcpkg_installed - key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'CMakeLists.txt', 'vcpkg-triplets/**') }} - restore-keys: vcpkg-${{ runner.os }}- - - - name: Build core libraries - run: | - cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=OFF - cmake --build build -j8 - - - name: Check formatting - run: | - ./vcpkg/vcpkg format-manifest vcpkg.json - if [[ $(git diff | wc -l) -gt 0 ]]; then - echo "Please run `./vcpkg/vcpkg format-manifest vcpkg.json` to reformat vcpkg.json" - exit 1 - fi - - - name: Build tests - run: | - cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - cmake --build build -j8 - - - name: Install gtest-parallel - run: | - sudo curl -o /gtest-parallel https://raw.githubusercontent.com/google/gtest-parallel/master/gtest_parallel.py - - - name: Run unit tests - run: RETRY_FAILED=3 CMAKE_BUILD_DIRECTORY=./build ./run-unit-tests.sh - - - name: Build with Boost.Asio - run: | - cmake -B build-boost-asio -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON - cmake --build build-boost-asio -j8 - - - name: Build perf tools - run: | - cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DBUILD_PERF_TOOLS=ON - cmake --build build -j8 - - - name: Verify custom vcpkg installation - run: | - mv vcpkg /tmp/vcpkg-custom - cmake -B build-2 -DINTEGRATE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE="/tmp/vcpkg-custom/scripts/buildsystems/vcpkg.cmake" - - cpp20-build: - name: Build with the C++20 standard - needs: lint - runs-on: ubuntu-22.04 - timeout-minutes: 60 - - steps: - - name: checkout - uses: actions/checkout@v3 - - name: Install deps - run: | - sudo apt-get update -y - sudo apt-get install -y libcurl4-openssl-dev libssl-dev \ - protobuf-compiler libprotobuf-dev libboost-dev \ - libboost-dev libboost-program-options-dev \ - libzstd-dev libsnappy-dev libgmock-dev libgtest-dev - - name: CMake - run: cmake -B build -DBUILD_PERF_TOOLS=ON -DCMAKE_CXX_STANDARD=20 - - name: Build - run: | - cmake --build build -j8 --target pulsarShared pulsarStatic - cmake --build build -j8 - - cpp-build-windows: - timeout-minutes: 120 - name: Build CPP Client on ${{ matrix.name }} - needs: unit-tests - runs-on: ${{ matrix.os }} - env: - VCPKG_ROOT: '${{ github.workspace }}/vcpkg' - INSTALL_DIR: 'C:\\pulsar-cpp' - strategy: - fail-fast: false - matrix: - include: - - name: 'Windows x64' - os: windows-2022 - triplet: x64-windows-static - suffix: 'windows-win64' - generator: 'Visual Studio 17 2022' - arch: '-A x64' - - name: 'Windows x86' - os: windows-2022 - triplet: x86-windows-static - suffix: 'windows-win32' - generator: 'Visual Studio 17 2022' - arch: '-A Win32' - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - name: Restore vcpkg and its artifacts. - uses: actions/cache@v4 - id: vcpkg-cache - continue-on-error: true - with: - path: | - ${{ github.workspace }}/vcpkg_installed - ${{ env.VCPKG_ROOT }}/downloads - ${{ env.VCPKG_ROOT }}/vcpkg.exe - key: ${{ runner.os }}-${{ matrix.triplet }}-vcpkg-${{ hashFiles('vcpkg.json') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.triplet }}-vcpkg- - save-always: true - - - name: Get vcpkg(windows) - if: ${{ runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' }} - shell: pwsh - run: | - cd ${{ github.workspace }} - mkdir build -Force - # If vcpkg.exe already exists, skip bootstrapping to save time and avoid - # modifying the checked-out vcpkg directory. - if (Test-Path "${{ github.workspace }}\\vcpkg\\vcpkg.exe") { - Write-Host "vcpkg.exe present — skipping bootstrap" - } else { - if (Test-Path vcpkg) { - # If vcpkg was checked out as a submodule it may be shallow; fetch full history - git -C vcpkg fetch --unshallow || true - } else { - git clone https://github.com/Microsoft/vcpkg.git - } - Push-Location vcpkg - .\bootstrap-vcpkg.bat - Pop-Location - } - - - name: remove system vcpkg(windows) - if: runner.os == 'Windows' - run: rm -rf "$VCPKG_INSTALLATION_ROOT" - shell: bash - - - name: Install vcpkg packages - run: | - ${{ env.VCPKG_ROOT }}\vcpkg.exe install --triplet ${{ matrix.triplet }} - - - name: Configure - shell: bash - run: | - if [ "$RUNNER_OS" == "Windows" ]; then - cmake \ - -B ./build-1 \ - -G "${{ matrix.generator }}" ${{ matrix.arch }} \ - -DUSE_ASIO=ON \ - -DBUILD_TESTS=OFF \ - -DVCPKG_TRIPLET="${{ matrix.triplet }}" \ - -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_DIR }}" \ - -S . - fi - - - name: Install - shell: bash - run: | - if [ "$RUNNER_OS" == "Windows" ]; then - cmake --build ./build-1 --parallel --config Release - cmake --install ./build-1 - fi - - - name: Test examples - shell: bash - run: | - if [ "$RUNNER_OS" == "Windows" ]; then - cd win-examples - cmake \ - -G "${{ matrix.generator }}" ${{ matrix.arch }} \ - -DLINK_STATIC=OFF \ - -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }} \ - -B build-dynamic - cmake --build build-dynamic --config Release - cmake \ - -G "${{ matrix.generator }}" ${{ matrix.arch }} \ - -DLINK_STATIC=ON \ - -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }} \ - -B build-static - cmake --build build-static --config Release - ./build-static/Release/win-example.exe - fi - - - name: Build (Debug) - shell: bash - run: | - if [ "$RUNNER_OS" == "Windows" ]; then - cmake \ - -B ./build-2 \ - -G "${{ matrix.generator }}" ${{ matrix.arch }} \ - -DUSE_ASIO=ON \ - -DBUILD_TESTS=OFF \ - -DVCPKG_TRIPLET="${{ matrix.triplet }}" \ - -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_DIR }}" \ - -DCMAKE_BUILD_TYPE=Debug \ - -S . - cmake --build ./build-2 --parallel --config Debug - fi - - package: - name: Build ${{matrix.pkg.name}} ${{matrix.cpu.platform}} - runs-on: ubuntu-22.04 - needs: [lint, unit-tests] - timeout-minutes: 500 - - strategy: - fail-fast: true - matrix: - pkg: - - { name: 'RPM', type: 'rpm', path: 'pkg/rpm/RPMS' } - - { name: 'Deb', type: 'deb', path: 'pkg/deb/BUILD/DEB' } - - { name: 'Alpine', type: 'apk', path: 'pkg/apk/build' } - cpu: - - { arch: 'x86_64', platform: 'x86_64' } - - steps: - - name: checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Package Pulsar source - run: build-support/generate-source-archive.sh - - - uses: docker/setup-buildx-action@v2 - - - name: Build dependencies Docker image - uses: docker/build-push-action@v3 - with: - context: ./pkg/${{matrix.pkg.type}} - load: true - tags: build:latest - platforms: linux/${{matrix.cpu.platform}} - build-args: PLATFORM=${{matrix.cpu.arch}} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Build packages - run: pkg/${{matrix.pkg.type}}/docker-build-${{matrix.pkg.type}}-${{matrix.cpu.platform}}.sh build:latest - - # TODO: verify the pre-built package works without linking issue - - cpp-build-macos: - timeout-minutes: 120 - name: Build CPP Client on macOS with static dependencies - runs-on: macos-14 - needs: lint - steps: - - name: checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - submodules: recursive - - - name: Restore vcpkg installed cache - uses: actions/cache@v4 - with: - path: build-osx/vcpkg_installed - key: vcpkg-${{ runner.os }}-arm64-${{ hashFiles('vcpkg.json', 'CMakeLists.txt', 'vcpkg-triplets/**') }} - restore-keys: vcpkg-${{ runner.os }}-arm64- - - - name: Build libraries - run: ./pkg/mac/build-static-library.sh - # Job that will be required to complete and depends on all the other jobs check-completion: name: Check Completion runs-on: ubuntu-latest - needs: [formatting-check, wireshark-dissector-build, lint, unit-tests, cpp20-build, cpp-build-windows, package, cpp-build-macos] + needs: [lint] steps: - run: true diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index c877c642..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,73 +0,0 @@ -# -# 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: "CodeQL" - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - schedule: - - cron: '16 21 * * 2' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-22.04 - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'cpp' ] - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - submodules: recursive - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - - - name: Install deps - run: | - sudo apt-get update -y - sudo apt-get install -y libcurl4-openssl-dev libssl-dev \ - protobuf-compiler libprotobuf-dev libboost-dev \ - libboost-dev libboost-program-options-dev \ - libzstd-dev libsnappy-dev - - - name: Build - run: | - cmake . -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=OFF -DBUILD_STATIC_LIB=OFF -DBUILD_PERF_TOOLS=ON - cmake --build . -j8 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" From 67288795e1ddf9245c34844fe03e4b6beb7ab137 Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Wed, 4 Mar 2026 14:35:13 +0800 Subject: [PATCH 4/7] Revert "[DEBUG] Verify lint workflow" This reverts commit 62e93efa6dcb2e01f044150528de29da1cb44017. --- .github/workflows/ci-pr-validation.yaml | 335 +++++++++++++++++++++++- .github/workflows/codeql-analysis.yml | 73 ++++++ 2 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/ci-pr-validation.yaml b/.github/workflows/ci-pr-validation.yaml index 8ab72013..8d14e7de 100644 --- a/.github/workflows/ci-pr-validation.yaml +++ b/.github/workflows/ci-pr-validation.yaml @@ -29,8 +29,57 @@ concurrency: jobs: + formatting-check: + name: Formatting Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run clang-format style check for C/C++/Protobuf programs. + uses: jidicula/clang-format-action@v4.11.0 + with: + clang-format-version: '11' + exclude-regex: '.*\.(proto|hpp)' + + wireshark-dissector-build: + name: Build the Wireshark dissector + needs: formatting-check + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + strategy: + matrix: + # TODO: support build on macos-14 + os: [ubuntu-latest] + + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: Install deps (Ubuntu) + if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: | + sudo apt-get update -y + sudo apt-get install -y protobuf-compiler libprotobuf-dev wireshark-dev + + - name: Install deps (macOS) + if: ${{ startsWith(matrix.os, 'macos') }} + run: | + # See https://github.com/Homebrew/homebrew-core/issues/157142 + export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 + cd /usr/local/bin + rm -f 2to3* idle3* pydoc* python3* + rm -f /usr/local/share/man/man1/python3.1 /usr/local/lib/pkgconfig/python3* + cd /usr/local/Frameworks/Python.framework + rm -rf Headers Python Resources Versions/Current + brew update + brew install pkg-config wireshark protobuf + - name: Build wireshark plugin + run: | + cmake -S wireshark -B build-wireshark + cmake --build build-wireshark + lint: name: Lint + needs: formatting-check runs-on: ubuntu-24.04 timeout-minutes: 120 @@ -62,11 +111,295 @@ jobs: exit 1 fi + unit-tests: + name: Run unit tests + needs: formatting-check + runs-on: ubuntu-24.04 + timeout-minutes: 120 + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + + - name: Restore vcpkg installed cache + uses: actions/cache@v4 + with: + path: | + build/vcpkg_installed + build-boost-asio/vcpkg_installed + key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'CMakeLists.txt', 'vcpkg-triplets/**') }} + restore-keys: vcpkg-${{ runner.os }}- + + - name: Build core libraries + run: | + cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=OFF + cmake --build build -j8 + + - name: Check formatting + run: | + ./vcpkg/vcpkg format-manifest vcpkg.json + if [[ $(git diff | wc -l) -gt 0 ]]; then + echo "Please run `./vcpkg/vcpkg format-manifest vcpkg.json` to reformat vcpkg.json" + exit 1 + fi + + - name: Build tests + run: | + cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + cmake --build build -j8 + + - name: Install gtest-parallel + run: | + sudo curl -o /gtest-parallel https://raw.githubusercontent.com/google/gtest-parallel/master/gtest_parallel.py + + - name: Run unit tests + run: RETRY_FAILED=3 CMAKE_BUILD_DIRECTORY=./build ./run-unit-tests.sh + + - name: Build with Boost.Asio + run: | + cmake -B build-boost-asio -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON + cmake --build build-boost-asio -j8 + + - name: Build perf tools + run: | + cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DBUILD_PERF_TOOLS=ON + cmake --build build -j8 + + - name: Verify custom vcpkg installation + run: | + mv vcpkg /tmp/vcpkg-custom + cmake -B build-2 -DINTEGRATE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE="/tmp/vcpkg-custom/scripts/buildsystems/vcpkg.cmake" + + cpp20-build: + name: Build with the C++20 standard + needs: lint + runs-on: ubuntu-22.04 + timeout-minutes: 60 + + steps: + - name: checkout + uses: actions/checkout@v3 + - name: Install deps + run: | + sudo apt-get update -y + sudo apt-get install -y libcurl4-openssl-dev libssl-dev \ + protobuf-compiler libprotobuf-dev libboost-dev \ + libboost-dev libboost-program-options-dev \ + libzstd-dev libsnappy-dev libgmock-dev libgtest-dev + - name: CMake + run: cmake -B build -DBUILD_PERF_TOOLS=ON -DCMAKE_CXX_STANDARD=20 + - name: Build + run: | + cmake --build build -j8 --target pulsarShared pulsarStatic + cmake --build build -j8 + + cpp-build-windows: + timeout-minutes: 120 + name: Build CPP Client on ${{ matrix.name }} + needs: unit-tests + runs-on: ${{ matrix.os }} + env: + VCPKG_ROOT: '${{ github.workspace }}/vcpkg' + INSTALL_DIR: 'C:\\pulsar-cpp' + strategy: + fail-fast: false + matrix: + include: + - name: 'Windows x64' + os: windows-2022 + triplet: x64-windows-static + suffix: 'windows-win64' + generator: 'Visual Studio 17 2022' + arch: '-A x64' + - name: 'Windows x86' + os: windows-2022 + triplet: x86-windows-static + suffix: 'windows-win32' + generator: 'Visual Studio 17 2022' + arch: '-A Win32' + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Restore vcpkg and its artifacts. + uses: actions/cache@v4 + id: vcpkg-cache + continue-on-error: true + with: + path: | + ${{ github.workspace }}/vcpkg_installed + ${{ env.VCPKG_ROOT }}/downloads + ${{ env.VCPKG_ROOT }}/vcpkg.exe + key: ${{ runner.os }}-${{ matrix.triplet }}-vcpkg-${{ hashFiles('vcpkg.json') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.triplet }}-vcpkg- + save-always: true + + - name: Get vcpkg(windows) + if: ${{ runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' }} + shell: pwsh + run: | + cd ${{ github.workspace }} + mkdir build -Force + # If vcpkg.exe already exists, skip bootstrapping to save time and avoid + # modifying the checked-out vcpkg directory. + if (Test-Path "${{ github.workspace }}\\vcpkg\\vcpkg.exe") { + Write-Host "vcpkg.exe present — skipping bootstrap" + } else { + if (Test-Path vcpkg) { + # If vcpkg was checked out as a submodule it may be shallow; fetch full history + git -C vcpkg fetch --unshallow || true + } else { + git clone https://github.com/Microsoft/vcpkg.git + } + Push-Location vcpkg + .\bootstrap-vcpkg.bat + Pop-Location + } + + - name: remove system vcpkg(windows) + if: runner.os == 'Windows' + run: rm -rf "$VCPKG_INSTALLATION_ROOT" + shell: bash + + - name: Install vcpkg packages + run: | + ${{ env.VCPKG_ROOT }}\vcpkg.exe install --triplet ${{ matrix.triplet }} + + - name: Configure + shell: bash + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + cmake \ + -B ./build-1 \ + -G "${{ matrix.generator }}" ${{ matrix.arch }} \ + -DUSE_ASIO=ON \ + -DBUILD_TESTS=OFF \ + -DVCPKG_TRIPLET="${{ matrix.triplet }}" \ + -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_DIR }}" \ + -S . + fi + + - name: Install + shell: bash + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + cmake --build ./build-1 --parallel --config Release + cmake --install ./build-1 + fi + + - name: Test examples + shell: bash + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + cd win-examples + cmake \ + -G "${{ matrix.generator }}" ${{ matrix.arch }} \ + -DLINK_STATIC=OFF \ + -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }} \ + -B build-dynamic + cmake --build build-dynamic --config Release + cmake \ + -G "${{ matrix.generator }}" ${{ matrix.arch }} \ + -DLINK_STATIC=ON \ + -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }} \ + -B build-static + cmake --build build-static --config Release + ./build-static/Release/win-example.exe + fi + + - name: Build (Debug) + shell: bash + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + cmake \ + -B ./build-2 \ + -G "${{ matrix.generator }}" ${{ matrix.arch }} \ + -DUSE_ASIO=ON \ + -DBUILD_TESTS=OFF \ + -DVCPKG_TRIPLET="${{ matrix.triplet }}" \ + -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_DIR }}" \ + -DCMAKE_BUILD_TYPE=Debug \ + -S . + cmake --build ./build-2 --parallel --config Debug + fi + + package: + name: Build ${{matrix.pkg.name}} ${{matrix.cpu.platform}} + runs-on: ubuntu-22.04 + needs: [lint, unit-tests] + timeout-minutes: 500 + + strategy: + fail-fast: true + matrix: + pkg: + - { name: 'RPM', type: 'rpm', path: 'pkg/rpm/RPMS' } + - { name: 'Deb', type: 'deb', path: 'pkg/deb/BUILD/DEB' } + - { name: 'Alpine', type: 'apk', path: 'pkg/apk/build' } + cpu: + - { arch: 'x86_64', platform: 'x86_64' } + + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Package Pulsar source + run: build-support/generate-source-archive.sh + + - uses: docker/setup-buildx-action@v2 + + - name: Build dependencies Docker image + uses: docker/build-push-action@v3 + with: + context: ./pkg/${{matrix.pkg.type}} + load: true + tags: build:latest + platforms: linux/${{matrix.cpu.platform}} + build-args: PLATFORM=${{matrix.cpu.arch}} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build packages + run: pkg/${{matrix.pkg.type}}/docker-build-${{matrix.pkg.type}}-${{matrix.cpu.platform}}.sh build:latest + + # TODO: verify the pre-built package works without linking issue + + cpp-build-macos: + timeout-minutes: 120 + name: Build CPP Client on macOS with static dependencies + runs-on: macos-14 + needs: lint + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + + - name: Restore vcpkg installed cache + uses: actions/cache@v4 + with: + path: build-osx/vcpkg_installed + key: vcpkg-${{ runner.os }}-arm64-${{ hashFiles('vcpkg.json', 'CMakeLists.txt', 'vcpkg-triplets/**') }} + restore-keys: vcpkg-${{ runner.os }}-arm64- + + - name: Build libraries + run: ./pkg/mac/build-static-library.sh + # Job that will be required to complete and depends on all the other jobs check-completion: name: Check Completion runs-on: ubuntu-latest - needs: [lint] + needs: [formatting-check, wireshark-dissector-build, lint, unit-tests, cpp20-build, cpp-build-windows, package, cpp-build-macos] steps: - run: true diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..c877c642 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,73 @@ +# +# 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: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '16 21 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-22.04 + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + + - name: Install deps + run: | + sudo apt-get update -y + sudo apt-get install -y libcurl4-openssl-dev libssl-dev \ + protobuf-compiler libprotobuf-dev libboost-dev \ + libboost-dev libboost-program-options-dev \ + libzstd-dev libsnappy-dev + + - name: Build + run: | + cmake . -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=OFF -DBUILD_STATIC_LIB=OFF -DBUILD_PERF_TOOLS=ON + cmake --build . -j8 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" From 6c89100947f2669f76dc6fda17177d1599284aa5 Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Wed, 4 Mar 2026 15:29:55 +0800 Subject: [PATCH 5/7] improve cache mechanism --- .github/workflows/ci-pr-validation.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-pr-validation.yaml b/.github/workflows/ci-pr-validation.yaml index 8d14e7de..b5a0973c 100644 --- a/.github/workflows/ci-pr-validation.yaml +++ b/.github/workflows/ci-pr-validation.yaml @@ -92,9 +92,11 @@ jobs: - name: Restore vcpkg installed cache uses: actions/cache@v4 + id: vcpkg-cache + if: always() && steps.vcpkg-cache.outputs.cache-hit != 'true' with: path: build/vcpkg_installed - key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'CMakeLists.txt', 'vcpkg-triplets/**') }} + key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json') }} restore-keys: vcpkg-${{ runner.os }}- - name: Build the project @@ -126,11 +128,13 @@ jobs: - name: Restore vcpkg installed cache uses: actions/cache@v4 + id: vcpkg-cache + if: always() && steps.vcpkg-cache.outputs.cache-hit != 'true' with: path: | build/vcpkg_installed build-boost-asio/vcpkg_installed - key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'CMakeLists.txt', 'vcpkg-triplets/**') }} + key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json') }} restore-keys: vcpkg-${{ runner.os }}- - name: Build core libraries @@ -168,11 +172,6 @@ jobs: cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DBUILD_PERF_TOOLS=ON cmake --build build -j8 - - name: Verify custom vcpkg installation - run: | - mv vcpkg /tmp/vcpkg-custom - cmake -B build-2 -DINTEGRATE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE="/tmp/vcpkg-custom/scripts/buildsystems/vcpkg.cmake" - cpp20-build: name: Build with the C++20 standard needs: lint @@ -229,7 +228,7 @@ jobs: - name: Restore vcpkg and its artifacts. uses: actions/cache@v4 id: vcpkg-cache - continue-on-error: true + if: always() && steps.vcpkg-cache.outputs.cache-hit != 'true' with: path: | ${{ github.workspace }}/vcpkg_installed @@ -238,7 +237,6 @@ jobs: key: ${{ runner.os }}-${{ matrix.triplet }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | ${{ runner.os }}-${{ matrix.triplet }}-vcpkg- - save-always: true - name: Get vcpkg(windows) if: ${{ runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' }} @@ -387,9 +385,11 @@ jobs: - name: Restore vcpkg installed cache uses: actions/cache@v4 + id: vcpkg-cache + if: always() && steps.vcpkg-cache.outputs.cache-hit != 'true' with: path: build-osx/vcpkg_installed - key: vcpkg-${{ runner.os }}-arm64-${{ hashFiles('vcpkg.json', 'CMakeLists.txt', 'vcpkg-triplets/**') }} + key: vcpkg-${{ runner.os }}-arm64-${{ hashFiles('vcpkg.json') }} restore-keys: vcpkg-${{ runner.os }}-arm64- - name: Build libraries From b52631f141d9de11498f5ed437ca2bde445495ad Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Wed, 4 Mar 2026 15:36:43 +0800 Subject: [PATCH 6/7] fix clang-tidy error --- lib/ClientConnection.cc | 2 +- tests/TlsNegotiationTest.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ClientConnection.cc b/lib/ClientConnection.cc index 8665a7e4..0a850ed0 100644 --- a/lib/ClientConnection.cc +++ b/lib/ClientConnection.cc @@ -597,7 +597,7 @@ void ClientConnection::tcpConnectAsync() { auto weakSelf = weak_from_this(); resolver_->async_resolve(service_url.host(), std::to_string(service_url.port()), - [weakSelf](const ASIO_ERROR& err, tcp::resolver::results_type results) { + [weakSelf](auto err, const auto& results) { auto self = weakSelf.lock(); if (self) { self->handleResolve(err, results); diff --git a/tests/TlsNegotiationTest.cc b/tests/TlsNegotiationTest.cc index 64f956d5..9ceafad5 100644 --- a/tests/TlsNegotiationTest.cc +++ b/tests/TlsNegotiationTest.cc @@ -135,7 +135,7 @@ TEST(TlsNegotiationTest, testTls12) { // It will fail to create producer because mock server doesn't speak Pulsar, // but we only care about the handshake. Producer producer; - client.createProducerAsync("topic", [](Result, Producer) {}); + client.createProducerAsync("topic", [](auto, const auto&) {}); // Wait for handshake ASSERT_TRUE(handshakeFuture.get()); From f1f211a10dca827b53c95fda959b22275e5527b5 Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Wed, 4 Mar 2026 16:28:43 +0800 Subject: [PATCH 7/7] fix --- tests/TlsNegotiationTest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TlsNegotiationTest.cc b/tests/TlsNegotiationTest.cc index 9ceafad5..84dd55ea 100644 --- a/tests/TlsNegotiationTest.cc +++ b/tests/TlsNegotiationTest.cc @@ -170,7 +170,7 @@ TEST(TlsNegotiationTest, testTls13) { Client client(serviceUrl, config); - client.createProducerAsync("topic", [](Result, Producer) {}); + client.createProducerAsync("topic", [](auto, const auto&) {}); ASSERT_TRUE(handshakeFuture.get());