@@ -29,15 +29,59 @@ concurrency:
2929
3030jobs :
3131
32- package-macos :
33- name : Build macOS libraries
34- runs-on : macos-14
35- timeout-minutes : 500
32+ formatting-check :
33+ name : Formatting Check
34+ runs-on : ubuntu-latest
35+ steps :
36+ - uses : actions/checkout@v3
37+ - name : Run clang-format style check for C/C++/Protobuf programs.
38+ 39+ with :
40+ clang-format-version : ' 11'
41+ exclude-regex : ' .*\.(proto|hpp)'
3642
43+ wireshark-dissector-build :
44+ name : Build the Wireshark dissector
45+ needs : formatting-check
46+ runs-on : ${{ matrix.os }}
47+ timeout-minutes : 60
3748 strategy :
38- fail-fast : false
3949 matrix :
40- arch : [x86_64, arm64]
50+ # TODO: support build on macos-14
51+ os : [ubuntu-20.04]
52+
53+ steps :
54+ - name : checkout
55+ uses : actions/checkout@v3
56+
57+ - name : Install deps (Ubuntu)
58+ if : ${{ startsWith(matrix.os, 'ubuntu') }}
59+ run : |
60+ sudo apt-get update -y
61+ sudo apt-get install -y protobuf-compiler libprotobuf-dev wireshark-dev
62+
63+ - name : Install deps (macOS)
64+ if : ${{ startsWith(matrix.os, 'macos') }}
65+ run : |
66+ # See https://github.com/Homebrew/homebrew-core/issues/157142
67+ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
68+ cd /usr/local/bin
69+ rm -f 2to3* idle3* pydoc* python3*
70+ rm -f /usr/local/share/man/man1/python3.1 /usr/local/lib/pkgconfig/python3*
71+ cd /usr/local/Frameworks/Python.framework
72+ rm -rf Headers Python Resources Versions/Current
73+ brew update
74+ brew install pkg-config wireshark protobuf
75+ - name : Build wireshark plugin
76+ run : |
77+ cmake -S wireshark -B build-wireshark
78+ cmake --build build-wireshark
79+
80+ unit-tests :
81+ name : Run unit tests
82+ needs : formatting-check
83+ runs-on : ubuntu-22.04
84+ timeout-minutes : 120
4185
4286 steps :
4387 - name : checkout
@@ -46,37 +90,270 @@ jobs:
4690 fetch-depth : 0
4791 submodules : recursive
4892
49- - name : Install dependencies
93+ - name : Build core libraries
94+ run : |
95+ cmake . -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=OFF
96+ cmake --build . -j8
97+
98+ - name : Check formatting
99+ run : |
100+ ./vcpkg/vcpkg format-manifest vcpkg.json
101+ if [[ $(git diff | wc -l) -gt 0 ]]; then
102+ echo "Please run `./vcpkg/vcpkg format-manifest vcpkg.json` to reformat vcpkg.json"
103+ exit 1
104+ fi
105+
106+ - name : Build tests
107+ run : |
108+ cmake . -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON
109+ cmake --build . -j8
110+
111+ - name : Install gtest-parallel
112+ run : |
113+ sudo curl -o /gtest-parallel https://raw.githubusercontent.com/google/gtest-parallel/master/gtest_parallel.py
114+
115+ - name : Run unit tests
116+ run : RETRY_FAILED=3 ./run-unit-tests.sh
117+
118+ - name : Build perf tools
119+ run : |
120+ cmake . -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DBUILD_PERF_TOOLS=ON
121+ cmake --build . -j8
122+
123+ - name : Verify custom vcpkg installation
124+ run : |
125+ mv vcpkg /tmp/
126+ cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE="/tmp/vcpkg/scripts/buildsystems/vcpkg.cmake"
127+
128+ cpp20-build :
129+ name : Build with the C++20 standard
130+ needs : formatting-check
131+ runs-on : ubuntu-22.04
132+ timeout-minutes : 60
133+
134+ steps :
135+ - name : checkout
136+ uses : actions/checkout@v3
137+ - name : Install deps
138+ run : |
139+ sudo apt-get update -y
140+ sudo apt-get install -y libcurl4-openssl-dev libssl-dev \
141+ protobuf-compiler libprotobuf-dev libboost-dev \
142+ libboost-dev libboost-program-options-dev \
143+ libzstd-dev libsnappy-dev libgmock-dev libgtest-dev
144+ - name : CMake
145+ run : cmake -B build -DBUILD_PERF_TOOLS=ON -DCMAKE_CXX_STANDARD=20
146+ - name : Build
147+ run : |
148+ cmake --build build -j8 --target pulsarShared pulsarStatic
149+ cmake --build build -j8
150+
151+ cpp-build-windows :
152+ timeout-minutes : 120
153+ name : Build CPP Client on ${{ matrix.name }}
154+ needs : unit-tests
155+ runs-on : ${{ matrix.os }}
156+ env :
157+ VCPKG_ROOT : ' ${{ github.workspace }}/vcpkg'
158+ INSTALL_DIR : ' C:\\pulsar-cpp'
159+ strategy :
160+ fail-fast : false
161+ matrix :
162+ include :
163+ - name : ' Windows x64'
164+ os : windows-2019
165+ triplet : x64-windows-static
166+ suffix : ' windows-win64'
167+ generator : ' Visual Studio 16 2019'
168+ arch : ' -A x64'
169+ - name : ' Windows x86'
170+ os : windows-2019
171+ triplet : x86-windows-static
172+ suffix : ' windows-win32'
173+ generator : ' Visual Studio 16 2019'
174+ arch : ' -A Win32'
175+
176+ steps :
177+ - name : checkout
178+ uses : actions/checkout@v3
179+
180+ - name : Restore vcpkg and its artifacts.
181+ uses : actions/cache@v3
182+ id : vcpkg-cache
183+ with :
184+ path : |
185+ ${{ env.VCPKG_ROOT }}
186+ vcpkg_installed
187+ !${{ env.VCPKG_ROOT }}/.git
188+ !${{ env.VCPKG_ROOT }}/buildtrees
189+ !${{ env.VCPKG_ROOT }}/packages
190+ !${{ env.VCPKG_ROOT }}/downloads
191+ key : |
192+ ${{ runner.os }}-${{ matrix.triplet}}-${{ hashFiles( 'vcpkg.json' ) }}
193+
194+ - name : Get vcpkg(windows)
195+ if : ${{ runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' }}
196+ run : |
197+ cd ${{ github.workspace }}
198+ mkdir build -force
199+ git clone https://github.com/Microsoft/vcpkg.git
200+ cd vcpkg
201+ .\bootstrap-vcpkg.bat
202+
203+ - name : remove system vcpkg(windows)
204+ if : runner.os == 'Windows'
205+ run : rm -rf "$VCPKG_INSTALLATION_ROOT"
206+ shell : bash
207+
208+ - name : Install vcpkg packages
209+ run : |
210+ ${{ env.VCPKG_ROOT }}\vcpkg.exe install --triplet ${{ matrix.triplet }}
211+
212+ - name : Configure
213+ shell : bash
214+ run : |
215+ if [ "$RUNNER_OS" == "Windows" ]; then
216+ cmake \
217+ -B ./build-1 \
218+ -G "${{ matrix.generator }}" ${{ matrix.arch }} \
219+ -DUSE_ASIO=ON \
220+ -DBUILD_TESTS=OFF \
221+ -DVCPKG_TRIPLET="${{ matrix.triplet }}" \
222+ -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_DIR }}" \
223+ -S .
224+ fi
225+
226+ - name : Install
227+ shell : bash
50228 run : |
51- export ARCH=${{ matrix.arch }}
52- ./pkg/mac/build-static-library.sh
229+ if [ "$RUNNER_OS" == "Windows" ]; then
230+ cmake --build ./build-1 --parallel --config Release
231+ cmake --install ./build-1
232+ fi
53233
54- - name : Test static libraries
234+ - name : Test examples
235+ shell : bash
55236 run : |
56- export PULSAR_DIR=$PWD/pkg/mac/.install
57- echo "Build with dynamic library"
58- clang++ win-examples/example.cc -o dynamic.out -std=c++11 -arch ${{ matrix.arch }} -I $PULSAR_DIR/include -L $PULSAR_DIR/lib -Wl,-rpath $PULSAR_DIR/lib -lpulsar
59- ./dynamic.out
60- echo "Build with static library"
61- clang++ win-examples/example.cc -o static.out -std=c++11 -arch ${{ matrix.arch }} -I $PULSAR_DIR/include $PULSAR_DIR/lib/libpulsarwithdeps.a
62- ./static.out
237+ if [ "$RUNNER_OS" == "Windows" ]; then
238+ cd win-examples
239+ cmake \
240+ -G "${{ matrix.generator }}" ${{ matrix.arch }} \
241+ -DLINK_STATIC=OFF \
242+ -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }} \
243+ -B build-dynamic
244+ cmake --build build-dynamic --config Release
245+ cmake \
246+ -G "${{ matrix.generator }}" ${{ matrix.arch }} \
247+ -DLINK_STATIC=ON \
248+ -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }} \
249+ -B build-static
250+ cmake --build build-static --config Release
251+ ./build-static/Release/win-example.exe
252+ fi
63253
64- - name : Zip artifact
254+ - name : Build (Debug)
255+ shell : bash
65256 run : |
66- cd ./pkg/mac/.install
67- zip -r macos-${{ matrix.arch }}.zip ./include/pulsar/* ./lib/*
68- cp macos-${{ matrix.arch }}.zip ../../../
257+ if [ "$RUNNER_OS" == "Windows" ]; then
258+ cmake \
259+ -B ./build-2 \
260+ -G "${{ matrix.generator }}" ${{ matrix.arch }} \
261+ -DUSE_ASIO=ON \
262+ -DBUILD_TESTS=OFF \
263+ -DVCPKG_TRIPLET="${{ matrix.triplet }}" \
264+ -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_DIR }}" \
265+ -DCMAKE_BUILD_TYPE=Debug \
266+ -S .
267+ cmake --build ./build-2 --parallel --config Debug
268+ fi
269+
270+ package :
271+ name : Build ${{matrix.pkg.name}} ${{matrix.cpu.platform}}
272+ runs-on : ubuntu-22.04
273+ needs : unit-tests
274+ timeout-minutes : 500
275+
276+ strategy :
277+ fail-fast : true
278+ matrix :
279+ pkg :
280+ - { name: 'RPM', type: 'rpm', path: 'pkg/rpm/RPMS' }
281+ - { name: 'Deb', type: 'deb', path: 'pkg/deb/BUILD/DEB' }
282+ - { name: 'Alpine', type: 'apk', path: 'pkg/apk/build' }
283+ cpu :
284+ - { arch: 'x86_64', platform: 'x86_64' }
285+
286+ steps :
287+ - name : checkout
288+ uses : actions/checkout@v3
289+
290+ - name : Set up QEMU
291+ uses : docker/setup-qemu-action@v2
69292
70- - name : Upload artifacts
71- uses : actions/upload-artifact@v3
293+ - name : Package Pulsar source
294+ run : build-support/generate-source-archive.sh
295+
296+ - uses : docker/setup-buildx-action@v2
297+ - run : build-support/copy-deps-versionfile.sh
298+
299+ - name : Build dependencies Docker image
300+ uses : docker/build-push-action@v3
72301 with :
73- name : macos-${{ matrix.arch }}.zip
74- path : macos-${{ matrix.arch }}.zip
302+ context : ./pkg/${{matrix.pkg.type}}
303+ load : true
304+ tags : build:latest
305+ platforms : linux/${{matrix.cpu.platform}}
306+ build-args : PLATFORM=${{matrix.cpu.arch}}
307+ cache-from : type=gha
308+ cache-to : type=gha,mode=max
309+
310+ - name : Build packages
311+ run : pkg/${{matrix.pkg.type}}/docker-build-${{matrix.pkg.type}}-${{matrix.cpu.platform}}.sh build:latest
312+
313+ cpp-build-macos :
314+ timeout-minutes : 120
315+ name : Build CPP Client on macOS
316+ needs : formatting-check
317+ runs-on : macos-14
318+ steps :
319+ - name : checkout
320+ uses : actions/checkout@v3
321+
322+ - name : Install dependencies
323+ run : brew install openssl protobuf boost zstd snappy googletest
324+
325+ - name : Configure (default)
326+ shell : bash
327+ run : cmake -B ./build-macos -S .
328+
329+ - name : Compile
330+ shell : bash
331+ run : |
332+ cmake --build ./build-macos --parallel --config Release
333+
334+ - name : Build with C++20
335+ shell : bash
336+ run : |
337+ cmake -B build-macos-cpp20 -DCMAKE_CXX_STANDARD=20
338+ cmake --build build-macos-cpp20 -j8
339+
340+ cpp-build-macos-static :
341+ timeout-minutes : 120
342+ name : Build CPP Client on macOS with static dependencies
343+ runs-on : macos-14
344+ needs : unit-tests
345+ steps :
346+ - name : checkout
347+ uses : actions/checkout@v3
348+
349+ - name : Build libraries
350+ run : ./pkg/mac/build-static-library.sh
75351
352+ # Job that will be required to complete and depends on all the other jobs
76353 check-completion :
77354 name : Check Completion
78355 runs-on : ubuntu-latest
79- needs : [package-macos]
356+ needs : [formatting-check, wireshark-dissector-build, unit-tests, cpp20-build, cpp-build-windows, package, cpp-build -macos]
80357
81358 steps :
82359 - run : true
0 commit comments