-
Notifications
You must be signed in to change notification settings - Fork 109
313 lines (283 loc) · 11.5 KB
/
build-test-macos.yml
File metadata and controls
313 lines (283 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
name: Build and test MacOS
on:
workflow_call:
inputs:
app_version:
required: true
type: string
full_config_build:
default: false
required: false
type: boolean
internal_build:
required: false
type: boolean
upload_artifacts:
required: true
type: boolean
upload_test_artifacts:
required: true
type: boolean
mrbind:
default: true
required: false
type: boolean
mrbind_c:
default: true
required: false
type: boolean
nuget_build_patch:
default: false
required: false
type: boolean
jobs:
macos-build-test:
timeout-minutes: 100
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
arch: [ x64, arm64 ]
config: [ Debug, Release ]
exclude:
- arch: x64
config: Debug
include:
- arch: x64
config: Release
os: x64
compiler: AppleClang
cxx-compiler-template: /usr/bin/clang++
c-compiler-template: /usr/bin/clang
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
runner: macos-15-intel # github hosted
- arch: arm64
config: Debug
os: github-arm
compiler: AppleClang
cxx-compiler-template: /usr/bin/clang++
c-compiler-template: /usr/bin/clang
runner: macos-latest # github hosted
- arch: arm64
config: Release
os: arm
compiler: brew-llvm18
cxx-compiler-template: BREW_PREFIX/opt/llvm@18/bin/clang++
c-compiler-template: BREW_PREFIX/opt/llvm@18/bin/clang
runner: [ self-hosted, macos, arm64, build ] # any macos version
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Checkout third-party submodules
run: |
# Selective init -- parent Checkout drops submodules:true.
# https://github.com/actions/checkout/issues/1779
# Retried via retry.sh: submodule endpoints occasionally 500.
bash scripts/retry.sh -- git submodule update --init --depth 1 \
thirdparty/imgui \
thirdparty/eigen \
thirdparty/parallel-hashmap \
thirdparty/expected \
thirdparty/googletest \
thirdparty/OpenCTM-git \
thirdparty/libE57Format \
thirdparty/glad \
thirdparty/tinygltf \
thirdparty/laz-perf \
thirdparty/clip \
thirdparty/fastmcpp \
thirdparty/nlohmann-json \
thirdparty/cpp-httplib \
thirdparty/mrbind \
thirdparty/mrbind-pybind11
# mrbind needs deps/cppdecl; recurse only there
bash scripts/retry.sh -- git -C thirdparty/mrbind submodule update --init --depth 1 deps/cppdecl
- name: Setup Homebrew prefix and resolve compiler paths
id: setup
run: |
BREW_PREFIX=$(brew --prefix)
echo "Brew prefix: $BREW_PREFIX"
echo "brew-prefix=$BREW_PREFIX" >> $GITHUB_OUTPUT
echo "BREW_PREFIX=$BREW_PREFIX" >> $GITHUB_ENV
# Substitute BREW_PREFIX in templates and set actual compiler paths
CXX_COMPILER=$(echo "${{ matrix.cxx-compiler-template }}" | sed "s|BREW_PREFIX|$BREW_PREFIX|g")
C_COMPILER=$(echo "${{ matrix.c-compiler-template }}" | sed "s|BREW_PREFIX|$BREW_PREFIX|g")
echo "CXX compiler: $CXX_COMPILER"
echo "C compiler: $C_COMPILER"
echo "cxx-compiler=$CXX_COMPILER" >> $GITHUB_OUTPUT
echo "c-compiler=$C_COMPILER" >> $GITHUB_OUTPUT
- name: Collect runner's system stats
if: ${{ inputs.internal_build }}
id: collect-runner-stats
continue-on-error: true
uses: ./.github/actions/collect-runner-stats
with:
target_os: macos
target_arch: ${{ matrix.arch }}
cxx_compiler: ${{ steps.setup.outputs.cxx-compiler }}
build_config: ${{ matrix.config }}
- name: Install thirdparty libs
run: ./scripts/build_thirdparty.sh
env:
CMAKE_CXX_COMPILER: ${{ steps.setup.outputs.cxx-compiler }}
CMAKE_C_COMPILER: ${{ steps.setup.outputs.c-compiler }}
- name: Install MRBind
if: ${{ inputs.mrbind || inputs.mrbind_c }}
run: |
./scripts/mrbind/install_deps_macos.sh
./scripts/mrbind/install_mrbind_macos.sh
- name: Create virtualenv
run: |
python3 -m venv .venv
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Setup python requirements
run: |
curl -sS https://bootstrap.pypa.io/get-pip.py | python3
python3 -m pip install -r ./requirements/python.txt
python3 -m pip install pytest
- name: Generate C bindings
if: ${{ inputs.mrbind_c }}
env:
PATH: ${{ steps.setup.outputs.brew-prefix }}/opt/make/libexec/gnubin:${{ steps.setup.outputs.brew-prefix }}/opt/grep/libexec/gnubin:${{env.PATH}}
CXX: ${{ steps.setup.outputs.cxx-compiler }}
run: |
make --version
make -f scripts/mrbind/generate.mk -B --trace TARGET=c
- name: Build
run: ./scripts/build_source.sh
env:
MESHLIB_BUILD_RELEASE: ${{ fromJSON('["OFF", "ON"]')[matrix.config == 'Release'] }}
MESHLIB_BUILD_DEBUG: ${{ fromJSON('["OFF", "ON"]')[matrix.config == 'Debug'] }}
CMAKE_CXX_COMPILER: ${{ steps.setup.outputs.cxx-compiler }}
MR_VERSION: ${{ inputs.app_version }}
MR_CMAKE_OPTIONS: >
-DMESHLIB_BUILD_MRMESH_PY_LEGACY=${{ fromJSON('["ON", "OFF"]')[inputs.mrbind] }}
-DMR_CXX_STANDARD=23
-DMESHLIB_BUILD_GENERATED_C_BINDINGS=${{ fromJSON('["OFF", "ON"]')[inputs.mrbind_c] }}
- name: MRMesh Exported Symbols
run: |
export PATH="$(brew --prefix llvm@18)/bin:$PATH"
nm -gU ./build/${{ matrix.config }}/bin/libMRMesh.dylib | llvm-cxxfilt
- name: Generate and build Python bindings
if: ${{ inputs.mrbind }}
env:
PATH: ${{ steps.setup.outputs.brew-prefix }}/opt/make/libexec/gnubin:${{ steps.setup.outputs.brew-prefix }}/opt/grep/libexec/gnubin:${{env.PATH}}
CXX: ${{ steps.setup.outputs.cxx-compiler }}
run: |
make --version
make -f scripts/mrbind/generate.mk \
-B --trace \
PYTHON_PKGCONF_NAME=python-3.10-embed \
MESHLIB_SHLIB_DIR=build/${{matrix.config}}/bin
- name: Run Start-and-Exit Tests
timeout-minutes: 3
run: ./build/${{ matrix.config }}/bin/MeshViewer -tryHidden -noEventLoop -unloadPluginsAtEnd
- name: Unit Tests
env:
GTEST_OUTPUT: 'xml:unit_tests_report_gtest.xml'
run: ./build/${{ matrix.config }}/bin/MRTest
- name: C Unit Tests
if: ${{ inputs.mrbind_c }}
run: ./build/${{ matrix.config }}/bin/MRTestC2
- name: Python Sanity Tests
timeout-minutes: 8
working-directory: ./build/${{ matrix.config }}/bin
run: python3 ./../../../scripts/run_python_test_script.py -d '../test_python' -a ' --junit-xml=../unit_tests_report_pytest.xml'
- name: Python Regression Tests
if: ${{ inputs.internal_build }}
env:
RUN_CUDA_ARG: "--run-cuda=negative --junit-xml=../unit_tests_report_regression.xml"
uses: ./.github/actions/python-regression-tests
with:
build_config: ${{ matrix.config }}
smoke: ${{ !inputs.full_config_build && matrix.config == 'Debug' }}
test_artifacts_path: macos/${{ matrix.os }}
upload_test_artifacts: ${{ inputs.upload_test_artifacts }}
- name: Generate Test Performance Report
continue-on-error: true
run: |
scripts/junit_to_csv.py unit_tests_report.csv unit_tests_report_*.xml
cat unit_tests_report.csv
- name: Create Pkg
if: ${{ matrix.config == 'Release' }}
run: |
./scripts/distribution_apple.sh ${{ inputs.app_version }}
mv MeshLib_.pkg meshlib_${{matrix.os}}.pkg
- name: Extract Pkg
if: ${{ matrix.config == 'Release' }}
run: |
# https://gist.github.com/ugultopu/1adf8e08acb87be649d69419cf7aca3c
pkgutil --expand meshlib_${{ matrix.os }}.pkg ./meshlib_install
cd ./meshlib_install/MeshLib.pkg
cat Payload | gunzip | cpio -i
- name: Build C++ examples
if: ${{ matrix.config == 'Release' }}
env:
CXX: ${{ steps.setup.outputs.cxx-compiler }}
run: |
cmake \
-S examples/cpp-examples \
-B cpp-examples-build \
-D CMAKE_FRAMEWORK_PATH=$(pwd)/meshlib_install/MeshLib.pkg/Frameworks/
cmake \
--build cpp-examples-build \
--parallel $(sysctl -n hw.physicalcpu)
- name: Build C examples
if: ${{ matrix.config == 'Release' }}
env:
CC: ${{ steps.setup.outputs.c-compiler }}
run: |
cmake \
-S examples/c-examples \
-B c-examples-build \
-D CMAKE_FRAMEWORK_PATH=$(pwd)/meshlib_install/MeshLib.pkg/Frameworks/
cmake \
--build c-examples-build \
--parallel $(sysctl -n hw.physicalcpu)
- name: Upload Macos Distribution
if: ${{ inputs.upload_artifacts && matrix.config == 'Release' }}
env:
ACTIONS_ARTIFACT_UPLOAD_TIMEOUT_MS: 1800000
uses: Wandalen/wretry.action@e68c23e6309f2871ca8ae4763e7629b9c258e1ea # v3.8.0
with:
action: actions/upload-artifact@v7
attempt_limit: 3
attempt_delay: 30000 # milliseconds
with: |
name: Distributives_macos-${{matrix.os}}
path: meshlib_${{matrix.os}}.pkg
retention-days: 1
overwrite: true
- name: Collect artifact stats
if: ${{ inputs.internal_build && inputs.upload_artifacts }}
continue-on-error: true
uses: ./.github/actions/collect-artifact-stats
with:
artifact_path: ${{ github.workspace }}
artifact_glob: meshlib_${{matrix.os}}.pkg
stats_file_suffix: -${{ steps.collect-runner-stats.outputs.job_id }}
- name: Create and fix fake Wheel for NuGet
if: ${{ inputs.nuget_build_patch && matrix.config == 'Release' }}
shell: bash
run: |
python3 -m venv ./wheel_venv
source ./wheel_venv/bin/activate
python3 -m pip install delocate==0.10.7
python3 ./scripts/nuget_patch/patch_library_deps.py ./patched_content/ ./build/Release/bin/lib{MeshLibC2,MeshLibC2Cuda}.dylib
./scripts/nuget_patch/fix_macos_rpath.sh ./patched_content/libMeshLibC2.dylib
- name: Upload NuGet files to Artifacts
if: ${{ inputs.nuget_build_patch && matrix.config == 'Release' }}
uses: Wandalen/wretry.action@e68c23e6309f2871ca8ae4763e7629b9c258e1ea # v3.8.0
with:
action: actions/upload-artifact@v7
attempt_limit: 3
attempt_delay: 30000 # milliseconds
with: |
name: DotNetPatchArchiveMacOs-${{ matrix.arch }}
path: ./patched_content/*
retention-days: 1
overwrite: true