-
Notifications
You must be signed in to change notification settings - Fork 110
397 lines (356 loc) · 17.9 KB
/
build-test-windows.yml
File metadata and controls
397 lines (356 loc) · 17.9 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
name: Build and test Windows
on:
workflow_call:
inputs:
config_matrix:
required: true
type: string
full_config_build:
default: false
required: false
type: boolean
internal_build:
required: true
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:
default: false
required: false
type: boolean
jobs:
windows-build-test:
timeout-minutes: 70
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix: ${{ fromJSON( inputs.config_matrix ) }}
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
env:
BUILD_C_SHARP: ${{ matrix.cxx_compiler == 'msvc-2022' && matrix.build_system == 'CMake' }}
PYTEST_C_SHARP_ARGS: --run-c-sharp-samples --csharp-sample-dir=..\source\x64\${{ matrix.config }}
VCPKG_DEFAULT_TRIPLET: ${{ matrix.vcpkg_triplet || 'x64-windows-meshlib' }}
job_upload_artifact: ${{ inputs.upload_artifacts && matrix.cxx_compiler == 'msvc-2019' && matrix.build_system == 'CMake' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Checkout third-party submodules
shell: bash
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/OpenCTM-git \
thirdparty/laz-perf \
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: Get AWS instance type
uses: ./.github/actions/get-aws-instance-type
- 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: windows
target_arch: x64
cxx_compiler: ${{ matrix.cxx_compiler }}
build_config: ${{ matrix.config }}
build_system: ${{ matrix.build_system }}
aws_instance_type: ${{ env.AWS_INSTANCE_TYPE }}
- name: Set up vcpkg
uses: ./.github/actions/setup-vcpkg-windows
with:
vcpkg-version: ${{ matrix.vcpkg-version }}
vcpkg-triplet: ${{ matrix.vcpkg_triplet || 'x64-windows-meshlib' }}
install-flags: '--write-s3 --use-s3-asset-provider'
internal-build: ${{ inputs.internal_build }}
- name: Install CUDA
uses: ./.github/actions/install-cuda
with:
cuda-version: ${{ matrix.CUDA-VERSION }}
cuda-major: ${{ matrix.CUDA-MAJOR }}
cuda-minor: ${{ matrix.CUDA-MINOR }}
- name: Setup CUDA
shell: cmd
run: |
echo>>%GITHUB_ENV% CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${{ matrix.CUDA-MAJOR }}.${{ matrix.CUDA-MINOR }}
echo>>%GITHUB_ENV% CUDA_PATH_V${{ matrix.CUDA-MAJOR }}_${{ matrix.CUDA-MINOR }}=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${{ matrix.CUDA-MAJOR }}.${{ matrix.CUDA-MINOR }}
echo>>%GITHUB_ENV% CUDA_PATH_VX_Y=CUDA_PATH_V${{ matrix.CUDA-MAJOR }}_${{ matrix.CUDA-MINOR }}
echo>>%GITHUB_PATH% C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${{ matrix.CUDA-MAJOR }}.${{ matrix.CUDA-MINOR }}\bin
- name: Install Visual Studio Integration
# CUDA's MSBuild integration files are only consumed by the MSBuild
# variant (source/MRCuda/MRCuda.vcxproj imports
# `$(VCTargetsPath)\BuildCustomizations\CUDA $(MRCudaVersion).props`).
# The CMake variants use `project(MRCuda CXX CUDA)` and call nvcc
# directly, so this step is a no-op for them.
if: ${{ matrix.build_system == 'MSBuild' }}
run: |
$x = (dir $env:CUDA_PATH -dir -recurse -depth 2).where({$_.name -eq 'visual_studio_integration'}).fullname
$y = (dir $x -dir -recurse).where({$_.name -eq 'MSBuildExtensions'}).fullname + '\*'
(gi '${{matrix.vc-path}}\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_})
- name: Setup python
run: py -3 scripts\setup_win_python_reqs.py
- name: Add msbuild to PATH
if: ${{ matrix.build_system == 'MSBuild' }}
uses: microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57 # v3.0.0
- name: Install .NET
if: ${{ env.BUILD_C_SHARP == 'true' }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Install MSYS2 for MRBind
if: ${{inputs.mrbind || (inputs.mrbind_c && matrix.build_system == 'CMake') || env.BUILD_C_SHARP == 'true'}}
uses: ./.github/actions/install-msys2-mrbind
- name: Build MRBind
if: ${{inputs.mrbind || (inputs.mrbind_c && matrix.build_system == 'CMake') || env.BUILD_C_SHARP == 'true'}}
shell: cmd
env:
MSYS2_DIR: C:\msys64
run: call ./scripts/mrbind/install_mrbind_windows_msys2.bat
- name: Generate C bindings
if: ${{ (inputs.mrbind_c && matrix.build_system == 'CMake') || env.BUILD_C_SHARP == 'true' }}
shell: cmd
env:
MSYS2_DIR: C:\msys64
# Note that `\` doesn't work here as a line continuation, and will lead to weird errors.
run: |
call "${{matrix.vc-path}}\Common7\Tools\VsDevCmd.bat" -arch=amd64 ${{ fromJSON('["", "-vcvars_ver=14.2"]')[matrix.cxx_compiler == 'msvc-2019'] }}
call ./scripts/mrbind/generate_win.bat -B --trace TARGET=c
# This consumes the JSON created by generating the C bindings.
- name: Generate C# bindings
if: ${{ env.BUILD_C_SHARP == 'true' }}
shell: cmd
env:
MSYS2_DIR: C:\msys64
# Note that `\` doesn't work here as a line continuation, and will lead to weird errors.
run: |
call "${{matrix.vc-path}}\Common7\Tools\VsDevCmd.bat" -arch=amd64 ${{ fromJSON('["", "-vcvars_ver=14.2"]')[matrix.cxx_compiler == 'msvc-2019'] }}
call ./scripts/mrbind/generate_win.bat -B --trace TARGET=csharp CSHARP_MODE=${{matrix.config}}
dotnet build examples/c-sharp-examples -c ${{matrix.config}}
- name: Build
shell: cmd
env:
GETTEXT_ROOT: C:\msys64\clang64
VCPKG_ROOT: C:\vcpkg
VCPKG_TARGET_TRIPLET: ${{ matrix.vcpkg_triplet }}
# `|| exit /b 1` is used instead of `if errorlevel 1 exit 1`
# because the latter can miss exit codes inside parenthesized IF
# blocks in cmd.exe (e.g. it failed to catch a ninja build failure).
run: |
if ${{ fromJSON('["1==0", "1==1"]')[matrix.build_system == 'CMake'] }} (
call "${{matrix.vc-path}}\Common7\Tools\VsDevCmd.bat" -arch=amd64 ${{ fromJSON('["", "-vcvars_ver=14.2"]')[matrix.cxx_compiler == 'msvc-2019'] }} || exit /b 1
cmake --version || exit /b 1
cmake -B source\TempOutput -GNinja -DCMAKE_BUILD_TYPE=${{matrix.config}} -DVCPKG_TARGET_TRIPLET=%VCPKG_TARGET_TRIPLET% -DMESHLIB_BUILD_GENERATED_C_BINDINGS=${{ fromJSON('["OFF", "ON"]')[inputs.mrbind_c] }} || exit /b 1
cmake --build source\TempOutput -j || exit /b 1
if not exist source\x64 mkdir source\x64 || exit /b 1
xcopy source\TempOutput\bin\* source\x64\${{matrix.config}}\* /s /e /i /Y || exit /b 1
) else (
msbuild -m source\MeshLib.sln -p:Configuration=${{ matrix.config }} -p:VcpkgTriplet=%VCPKG_TARGET_TRIPLET%${{ fromJSON('["", ";PlatformToolset=v142"]')[matrix.cxx_compiler == 'msvc-2019'] }} || exit /b 1
)
- name: Generate and build Python bindings
if: ${{inputs.mrbind && matrix.vcpkg_triplet != 'x64-windows-meshlib-iterator-debug'}}
shell: cmd
env:
MSYS2_DIR: C:\msys64
# Note that `\` doesn't work here as a line continuation, and will lead to weird errors.
run: |
call "${{matrix.vc-path}}\Common7\Tools\VsDevCmd.bat" -arch=amd64 ${{ fromJSON('["", "-vcvars_ver=14.2"]')[matrix.cxx_compiler == 'msvc-2019'] }}
call ./scripts/mrbind/generate_win.bat -B --trace MODE=none VS_MODE=${{matrix.config}}
- name: Diagnostic — output bin DLL inventory + MRMesh imports
if: ${{ always() }}
shell: pwsh
continue-on-error: true
# Don't pin working-directory to source\x64\${{ matrix.config }} — when
# an upstream step fails before MSBuild runs, that directory does not
# exist and the runner cannot start pwsh, which makes the failure
# cascade look like the previous step is the failing one.
# Instead enter the directory inside the script and bail out cleanly
# if it doesn't exist.
run: |
$buildDir = Join-Path $Env:GITHUB_WORKSPACE 'source\x64\${{ matrix.config }}'
if (-not (Test-Path $buildDir)) {
Write-Host "Build output directory '$buildDir' does not exist — skipping diagnostic."
exit 0
}
Push-Location $buildDir
try {
& "$Env:GITHUB_WORKSPACE\scripts\diagnostics\windows-bin-imports.ps1" -VcPath "${{ matrix.vc-path }}"
} finally {
Pop-Location
}
- name: Run Start-and-Exit Tests
timeout-minutes: 3
working-directory: source\x64\${{ matrix.config }}
run: .\MeshViewer.exe -tryHidden -noEventLoop -unloadPluginsAtEnd
shell: cmd
- name: Verify meshlib.mrmeshpy import
if: ${{ inputs.mrbind && matrix.vcpkg_triplet != 'x64-windows-meshlib-iterator-debug' }}
timeout-minutes: 3
uses: ./.github/actions/verify-meshlib-python-import
with:
build-bin-dir: source\x64\${{ matrix.config }}
- name: Unit Tests
env:
GTEST_OUTPUT: 'xml:unit_tests_report_gtest.xml'
timeout-minutes: 10
run: source\x64\${{ matrix.config }}\MRTest.exe
- name: C Unit Tests
if: ${{inputs.mrbind_c && matrix.build_system == 'CMake'}}
timeout-minutes: 10
run: py -3 scripts\run_c2_unit_test_script.py ${{ matrix.config }}
- name: C# Unit Tests
if: ${{ env.BUILD_C_SHARP == 'true' }}
timeout-minutes: 10
run: |
dotnet build source\MRDotNet2Test -c ${{ matrix.config }}
source\x64\${{ matrix.config }}\MRDotNet2Test.exe --result="_report_nunit.xml"
# convert report to JUnit format
[Environment]::CurrentDirectory = $pwd
$xslt = New-Object System.Xml.Xsl.XslCompiledTransform
$xslt.Load("scripts\devops\nunit3-junit.xslt")
$xslt.Transform("_report_nunit.xml", "unit_tests_report_nunit.xml")
- name: Python Sanity Tests
if: ${{matrix.vcpkg_triplet != 'x64-windows-meshlib-iterator-debug'}}
timeout-minutes: 8
working-directory: source\x64\${{ matrix.config }}
run: py -3 -u ..\..\..\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 && matrix.vcpkg_triplet != 'x64-windows-meshlib-iterator-debug'}}
uses: ./.github/actions/python-regression-tests
with:
build_config: ${{ matrix.config }}
pytest_args: "${{ env.BUILD_C_SHARP == 'true' && env.PYTEST_C_SHARP_ARGS || '' }} --run-cuda=negative --junit-xml=../unit_tests_report_regression.xml"
smoke: ${{ !inputs.full_config_build && matrix.config == 'Debug' }}
test_artifacts_path: ${{ matrix.test_artifacts_path }}
upload_test_artifacts: ${{ inputs.upload_test_artifacts }}
- name: Generate Test Performance Report
continue-on-error: true
run: |
py -3 scripts/junit_to_csv.py unit_tests_report.csv (get-item unit_tests_report_*.xml)
cat unit_tests_report.csv
- name: Delete unwanted files
# Those files should not exist when using CMake.
shell: cmd
run: |
if exist source\x64\Debug\pybind11nonlimitedapi_meshlib_3*.dll del /Q source\x64\Debug\pybind11nonlimitedapi_meshlib_3*.dll
if exist source\x64\Release\pybind11nonlimitedapi_meshlib_3*.dll del /Q source\x64\Release\pybind11nonlimitedapi_meshlib_3*.dll
- name: Find CMake
run: |
# https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-powershell
$installationPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -no_logo && set" | foreach-object {
$name, $value = $_ -split '=', 2
set-content env:\"$name" $value
}
$env:CMAKE_EXE = (Get-Command cmake.exe).Path
& $env:CMAKE_EXE --version
# https://github.com/actions/runner-images/issues/5251#issuecomment-1071030822
echo "CMAKE_EXE=$env:CMAKE_EXE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Build C++ examples
if: ${{ matrix.config == 'Release' }} # debug builds not supported due to missing file 'tbb12_debug.lib'
env:
VCPKG_ROOT: C:\vcpkg
VCPKG_TARGET_TRIPLET: ${{ matrix.vcpkg_triplet }}
run: |
& $env:CMAKE_EXE `
-S examples/cpp-examples `
-B cpp-examples-build `
-D MESHLIB_INCLUDE_DIRS="$pwd/source;$pwd/thirdparty/parallel-hashmap;$env:VCPKG_ROOT/installed/$env:VCPKG_TARGET_TRIPLET/include;$env:VCPKG_ROOT/installed/$env:VCPKG_TARGET_TRIPLET/include/eigen3" `
-D MESHLIB_LIB_DIRS="$pwd/source/x64/${{ matrix.config }};$env:VCPKG_ROOT/installed/$env:VCPKG_TARGET_TRIPLET/lib"
& $env:CMAKE_EXE `
--build cpp-examples-build `
--config ${{ matrix.config }} `
--parallel $env:NUMBER_OF_PROCESSORS
- name: Build C examples
if: ${{ inputs.mrbind_c && matrix.build_system == 'CMake' }}
run: |
& $env:CMAKE_EXE `
-S examples/c-examples `
-B c-examples-build `
-D MESHLIB_INCLUDE_DIRS="$pwd/source/MeshLibC2/include" `
-D MESHLIB_LIB_DIRS="$pwd/source/x64/${{ matrix.config }}"
& $env:CMAKE_EXE `
--build c-examples-build `
--config ${{ matrix.config }} `
--parallel $env:NUMBER_OF_PROCESSORS
# https://github.com/actions/download-artifact#maintaining-file-permissions-and-case-sensitive-files
- name: Archive files
if: ${{ env.job_upload_artifact == 'true' }}
run: tar -a -c -f MREDist_${{ matrix.upload_name || matrix.config }}.zip ./source/x64/${{ matrix.config }}
- name: Archive generated C headers
if: ${{ env.job_upload_artifact == 'true' && matrix.config == 'Release' && inputs.mrbind_c }}
run: tar -a -c -f MeshLibC2Headers.zip ./source/MeshLibC2/include
- name: Upload Windows Binaries Archive
if: ${{ env.job_upload_artifact == 'true' }}
uses: actions/upload-artifact@v7
with:
name: WindowsArchive_${{ matrix.upload_name || matrix.config }}
path: MREDist_${{ matrix.upload_name || matrix.config }}.zip
retention-days: 1
overwrite: true
- name: Collect artifact stats
if: ${{ inputs.internal_build && env.job_upload_artifact == 'true' }}
continue-on-error: true
uses: ./.github/actions/collect-artifact-stats
with:
artifact_path: ${{ github.workspace }}
artifact_glob: MREDist_${{ matrix.upload_name || matrix.config }}.zip
stats_file_suffix: -${{ steps.collect-runner-stats.outputs.job_id }}
- name: Upload MeshLibC2 headers archive
if: ${{ env.job_upload_artifact == 'true' && matrix.config == 'Release' && inputs.mrbind_c }}
uses: actions/upload-artifact@v7
with:
name: WindowsArchive_MeshLibC2Headers
path: MeshLibC2Headers.zip
retention-days: 1
overwrite: true
- name: Create and fix fake Wheel for NuGet
if: ${{ inputs.nuget_build && matrix.cxx_compiler == 'msvc-2022' && matrix.config == 'Release' && env.BUILD_C_SHARP == 'true' }}
run: |
py -3 -m venv wheel_venv
wheel_venv\Scripts\Activate
py -3 -m pip install delvewheel
py -3 ./scripts/nuget_patch/patch_library_deps.py ./patched_content/ ./source/x64/Release/MeshLibC2.dll ./source/x64/Release/MeshLibC2Cuda.dll
- name: Upload NuGet files to Artifacts
if: ${{ inputs.nuget_build && matrix.cxx_compiler == 'msvc-2022' && matrix.config == 'Release' && env.BUILD_C_SHARP == 'true' }}
uses: actions/upload-artifact@v7
with:
name: DotNetPatchArchiveWindows-x64
path: ./patched_content/*
retention-days: 1
overwrite: true
- name: Upload NuGet library DLL and XML to Artifacts
if: ${{ inputs.nuget_build && matrix.cxx_compiler == 'msvc-2022' && matrix.config == 'Release' && env.BUILD_C_SHARP == 'true' }}
uses: actions/upload-artifact@v7
with:
name: DotNetDllXml
path: |
./source/x64/Release/MRDotNet2.dll
./source/x64/Release/MRDotNet2.xml
retention-days: 1
overwrite: true