forked from MeshInspector/MeshLib
-
Notifications
You must be signed in to change notification settings - Fork 0
326 lines (282 loc) · 13.6 KB
/
build-test-windows.yml
File metadata and controls
326 lines (282 loc) · 13.6 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
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.os == 'windows-2022' && matrix.build_system == 'MSBuild' }}
PYTEST_C_SHARP_ARGS: --run-c-sharp-samples --csharp-sample-dir=..\source\x64\${{ matrix.config }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: true
- name: Checkout third-party submodules
run: |
# Download sub-submodules for certain submodules. We don't recurse above in Checkout to improve build performance. See: https://github.com/actions/checkout/issues/1779
git submodule update --init --recursive --depth 1 thirdparty/mrbind
- name: Collect runner's system stats
if: ${{ inputs.internal_build }}
continue-on-error: true
uses: ./.github/actions/collect-runner-stats
with:
target_os: windows
target_arch: x64
cxx_compiler: ${{ matrix.os }} # os name will be transformed to MSVC name (e.g. windows-2022 -> msvc-2022)
build_config: ${{ matrix.config }}
build_system: ${{ matrix.build_system }}
- name: Clean Vcpkg Directory
if: ${{ matrix.os == 'windows-2022' }}
working-directory: C:\vcpkg
run: git clean -ffdx
- name: Checkout & Update Vcpkg ${{ matrix.vcpkg-version }}
working-directory: C:\vcpkg
run: |
git fetch
git pull --rebase
git checkout ${{ matrix.vcpkg-version }}
bootstrap-vcpkg.bat
vcpkg.exe integrate install
- name: Restore Vcpkg Cache
uses: actions/cache@v4
id: vcpkg-cache
with:
key: vcpkg-cache-${{ matrix.vcpkg-version }}
path: |
C:\vcpkg\*
- name: Configure AWS Credentials
if: ${{ inputs.internal_build }}
uses: aws-actions/configure-aws-credentials@8e2d02296bcf12c081e192c60f3cb80d77f4f76a # v4
with:
role-to-assume: arn:aws:iam::259351611210:role/GitHubMeshLibAwsCredsRole
aws-region: us-east-1
- name: Update vcpkg packages
run: |
.\thirdparty\install.bat --write-s3
- name: Vcpkg integrate install
working-directory: C:\vcpkg
run: C:\vcpkg\vcpkg.exe integrate install
- name: Restore CUDA Cache
if: ${{ matrix.os == 'windows-2022' }}
uses: actions/cache@v4
id: cuda-cache
with:
key: cuda-${{matrix.CUDA-VERSION}}
path: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA*
- name: Install CUDA
if: ${{ steps.cuda-cache.outputs.cache-hit != 'true' && matrix.os == 'windows-2022' }}
run: choco install cuda --version=${{matrix.CUDA-VERSION}} --confirm
- name: Setup CUDA
if: ${{ matrix.os == 'windows-2022' }}
shell: bash
run: |
echo "CUDA_PATH=C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v${{ matrix.CUDA-MAJOR }}.${{ matrix.CUDA-MINOR }}" >> $GITHUB_ENV
echo "CUDA_PATH_V${{ matrix.CUDA-MAJOR }}_${{ matrix.CUDA-MINOR }}=C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v${{ matrix.CUDA-MAJOR }}.${{ matrix.CUDA-MINOR }}" >> $GITHUB_ENV
echo "CUDA_PATH_VX_Y=CUDA_PATH_V${{ matrix.CUDA-MAJOR }}_${{ matrix.CUDA-MINOR }}" >> $GITHUB_ENV
echo "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v${{ matrix.CUDA-MAJOR }}.${{ matrix.CUDA-MINOR }}\\bin" >> $GITHUB_PATH
- name: Install Visual Studio Integration
if: ${{ matrix.os == 'windows-2022' }}
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@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2
- name: Install .NET
if: ${{ env.BUILD_C_SHARP == 'true' }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Restore Dependencies
if: ${{ env.BUILD_C_SHARP == 'true' }}
uses: codebeltnet/dotnet-restore@7a827ce5193af33b950d0fedfc0277cab2ff8887 # v2
with:
projects: 'source/**/*.csproj'
# Install MSYS2 using their github action instead of ours `install_deps_windows_msys2.bat`. Locally users should use that bat file.
# I'm expecting the official action to be better suited for CI needs (e.g. they promise some form of caching in the readme), but I didn't perform a proper comparison.
- name: Install MSYS2 for MRBind
uses: msys2/setup-msys2@61f9e5e925871ba6c9e3e8da24ede83ea27fa91f # v2
if: ${{inputs.mrbind || (inputs.mrbind_c && matrix.build_system == 'CMake')}}
with:
msystem: clang64
install: make gawk procps-ng mingw-w64-clang-x86_64-cmake
location: C:\msys64_meshlib_mrbind
- name: Install Clang in MSYS2
if: ${{inputs.mrbind || (inputs.mrbind_c && matrix.build_system == 'CMake')}}
shell: msys2 {0}
run: |
./scripts/mrbind/msys2_install_clang_ver.sh $(cat scripts/mrbind/clang_version_msys2.txt)
- name: Install Ninja for CMake
if: ${{ matrix.build_system == 'CMake' }}
uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
- name: Build MRBind
if: ${{inputs.mrbind || (inputs.mrbind_c && matrix.build_system == 'CMake')}}
shell: cmd
env:
# Need this env variable because our .bat files assume msys2 installed directly to `C:\msys64_meshlib_mrbind`,
# and the setup-msys2 action always adds the `...\msys64` component at the end, and it's a tiny bit wasteful to move it around when running in the CI.
MSYS2_DIR: C:\msys64_meshlib_mrbind\msys64
run: call ./scripts/mrbind/install_mrbind_windows_msys2.bat
- name: Generate C bindings
if: ${{inputs.mrbind_c && matrix.build_system == 'CMake'}}
shell: cmd
env:
MSYS2_DIR: C:\msys64_meshlib_mrbind\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
call ./scripts/mrbind/generate_win.bat -B --trace TARGET=c
- name: Build
shell: cmd
env:
VCPKG_ROOT: C:\vcpkg
run: |
if ${{ fromJSON('["1==0", "1==1"]')[matrix.build_system == 'CMake'] }} (
call "${{matrix.vc-path}}\Common7\Tools\VsDevCmd.bat" -arch=amd64
if errorlevel 1 exit 1
cmake --version
if errorlevel 1 exit 1
cmake -B source\TempOutput -GNinja -DCMAKE_BUILD_TYPE=${{matrix.config}} -DMESHLIB_BUILD_GENERATED_C_BINDINGS=${{ fromJSON('["OFF", "ON"]')[inputs.mrbind_c] }}
if errorlevel 1 exit 1
cmake --build source\TempOutput -j
if errorlevel 1 exit 1
if not exist source\x64 mkdir source\x64
if errorlevel 1 exit 1
move source\TempOutput\bin source\x64\${{matrix.config}}
if errorlevel 1 exit 1
) else (
msbuild -m source\MeshLib.sln -p:Configuration=${{ matrix.config }}
if errorlevel 1 exit 1
)
- name: Build .NET
if: ${{ env.BUILD_C_SHARP == 'true' }}
run: msbuild -m source\MeshLibDotNet.sln -p:Configuration=${{ matrix.config }} -t:restore -t:build
- name: Build .NET examples
if: ${{ env.BUILD_C_SHARP == 'true' }}
run: msbuild -m examples\c-sharp-examples\c-sharp-examples.sln -p:Configuration=${{ matrix.config }} -t:restore -t:build
- name: Generate and build Python bindings
if: ${{inputs.mrbind}}
shell: cmd
env:
MSYS2_DIR: C:\msys64_meshlib_mrbind\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
call ./scripts/mrbind/generate_win.bat -B --trace MODE=none VS_MODE=${{matrix.config}}
- name: Run Start-and-Exit Tests
timeout-minutes: 3
working-directory: source\x64\${{ matrix.config }}
run: .\MeshViewer.exe -tryHidden -noEventLoop -unloadPluginsAtEnd
shell: cmd
- name: Unit Tests
run: source\x64\${{ matrix.config }}\MRTest.exe
- name: C Unit Tests (old bindings)
run: py -3 scripts\run_c_unit_test_script.py ${{ matrix.config }}
- name: C Unit Tests
if: ${{inputs.mrbind_c && matrix.build_system == 'CMake'}}
run: py -3 scripts\run_c2_unit_test_script.py ${{ matrix.config }}
- name: C# Unit Tests
if: ${{ env.BUILD_C_SHARP == 'true' }}
run: py -3 scripts\run_c_sharp_unit_test_script.py ${{ matrix.config }}
- name: Python Sanity Tests
timeout-minutes: 8
working-directory: source\x64\${{ matrix.config }}
run: py -3 ..\..\..\scripts\run_python_test_script.py -d '..\test_python'
- name: Python Regression Tests
if: ${{ inputs.internal_build }}
uses: ./.github/actions/python-regression-tests
with:
build_config: ${{ matrix.config }}
mrbind: ${{ inputs.mrbind }}
pytest_args: "${{ env.BUILD_C_SHARP == 'true' && env.PYTEST_C_SHARP_ARGS || '' }} --run-cuda=negative"
smoke: ${{ !inputs.full_config_build && matrix.config == 'Debug' }}
test_artifacts_path: windows/${{ matrix.os }}/${{ matrix.config }}
upload_test_artifacts: ${{ inputs.upload_test_artifacts }}
- 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
# https://github.com/actions/download-artifact#maintaining-file-permissions-and-case-sensitive-files
- name: Archive files
if: ${{ inputs.upload_artifacts && matrix.os == 'windows-2019' && matrix.build_system == 'CMake' }}
run: tar -a -c -f MREDist_${{ matrix.config }}.zip ./source/x64/${{matrix.config}}
- name: Archive generated C headers
if: ${{ inputs.upload_artifacts && matrix.os == 'windows-2019' && matrix.build_system == 'CMake' && matrix.config == 'Release' && inputs.mrbind_c }}
run: tar -a -c -f MeshLibC2Headers.zip ./source/MeshLibC2/include
- name: Upload Windows Binaries Archive
if: ${{ inputs.upload_artifacts && matrix.os == 'windows-2019' && matrix.build_system == 'CMake' }}
uses: actions/upload-artifact@v4
with:
name: WindowsArchive_${{matrix.config}}
path: MREDist_${{matrix.config}}.zip
retention-days: 1
- name: Upload MeshLibC2 headers archive
if: ${{ inputs.upload_artifacts && matrix.os == 'windows-2019' && matrix.build_system == 'CMake' && matrix.config == 'Release' && inputs.mrbind_c }}
uses: actions/upload-artifact@v4
with:
name: WindowsArchive_MeshLibC2Headers
path: MeshLibC2Headers.zip
retention-days: 1
- name: Create and fix fake Wheel for NuGet
if: ${{ inputs.nuget_build && matrix.os == 'windows-2022' && matrix.config == 'Release' && matrix.build_system == 'MSBuild' && env.BUILD_C_SHARP == 'true' }}
run: |
py -3 -m venv wheel_venv
wheel_venv\Scripts\Activate
python -m pip install delvewheel
python ./scripts/nuget_patch/patch_library_deps.py "./source/x64/Release/MRMeshC.dll" "./patched_content/"
- name: Upload NuGet files to Artifacts
if: ${{ inputs.nuget_build && matrix.os == 'windows-2022' && matrix.config == 'Release' && matrix.build_system == 'MSBuild' && env.BUILD_C_SHARP == 'true' }}
uses: actions/upload-artifact@v4
with:
name: DotNetPatchArchiveWindows-x64
path: ./patched_content/*
retention-days: 1
- name: Upload NuGet library DLL to Artifacts
if: ${{ inputs.nuget_build && matrix.os == 'windows-2022' && matrix.config == 'Release' && matrix.build_system == 'MSBuild' && env.BUILD_C_SHARP == 'true' }}
uses: actions/upload-artifact@v4
with:
name: DotNetDll
path: ./source/x64/Release/MRDotNet.dll
retention-days: 1