Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
308 changes: 9 additions & 299 deletions .github/workflows/ci-pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,292 +28,19 @@ concurrency:
cancel-in-progress: true

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/[email protected]
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

steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive

- name: Build the project
run: |
cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build build -j8

- name: Tidy check
run: |
sudo apt-get install -y clang-tidy
./build-support/run_clang_tidy.sh
if [[ $? -ne 0 ]]; then
echo "clang-tidy failed"
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: 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/
cmake -B build-2 -DINTEGRATE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE="/tmp/vcpkg/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:
- name: checkout
uses: actions/checkout@v3

- name: Restore vcpkg and its artifacts.
uses: actions/cache@v3
id: vcpkg-cache
with:
path: |
${{ env.VCPKG_ROOT }}
vcpkg_installed
!${{ env.VCPKG_ROOT }}/.git
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
key: |
${{ runner.os }}-${{ matrix.triplet}}-${{ hashFiles( 'vcpkg.json' ) }}

- name: Get vcpkg(windows)
if: ${{ runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' }}
run: |
cd ${{ github.workspace }}
mkdir build -force
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat

- 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:
package-linux:
name: Build ${{matrix.pkg.name}} ${{matrix.cpu.platform}}
runs-on: ubuntu-22.04
needs: [lint, unit-tests]
timeout-minutes: 500

strategy:
fail-fast: true
fail-fast: false
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' }
- { arch: 'aarch64', platform: 'arm64' }

steps:
- name: checkout
Expand Down Expand Up @@ -341,28 +68,11 @@ jobs:
- 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
- name: Zip artifact
run: zip -r ${{matrix.pkg.type}}-${{matrix.cpu.platform}}.zip ${{matrix.pkg.path}}

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
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
fetch-depth: 0
submodules: recursive

- 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]

steps:
- run: true
name: ${{matrix.pkg.type}}-${{matrix.cpu.platform}}
path: ${{matrix.pkg.path}}
7 changes: 5 additions & 2 deletions pkg/apk/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ build() {
set +e
cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_MAKE_PROGRAM=make \
-DCMAKE_INSTALL_PREFIX="$pkgdir" \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON \
$ROOT_DIR
if [[ $? -ne 0 ]]; then
Expand All @@ -53,8 +53,11 @@ build() {
fi
set -e
cmake --build build -j8
$ROOT_DIR/build-support/merge_archives_vcpkg.sh $PWD/build
}

package() {
cmake --build build --target install
set -x -e
DESTDIR="$pkgdir" cmake --build build --target install
cp ./build/libpulsarwithdeps.a "$pkgdir/usr/lib/"
}
9 changes: 9 additions & 0 deletions pkg/apk/build-apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ sudo abuild-keygen -a -i -n
abuild -F -c -r

cp -r /root/packages/pkg ./build

# Test installation
apk add --allow-untrusted build/$PLATFORM/*.apk

cd $ROOT_DIR/win-examples
g++ -o dynamic.out -std=c++11 ./example.cc -Wl,-rpath=/usr/lib -lpulsar
./dynamic.out
g++ -o static.out -std=c++11 ./example.cc /usr/lib/libpulsarwithdeps.a -lpthread -ldl
./static.out