Skip to content

Commit 3de8c36

Browse files
committed
Test macOS build
1 parent aeff955 commit 3de8c36

File tree

3 files changed

+20
-397
lines changed

3 files changed

+20
-397
lines changed

.github/workflows/ci-pr-validation.yaml

Lines changed: 16 additions & 324 deletions
Original file line numberDiff line numberDiff line change
@@ -29,341 +29,33 @@ concurrency:
2929

3030
jobs:
3131

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-
uses: jidicula/[email protected]
39-
with:
40-
clang-format-version: '11'
41-
exclude-regex: '.*\.(proto|hpp)'
42-
43-
wireshark-dissector-build:
44-
name: Build the Wireshark dissector
45-
needs: formatting-check
46-
runs-on: ${{ matrix.os }}
47-
timeout-minutes: 60
48-
strategy:
49-
matrix:
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
85-
86-
steps:
87-
- name: checkout
88-
uses: actions/checkout@v3
89-
with:
90-
fetch-depth: 0
91-
submodules: recursive
92-
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
228-
run: |
229-
if [ "$RUNNER_OS" == "Windows" ]; then
230-
cmake --build ./build-1 --parallel --config Release
231-
cmake --install ./build-1
232-
fi
233-
234-
- name: Test examples
235-
shell: bash
236-
run: |
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
253-
254-
- name: Build (Debug)
255-
shell: bash
256-
run: |
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
32+
package-macos:
33+
name: Build macOS libraries
34+
runs-on: macos-14
27435
timeout-minutes: 500
27536

27637
strategy:
277-
fail-fast: true
38+
fail-fast: false
27839
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
40+
arch: [x86_64, arm64]
29241

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
301-
with:
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
31842
steps:
31943
- name: checkout
32044
uses: actions/checkout@v3
32145

32246
- 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
33147
run: |
332-
cmake --build ./build-macos --parallel --config Release
48+
export ARCH=${{ matrix.arch }}
49+
./pkg/mac/build-static-library.sh
33350
334-
- name: Build with C++20
335-
shell: bash
51+
- name: Zip artifact
33652
run: |
337-
cmake -B build-macos-cpp20 -DCMAKE_CXX_STANDARD=20
338-
cmake --build build-macos-cpp20 -j8
53+
cd ./pkg/mac/.install
54+
zip -r macos-${{ matrix.arch }}.zip ./include/pulsar/* ./lib/*
55+
cp macos-${{ matrix.arch }}.zip ../../../
33956
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
351-
352-
- name: Test static libraries
353-
run: |
354-
export PULSAR_DIR=$PWD/pkg/mac/.install
355-
echo "Build with static library"
356-
clang++ win-examples/example.cc -o static.out -std=c++11 -I $PULSAR_DIR/include $PULSAR_DIR/lib/libpulsarwithdeps.a
357-
./static.out
358-
echo "Build with dynamic library"
359-
clang++ win-examples/example.cc -o dynamic.out -std=c++11 -I $PULSAR_DIR/include -L $PULSAR_DIR/lib -Wl,-rpath $PULSAR_DIR/lib -lpulsar
360-
./dynamic.out
361-
362-
# Job that will be required to complete and depends on all the other jobs
363-
check-completion:
364-
name: Check Completion
365-
runs-on: ubuntu-latest
366-
needs: [formatting-check, wireshark-dissector-build, unit-tests, cpp20-build, cpp-build-windows, package, cpp-build-macos]
367-
368-
steps:
369-
- run: true
57+
- name: Upload artifacts
58+
uses: actions/upload-artifact@v3
59+
with:
60+
name: macos-${{ matrix.arch }}.zip
61+
path: macos-${{ matrix.arch }}.zip

0 commit comments

Comments
 (0)