| 1 |
name: Build |
| 2 |
|
| 3 |
on: [push, pull_request, workflow_dispatch] |
| 4 |
|
| 5 |
env: |
| 6 |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| 7 |
BUILD_TYPE: Release |
| 8 |
|
| 9 |
jobs: |
| 10 |
build-linux: |
| 11 |
# The CMake configure and build commands are platform agnostic and should work equally |
| 12 |
# well on Windows or Mac. You can convert this to a matrix build if you need |
| 13 |
# cross-platform coverage. |
| 14 |
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 15 |
runs-on: ubuntu-latest |
| 16 |
|
| 17 |
steps: |
| 18 |
- uses: actions/checkout@v3 |
| 19 |
|
| 20 |
- name: Hashing dependency CMake files |
| 21 |
id: dep_cmake_hash |
| 22 |
run: echo "dep_cmake_hash=${{ hashFiles('./deps/**') }}" >> $GITHUB_OUTPUT |
| 23 |
|
| 24 |
- name: Create Build Environment |
| 25 |
# Some projects don't allow in-source building, so create a separate build directory |
| 26 |
# We'll use this as our working directory for all subsequent commands |
| 27 |
run: | |
| 28 |
python -m pip install build |
| 29 |
python -m pip install py-build-cmake |
| 30 |
cmake -E make_directory ${{github.workspace}}/build |
| 31 |
cmake -E make_directory ${{github.workspace}}/build/dist |
| 32 |
cmake -E make_directory ${{github.workspace}}/example/build_fp |
| 33 |
cmake -E make_directory ${{github.workspace}}/example/build_subd |
| 34 |
|
| 35 |
- uses: actions/cache@v3 |
| 36 |
name: Getting dependency cache |
| 37 |
id: cache |
| 38 |
with: |
| 39 |
path: ${{github.workspace}}/deps/build-python-module/destdir |
| 40 |
key: ${{ runner.os }}-${{ matrix.arch }}-build-deps-${{ steps.dep_cmake_hash.outputs.dep_cmake_hash }} |
| 41 |
|
| 42 |
- name: Build dependencies |
| 43 |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} |
| 44 |
shell: bash |
| 45 |
working-directory: ${{github.workspace}}/deps |
| 46 |
run: cmake -D_DEPS_PRESET=python-module -P autobuild.cmake |
| 47 |
|
| 48 |
- name: Configure CMake |
| 49 |
# Use a bash shell so we can use the same syntax for environment variable |
| 50 |
# access regardless of the host operating system |
| 51 |
shell: bash |
| 52 |
working-directory: ${{github.workspace}}/build |
| 53 |
# Note the current convention is to use the -S and -B options here to specify source |
| 54 |
# and build directories, but this is only available with CMake 3.13 and higher. |
| 55 |
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12 |
| 56 |
run: > |
| 57 |
cmake $GITHUB_WORKSPACE |
| 58 |
-DCMAKE_BUILD_TYPE=$BUILD_TYPE |
| 59 |
-DCMAKE_PREFIX_PATH=${{github.workspace}}/deps/build-python-module/destdir/usr/local |
| 60 |
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/dist |
| 61 |
-DCATCH_EXTRA_ARGS="--reporter;junit;--out=result-junit-linux.xml" |
| 62 |
|
| 63 |
- name: Build |
| 64 |
working-directory: ${{github.workspace}}/build |
| 65 |
shell: bash |
| 66 |
run: cmake --build . --config $BUILD_TYPE --target install |
| 67 |
|
| 68 |
- name: Test |
| 69 |
working-directory: ${{github.workspace}}/build |
| 70 |
shell: bash |
| 71 |
# Execute tests defined by the CMake configuration. |
| 72 |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 73 |
run: ctest --verbose |
| 74 |
|
| 75 |
- name: Build example (using find_package) |
| 76 |
working-directory: ${{github.workspace}}/example/build_fp |
| 77 |
shell: bash |
| 78 |
run: | |
| 79 |
cmake .. -DCMAKE_PREFIX_PATH="${{github.workspace}}/build/dist;${{github.workspace}}/deps/build-python-module/destdir/usr/local" |
| 80 |
cmake --build . |
| 81 |
|
| 82 |
- name: Build example (using add_subdirectory) |
| 83 |
working-directory: ${{github.workspace}}/example/build_subd |
| 84 |
shell: bash |
| 85 |
run: | |
| 86 |
cmake .. -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_PREFIX_PATH=${{github.workspace}}/deps/build-python-module/destdir/usr/local |
| 87 |
cmake --build . |
| 88 |
|
| 89 |
- name: Build Python wheel |
| 90 |
working-directory: ${{github.workspace}} |
| 91 |
shell: bash |
| 92 |
run: python -m build --wheel |
| 93 |
|
| 94 |
- uses: actions/upload-artifact@v4 # upload test results |
| 95 |
if: success() || failure() # run this step even if previous step failed |
| 96 |
with: |
| 97 |
name: test-results-linux |
| 98 |
path: ${{github.workspace}}/build/**/result-junit-linux.xml |
| 99 |
|
| 100 |
- uses: actions/upload-artifact@v4 # upload python module |
| 101 |
name: Saving Python artifacts |
| 102 |
if: success() |
| 103 |
with: |
| 104 |
name: libbgcode-python-linux |
| 105 |
path: ${{github.workspace}}/dist/ |
| 106 |
|
| 107 |
build-wasm: |
| 108 |
runs-on: ubuntu-latest |
| 109 |
container: |
| 110 |
image: emscripten/emsdk |
| 111 |
env: |
| 112 |
LANG: C.utf8 |
| 113 |
|
| 114 |
steps: |
| 115 |
- uses: actions/checkout@v3 |
| 116 |
|
| 117 |
- name: Hashing dependency CMake files |
| 118 |
id: dep_cmake_hash |
| 119 |
run: echo "dep_cmake_hash=${{ hashFiles('./deps/**') }}" >> $GITHUB_OUTPUT |
| 120 |
|
| 121 |
- name: Create Build Environment |
| 122 |
shell: bash |
| 123 |
# Some projects don't allow in-source building, so create a separate build directory |
| 124 |
# We'll use this as our working directory for all subsequent commands |
| 125 |
run: | |
| 126 |
cmake -E make_directory build |
| 127 |
cmake -E make_directory build/dist |
| 128 |
cmake -E make_directory example/build_fp |
| 129 |
cmake -E make_directory example/build_subd |
| 130 |
|
| 131 |
- uses: actions/cache@v3 |
| 132 |
name: Getting dependency cache |
| 133 |
id: cache |
| 134 |
with: |
| 135 |
path: deps/build-wasm/destdir |
| 136 |
key: ${{ runner.os }}-${{ matrix.arch }}-emscripten-build-deps-${{ steps.dep_cmake_hash.outputs.dep_cmake_hash }} |
| 137 |
|
| 138 |
- name: Build dependencies |
| 139 |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} |
| 140 |
shell: bash |
| 141 |
working-directory: ${{github.workspace}}/deps |
| 142 |
run: | |
| 143 |
emcmake cmake --preset wasm |
| 144 |
cmake --build --preset wasm |
| 145 |
|
| 146 |
- name: Configure CMake |
| 147 |
# Use a bash shell so we can use the same syntax for environment variable |
| 148 |
# access regardless of the host operating system |
| 149 |
shell: bash |
| 150 |
working-directory: ${{github.workspace}}/build |
| 151 |
# Note the current convention is to use the -S and -B options here to specify source |
| 152 |
# and build directories, but this is only available with CMake 3.13 and higher. |
| 153 |
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12 |
| 154 |
run: emcmake cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_FIND_ROOT_PATH=$(pwd)/../deps/build-wasm/destdir/usr/local -DCMAKE_INSTALL_PREFIX=$(pwd)/../build/dist -DCATCH_EXTRA_ARGS="--reporter;junit;--out=result-junit-wasm.xml" |
| 155 |
|
| 156 |
- name: Build |
| 157 |
shell: bash |
| 158 |
working-directory: ${{github.workspace}}/build |
| 159 |
# Execute the build. You can specify a specific target with "--target <NAME>" |
| 160 |
run: cmake --build . --target install |
| 161 |
|
| 162 |
- name: Test |
| 163 |
shell: bash |
| 164 |
working-directory: ${{github.workspace}}/build |
| 165 |
# Execute tests defined by the CMake configuration. |
| 166 |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 167 |
run: ctest --verbose |
| 168 |
|
| 169 |
- name: Build example (using find_package) |
| 170 |
shell: bash |
| 171 |
working-directory: ${{github.workspace}}/example/build_fp |
| 172 |
run: | |
| 173 |
emcmake cmake .. -DCMAKE_FIND_ROOT_PATH="$(pwd)/../../build/dist;$(pwd)/../../deps/build-wasm/destdir/usr/local" |
| 174 |
cmake --build . |
| 175 |
|
| 176 |
- name: Build example (using add_subdirectory) |
| 177 |
shell: bash |
| 178 |
working-directory: ${{github.workspace}}/example/build_subd |
| 179 |
run: | |
| 180 |
emcmake cmake .. -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_FIND_ROOT_PATH=$(pwd)/../../deps/build-wasm/destdir/usr/local |
| 181 |
cmake --build . |
| 182 |
|
| 183 |
- uses: actions/upload-artifact@v4 # upload test results |
| 184 |
if: success() || failure() # run this step even if previous step failed |
| 185 |
with: |
| 186 |
name: test-results-wasm |
| 187 |
path: ${{github.workspace}}/build/**/result-junit-wasm.xml |
| 188 |
|
| 189 |
- uses: actions/upload-artifact@v4 # upload wasm module |
| 190 |
name: Saving WebAssembly artifacts |
| 191 |
if: success() |
| 192 |
with: |
| 193 |
name: libbgcode-wasm |
| 194 |
path: ${{github.workspace}}/build/dist/lib/wasm/ |
| 195 |
|
| 196 |
build-msvc: |
| 197 |
runs-on: windows-2022 |
| 198 |
|
| 199 |
strategy: |
| 200 |
matrix: |
| 201 |
arch: [x64] |
| 202 |
|
| 203 |
steps: |
| 204 |
- uses: actions/checkout@v3 |
| 205 |
name: Checking out |
| 206 |
|
| 207 |
- uses: ilammy/msvc-dev-cmd@v1 |
| 208 |
name: Configuring build environment |
| 209 |
with: |
| 210 |
arch: ${{ matrix.arch }} |
| 211 |
|
| 212 |
- name: Hashing dependency CMake files |
| 213 |
id: dep_cmake_hash |
| 214 |
run: echo "dep_cmake_hash=${{ hashFiles('./deps/**') }}" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append |
| 215 |
|
| 216 |
- name: Create Build Environment |
| 217 |
# Some projects don't allow in-source building, so create a separate build directory |
| 218 |
# We'll use this as our working directory for all subsequent commands |
| 219 |
run: | |
| 220 |
python -m pip install build |
| 221 |
cmake -E make_directory ${{github.workspace}}\build |
| 222 |
cmake -E make_directory ${{github.workspace}}\build\dist |
| 223 |
cmake -E make_directory ${{github.workspace}}\example\build_fp |
| 224 |
cmake -E make_directory ${{github.workspace}}\example\build_subd |
| 225 |
|
| 226 |
- uses: actions/cache@v3 |
| 227 |
name: Getting dependency cache |
| 228 |
id: cache |
| 229 |
with: |
| 230 |
path: ${{github.workspace}}\deps\build-python-module\destdir |
| 231 |
key: ${{ runner.os }}-${{ matrix.arch }}-build-deps-${{ steps.dep_cmake_hash.outputs.dep_cmake_hash }} |
| 232 |
|
| 233 |
- name: Build dependencies |
| 234 |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} |
| 235 |
working-directory: ${{github.workspace}}\deps |
| 236 |
run: | |
| 237 |
cmake --preset python-module -DCMAKE_BUILD_TYPE=Release |
| 238 |
cmake --build --preset python-module |
| 239 |
cmake --preset python-module -DCMAKE_BUILD_TYPE=Debug |
| 240 |
cmake --build --preset python-module |
| 241 |
|
| 242 |
- name: Configure CMake |
| 243 |
# Use a bash shell so we can use the same syntax for environment variable |
| 244 |
# access regardless of the host operating system |
| 245 |
working-directory: ${{github.workspace}}\build |
| 246 |
# Note the current convention is to use the -S and -B options here to specify source |
| 247 |
# and build directories, but this is only available with CMake 3.13 and higher. |
| 248 |
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12 |
| 249 |
run: > |
| 250 |
cmake .. -DCMAKE_PREFIX_PATH=${{github.workspace}}\deps\build-python-module\destdir\usr\local |
| 251 |
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}\build\dist |
| 252 |
-DCATCH_EXTRA_ARGS="--reporter;junit;--out=result-junit-msvc.xml" |
| 253 |
|
| 254 |
- name: Build |
| 255 |
working-directory: ${{github.workspace}}\build |
| 256 |
# Execute the build. You can specify a specific target with "--target <NAME>" |
| 257 |
run: cmake --build . --config $Env:BUILD_TYPE --target install |
| 258 |
|
| 259 |
- name: Test |
| 260 |
working-directory: ${{github.workspace}}\build |
| 261 |
# Execute tests defined by the CMake configuration. |
| 262 |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 263 |
run: ctest --verbose -C Release |
| 264 |
|
| 265 |
- name: Build example (using find_package) |
| 266 |
working-directory: ${{github.workspace}}\example\build_fp |
| 267 |
run: | |
| 268 |
cmake .. -DCMAKE_PREFIX_PATH="${{github.workspace}}\build\dist;${{github.workspace}}\deps\build-python-module\destdir\usr\local" |
| 269 |
cmake --build . --config Release |
| 270 |
|
| 271 |
- name: Build example (using add_subdirectory) |
| 272 |
working-directory: ${{github.workspace}}\example\build_subd |
| 273 |
run: | |
| 274 |
cmake .. -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_PREFIX_PATH=${{github.workspace}}\deps\build-python-module\destdir\usr\local |
| 275 |
cmake --build . --config Release |
| 276 |
|
| 277 |
- name: Build Python wheel |
| 278 |
working-directory: ${{github.workspace}} |
| 279 |
run: python -m build --wheel |
| 280 |
|
| 281 |
- uses: actions/upload-artifact@v4 # upload test results |
| 282 |
if: success() || failure() # run this step even if previous step failed |
| 283 |
with: |
| 284 |
name: test-results-msvc |
| 285 |
path: ${{github.workspace}}\build\**\result-junit-msvc.xml |
| 286 |
|
| 287 |
- uses: actions/upload-artifact@v4 # upload python module |
| 288 |
name: Saving Python artifacts |
| 289 |
if: success() |
| 290 |
with: |
| 291 |
name: libbgcode-python-msvc |
| 292 |
path: ${{github.workspace}}\dist\ |
| 293 |
|
| 294 |
build-mac: |
| 295 |
# The CMake configure and build commands are platform agnostic and should work equally |
| 296 |
# well on Windows or Mac. You can convert this to a matrix build if you need |
| 297 |
# cross-platform coverage. |
| 298 |
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 299 |
runs-on: macos-latest |
| 300 |
|
| 301 |
steps: |
| 302 |
- uses: actions/checkout@v3 |
| 303 |
|
| 304 |
# - uses: actions/setup-python@v4 |
| 305 |
# with: |
| 306 |
# python-version: '3.10' |
| 307 |
|
| 308 |
- name: Hashing dependency CMake files |
| 309 |
id: dep_cmake_hash |
| 310 |
run: echo "dep_cmake_hash=${{ hashFiles('./deps/**') }}" >> $GITHUB_OUTPUT |
| 311 |
|
| 312 |
- name: Create Build Environment |
| 313 |
# Some projects don't allow in-source building, so create a separate build directory |
| 314 |
# We'll use this as our working directory for all subsequent commands |
| 315 |
run: | |
| 316 |
brew install python-build |
| 317 |
cmake -E make_directory ${{github.workspace}}/build |
| 318 |
cmake -E make_directory ${{github.workspace}}/build/dist |
| 319 |
cmake -E make_directory ${{github.workspace}}/example/build_fp |
| 320 |
cmake -E make_directory ${{github.workspace}}/example/build_subd |
| 321 |
|
| 322 |
- uses: actions/cache@v3 |
| 323 |
name: Getting dependency cache |
| 324 |
id: cache |
| 325 |
with: |
| 326 |
path: ${{github.workspace}}/deps/build-python-module/destdir |
| 327 |
key: ${{ runner.os }}-${{ matrix.arch }}-build-deps-${{ steps.dep_cmake_hash.outputs.dep_cmake_hash }} |
| 328 |
|
| 329 |
- name: Build dependencies |
| 330 |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} |
| 331 |
shell: bash |
| 332 |
working-directory: ${{github.workspace}}/deps/ |
| 333 |
run: | |
| 334 |
cmake --preset python-module -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 |
| 335 |
cmake --build --preset python-module |
| 336 |
|
| 337 |
- name: Configure CMake |
| 338 |
# Use a bash shell so we can use the same syntax for environment variable |
| 339 |
# access regardless of the host operating system |
| 340 |
shell: bash |
| 341 |
working-directory: ${{github.workspace}}/build |
| 342 |
# Note the current convention is to use the -S and -B options here to specify source |
| 343 |
# and build directories, but this is only available with CMake 3.13 and higher. |
| 344 |
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12 |
| 345 |
run: > |
| 346 |
cmake $GITHUB_WORKSPACE |
| 347 |
-DCMAKE_BUILD_TYPE=$BUILD_TYPE |
| 348 |
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 |
| 349 |
-DCMAKE_PREFIX_PATH=${{github.workspace}}/deps/build-python-module/destdir/usr/local |
| 350 |
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/dist |
| 351 |
-DCATCH_EXTRA_ARGS="--reporter;junit;--out=result-junit-mac.xml" |
| 352 |
|
| 353 |
- name: Build |
| 354 |
working-directory: ${{github.workspace}}/build |
| 355 |
shell: bash |
| 356 |
run: cmake --build . --target install |
| 357 |
|
| 358 |
- name: Test |
| 359 |
working-directory: ${{github.workspace}}/build |
| 360 |
shell: bash |
| 361 |
# Execute tests defined by the CMake configuration. |
| 362 |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 363 |
run: ctest --verbose |
| 364 |
|
| 365 |
- name: Build Python wheel |
| 366 |
working-directory: ${{github.workspace}} |
| 367 |
shell: bash |
| 368 |
run: pyproject-build --wheel |
| 369 |
|
| 370 |
- name: Build example (using find_package) |
| 371 |
working-directory: ${{github.workspace}}/example/build_fp |
| 372 |
shell: bash |
| 373 |
run: | |
| 374 |
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DCMAKE_PREFIX_PATH="${{github.workspace}}/build/dist;${{github.workspace}}/deps/build-python-module/destdir/usr/local" |
| 375 |
cmake --build . |
| 376 |
|
| 377 |
- name: Build example (using add_subdirectory) |
| 378 |
working-directory: ${{github.workspace}}/example/build_subd |
| 379 |
shell: bash |
| 380 |
run: | |
| 381 |
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DBGCODE_AS_SUBPROJECT=ON -DLibBGCode_BUILD_TESTS=OFF -DCMAKE_PREFIX_PATH=${{github.workspace}}/deps/build-python-module/destdir/usr/local |
| 382 |
cmake --build . |
| 383 |
|
| 384 |
- uses: actions/upload-artifact@v4 # upload test results |
| 385 |
if: success() || failure() # run this step even if previous step failed |
| 386 |
with: |
| 387 |
name: test-results-mac |
| 388 |
path: ${{github.workspace}}/build/**/result-junit-mac.xml |
| 389 |
|
| 390 |
- uses: actions/upload-artifact@v4 # upload python module |
| 391 |
name: Saving Python artifacts |
| 392 |
if: success() |
| 393 |
with: |
| 394 |
name: libbgcode-python-mac |
| 395 |
path: ${{github.workspace}}/dist/ |