Skip to content

Commit 4907215

Browse files
authored
Fix cmake and add CI github (#1)
* Create ci.yml * Update CMakeLists.txt
1 parent 385ec23 commit 4907215

3 files changed

Lines changed: 137 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
8+
jobs:
9+
build-and-test:
10+
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-20.04, macos-10.15, windows-2019]
16+
sofa_branch: [master]
17+
18+
steps:
19+
- name: Setup SOFA and environment
20+
id: sofa
21+
uses: sofa-framework/sofa-setup-action@v3.0
22+
with:
23+
sofa_root: ${{ github.workspace }}/sofa
24+
sofa_version: ${{ matrix.sofa_branch }}
25+
26+
- name: Checkout source code
27+
uses: actions/checkout@v2
28+
with:
29+
path: ${{ env.WORKSPACE_SRC_PATH }}
30+
31+
- name: Build and install
32+
shell: bash
33+
run: |
34+
if [[ "$RUNNER_OS" == "Windows" ]]; then
35+
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
36+
&& cd /d $WORKSPACE_BUILD_PATH \
37+
&& cmake \
38+
-GNinja \
39+
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
40+
-DCMAKE_BUILD_TYPE=Release \
41+
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
42+
../src \
43+
&& ninja -v install"
44+
else
45+
cd "$WORKSPACE_BUILD_PATH"
46+
ccache -z
47+
cmake \
48+
-GNinja \
49+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
50+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
51+
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
52+
-DCMAKE_BUILD_TYPE=Release \
53+
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
54+
../src
55+
ninja -v install
56+
echo ${CCACHE_BASEDIR}
57+
ccache -s
58+
fi
59+
- name: Create artifact
60+
uses: actions/upload-artifact@v2
61+
with:
62+
name: PluginExample_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
63+
path: ${{ env.WORKSPACE_INSTALL_PATH }}
64+
65+
- name: Install artifact
66+
uses: actions/download-artifact@v2
67+
with:
68+
name: PluginExample_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
69+
path: ${{ env.WORKSPACE_ARTIFACT_PATH }}
70+
71+
- name: Set env vars for tests
72+
shell: bash
73+
run: |
74+
# Set env vars for tests
75+
if [[ "$RUNNER_OS" == "Windows" ]]; then
76+
echo "$(cd $WORKSPACE_ARTIFACT_PATH/lib && pwd -W)" >> $GITHUB_PATH
77+
echo "$(cd $WORKSPACE_ARTIFACT_PATH/bin && pwd -W)" >> $GITHUB_PATH
78+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
79+
echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV
80+
fi
81+
echo "LD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV
82+
# Add execution right on the tests
83+
chmod +x $WORKSPACE_BUILD_PATH/PluginExample_test/PluginExample_test${{ steps.sofa.outputs.exe }}
84+
85+
- name: Check environment for tests
86+
shell: bash
87+
run: |
88+
echo '------ ls -la "$WORKSPACE_SRC_PATH" ------'
89+
ls -la "$WORKSPACE_SRC_PATH"
90+
echo '------ ls -la "$WORKSPACE_BUILD_PATH" ------'
91+
ls -la "$WORKSPACE_BUILD_PATH"
92+
echo '------ ls -la "$WORKSPACE_INSTALL_PATH" ------'
93+
ls -la "$WORKSPACE_INSTALL_PATH"
94+
echo '------ ls -la "$WORKSPACE_ARTIFACT_PATH" ------'
95+
ls -la "$WORKSPACE_ARTIFACT_PATH"
96+
97+
- name: Run test PluginExample_test
98+
if: always()
99+
shell: bash
100+
run: |
101+
cd $WORKSPACE_BUILD_PATH
102+
./PluginExample_test/PluginExample_test${{ steps.sofa.outputs.exe }}
103+
104+
deploy:
105+
name: Deploy artifacts
106+
if: always() && startsWith(github.ref, 'refs/heads/') # we are on a branch (not a PR)
107+
needs: [build-and-test]
108+
runs-on: ubuntu-latest
109+
continue-on-error: true
110+
steps:
111+
- name: Get artifacts
112+
uses: actions/download-artifact@v2
113+
with:
114+
path: artifacts
115+
116+
- name: Zip artifacts
117+
shell: bash
118+
run: |
119+
cd $GITHUB_WORKSPACE/artifacts
120+
for artifact in *; do
121+
zip $artifact.zip -r $artifact/*
122+
done
123+
- name: Upload release
124+
uses: softprops/action-gh-release@v1
125+
with:
126+
name: ${{ github.ref_name }}
127+
tag_name: release-${{ github.ref_name }}
128+
fail_on_unmatched_files: true
129+
files: |
130+
artifacts/PluginExample_*_Linux.zip
131+
artifacts/PluginExample_*_Windows.zip
132+
artifacts/PluginExample_*_macOS.zip

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ set(SOURCE_FILES
2525
${PLUGINEXAMPLE_SRC_DIR}/initPluginExample.cpp
2626
${PLUGINEXAMPLE_SRC_DIR}/MyBehaviorModel.cpp
2727
${PLUGINEXAMPLE_SRC_DIR}/MyVisualModel.cpp
28-
${PLUGINEXAMPLE_SRC_DIR}/MyDataWidgetUnsigned.cpp
2928
${PLUGINEXAMPLE_SRC_DIR}/MyMappingPendulumInPlane.cpp
3029
${PLUGINEXAMPLE_SRC_DIR}/MyProjectiveConstraintSet.cpp
3130
)
3231
set(README_FILES
33-
PluginExample.md
32+
README.md
3433
)
3534

3635
if(Qt5Core_FOUND AND SofaGui_FOUND)

PluginExample_test/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ cmake_minimum_required(VERSION 3.12)
22

33
project(PluginExample_test)
44

5-
find_package(PluginExample REQUIRED)
5+
# find_package(PluginExample REQUIRED)
6+
find_package(Threads REQUIRED)
7+
find_package(Sofa.Testing REQUIRED)
68

79
set(SOURCE_FILES
810
MyBehaviorModel_test.cpp
911
)
1012

1113
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
12-
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Testing PluginExample)
14+
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Testing PluginExample Threads::Threads)
1315

1416
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})

0 commit comments

Comments
 (0)