Skip to content

Commit ce2e46a

Browse files
authored
[ci] Update Github Action yml to build with and without the dependency to MeshRefinement plugin (#56)
* [ci] test compilation with link to MeshRefinement * Change ssh-key to token for MeshRefinement checkout * Remove message for finding MeshRefinement package * try to fix windows compilation * Update prefix_path * fix windows? problem of double quotes * add with or without option * remove extra_prefix_path * restore full ci * fix windows tests?
1 parent c5e79db commit ce2e46a

2 files changed

Lines changed: 73 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ on:
66
- main
77
- master
88

9+
tags:
10+
- 'v*' #release tags in format of 'v25.12.00' for example
11+
912
pull_request:
1013
types: [opened, synchronize, reopened, labeled]
1114

1215
jobs:
1316
build-and-test:
14-
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
17+
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }} / MeshRefinement=${{ matrix.with_mesh_refinement }}
1518
if: >
1619
github.event_name == 'push' ||
1720
(
@@ -24,14 +27,18 @@ jobs:
2427
)
2528
)
2629
)
30+
2731
runs-on: ${{ matrix.os }}
32+
2833
strategy:
2934
fail-fast: false
3035
matrix:
3136
os: [ubuntu-22.04, macos-14, windows-2022]
3237
sofa_branch: [master]
38+
with_mesh_refinement: [ON, OFF]
3339

3440
steps:
41+
####################### Setup SOFA #######################
3542
- name: Setup SOFA and environment
3643
id: sofa
3744
uses: sofa-framework/sofa-setup-action@v5
@@ -40,22 +47,66 @@ jobs:
4047
sofa_version: ${{ matrix.sofa_branch }}
4148
sofa_scope: 'full'
4249

43-
- name: Checkout source code
50+
############## Checkout MeshRefinement only if enabled ##############
51+
- name: Checkout MeshRefinement source code
52+
if: matrix.with_mesh_refinement == 'ON'
53+
uses: actions/checkout@v4
54+
with:
55+
path: deps/MeshRefinement
56+
repository: InfinyTech3D/MeshRefinement
57+
token: ${{ secrets.MESH_REFINEMENT_DEPLOY_KEY }}
58+
59+
############### Build and install MeshRefinement only if enabled ##############
60+
- name: Build and install MeshRefinement
61+
if: matrix.with_mesh_refinement == 'ON'
62+
shell: bash
63+
run: |
64+
mkdir -p deps/MeshRefinement/build
65+
66+
if [[ "$RUNNER_OS" == "Windows" ]]; then
67+
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
68+
&& cd /d %GITHUB_WORKSPACE%/deps/MeshRefinement/build \
69+
&& cmake \
70+
-GNinja \
71+
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
72+
-DCMAKE_BUILD_TYPE=Release \
73+
-DCMAKE_INSTALL_PREFIX=%GITHUB_WORKSPACE%/deps/MeshRefinement/install \
74+
.. \
75+
&& ninja install"
76+
# Temp hack
77+
cp deps/MeshRefinement/install/bin/MeshRefinement.dll "$WORKSPACE_BUILD_PATH/"
78+
79+
else
80+
cd deps/MeshRefinement/build
81+
cmake \
82+
-GNinja \
83+
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
84+
-DCMAKE_BUILD_TYPE=Release \
85+
-DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/deps/MeshRefinement/install" \
86+
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$WORKSPACE_BUILD_PATH/lib" \
87+
..
88+
ninja install
89+
fi
90+
91+
################# Checkout current repository ##############
92+
- name: Checkout current source code
4493
uses: actions/checkout@v4
4594
with:
4695
path: ${{ env.WORKSPACE_SRC_PATH }}
4796

97+
################ Build and install current plugin ##############
4898
- name: Build and install
4999
shell: bash
50100
run: |
51101
if [[ "$RUNNER_OS" == "Windows" ]]; then
52102
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
53-
&& cd /d $WORKSPACE_BUILD_PATH \
103+
&& cd /d %GITHUB_WORKSPACE%/build \
54104
&& cmake \
55105
-GNinja \
56-
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
106+
-DCMAKE_PREFIX_PATH=%SOFA_ROOT%/lib/cmake;%GITHUB_WORKSPACE%/deps/MeshRefinement/install \
57107
-DCMAKE_BUILD_TYPE=Release \
58-
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
108+
-DCMAKE_INSTALL_PREFIX=%GITHUB_WORKSPACE%/install \
109+
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=%WORKSPACE_BUILD_PATH% \
59110
../src \
60111
&& ninja install"
61112
else
@@ -65,9 +116,10 @@ jobs:
65116
-GNinja \
66117
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
67118
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
68-
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
119+
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake;$GITHUB_WORKSPACE/deps/MeshRefinement/install" \
69120
-DCMAKE_BUILD_TYPE=Release \
70121
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
122+
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$WORKSPACE_BUILD_PATH/lib" \
71123
../src
72124
ninja install
73125
echo ${CCACHE_BASEDIR}
@@ -82,10 +134,18 @@ jobs:
82134
# This sanitization prevents errors in artifact creation and retrieval
83135
shell: pwsh
84136
run: |
85-
$originalName = "InfinyToolkit_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}"
137+
if ("${{ matrix.with_mesh_refinement }}" -eq "ON") {
138+
$dependency = "with_meshrefinement"
139+
}
140+
else {
141+
$dependency = "standalone"
142+
}
143+
144+
$originalName = "InfinyToolkit_${dependency}_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}"
86145
$artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_'
87146
echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT
88-
147+
148+
################### Create and upload artifact ##############
89149
- name: Create artifact
90150
id: create-artifact
91151
uses: actions/upload-artifact@v4.4.0
@@ -112,6 +172,8 @@ jobs:
112172
output_dir: ${{ github.workspace }}/tests-results_dir
113173
nb_parallel_threads: '4'
114174

175+
176+
115177
deploy:
116178
name: Deploy artifacts
117179
if: always() && startsWith(github.ref, 'refs/tags/')

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ set(SOURCE_FILES
120120
)
121121

122122
# Add component for carving using refinement mesh
123-
find_package(MeshRefinement QUIET)
123+
sofa_find_package(MeshRefinement QUIET)
124124
if (MeshRefinement_FOUND)
125125
message("MeshRefinement plugin found - Adding it to ${PROJECT_NAME}")
126126
list(APPEND HEADER_FILES
@@ -134,6 +134,8 @@ if (MeshRefinement_FOUND)
134134
)
135135

136136
add_definitions(-DHAS_MESHREFINEMENT_PLUGIN)
137+
else()
138+
message("MeshRefinement plugin NOT found")
137139
endif()
138140

139141
set(README_FILES README.md)

0 commit comments

Comments
 (0)