Skip to content

Commit 97d7464

Browse files
committed
[ci] Update Github Action yml to build with and without the dependency to MeshRefinement plugin (#56)
1 parent 1c92e0e commit 97d7464

2 files changed

Lines changed: 70 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
jobs:
1616
build-and-test:
17-
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 }}
1818
if: >
1919
github.event_name == 'push' ||
2020
(
@@ -27,14 +27,18 @@ jobs:
2727
)
2828
)
2929
)
30+
3031
runs-on: ${{ matrix.os }}
32+
3133
strategy:
3234
fail-fast: false
3335
matrix:
3436
os: [ubuntu-22.04, macos-14, windows-2022]
3537
sofa_branch: [v25.12]
38+
with_mesh_refinement: [ON, OFF]
3639

3740
steps:
41+
####################### Setup SOFA #######################
3842
- name: Setup SOFA and environment
3943
id: sofa
4044
uses: sofa-framework/sofa-setup-action@v5
@@ -43,22 +47,66 @@ jobs:
4347
sofa_version: ${{ matrix.sofa_branch }}
4448
sofa_scope: 'full'
4549

46-
- 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
4793
uses: actions/checkout@v4
4894
with:
4995
path: ${{ env.WORKSPACE_SRC_PATH }}
5096

97+
################ Build and install current plugin ##############
5198
- name: Build and install
5299
shell: bash
53100
run: |
54101
if [[ "$RUNNER_OS" == "Windows" ]]; then
55102
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
56-
&& cd /d $WORKSPACE_BUILD_PATH \
103+
&& cd /d %GITHUB_WORKSPACE%/build \
57104
&& cmake \
58105
-GNinja \
59-
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
106+
-DCMAKE_PREFIX_PATH=%SOFA_ROOT%/lib/cmake;%GITHUB_WORKSPACE%/deps/MeshRefinement/install \
60107
-DCMAKE_BUILD_TYPE=Release \
61-
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
108+
-DCMAKE_INSTALL_PREFIX=%GITHUB_WORKSPACE%/install \
109+
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=%WORKSPACE_BUILD_PATH% \
62110
../src \
63111
&& ninja install"
64112
else
@@ -68,9 +116,10 @@ jobs:
68116
-GNinja \
69117
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
70118
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
71-
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
119+
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake;$GITHUB_WORKSPACE/deps/MeshRefinement/install" \
72120
-DCMAKE_BUILD_TYPE=Release \
73121
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
122+
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$WORKSPACE_BUILD_PATH/lib" \
74123
../src
75124
ninja install
76125
echo ${CCACHE_BASEDIR}
@@ -85,10 +134,18 @@ jobs:
85134
# This sanitization prevents errors in artifact creation and retrieval
86135
shell: pwsh
87136
run: |
88-
$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 }}"
89145
$artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_'
90146
echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT
91-
147+
148+
################### Create and upload artifact ##############
92149
- name: Create artifact
93150
id: create-artifact
94151
uses: actions/upload-artifact@v4.4.0
@@ -115,6 +172,8 @@ jobs:
115172
output_dir: ${{ github.workspace }}/tests-results_dir
116173
nb_parallel_threads: '4'
117174

175+
176+
118177
deploy:
119178
name: Deploy artifacts
120179
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)