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 : Set env vars for pybind11 installation
32+ shell : bash
33+ run : |
34+ # Define pybind11 specs
35+ PYBIND11_VERSION=2.4.3
36+ PYBIND11_INSTALL_PATH="/tmp/deps_cache_is_for_windows_only"
37+ if [[ "$RUNNER_OS" == "Windows" ]]; then
38+ PYBIND11_INSTALL_PATH="C:/pybind11"
39+ fi
40+ echo "PYBIND11_VERSION=$PYBIND11_VERSION" | tee -a $GITHUB_ENV
41+ echo "PYBIND11_INSTALL_PATH=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV
42+
43+ - name : Setup cache for pybind11 files
44+ uses : actions/cache@v2
45+ id : pybind11_cache
46+ with :
47+ path : ${{ env.PYBIND11_INSTALL_PATH }}
48+ key : pybind11-${{ env.PYBIND11_VERSION }}_${{ runner.os }}_python-${{ steps.sofa.outputs.python_version }}_${{ hashFiles('src/.github/workflows/*.yml') }}
49+
50+ - name : Install pybind11
51+ shell : bash
52+ run : |
53+ # Build and install pybind11
54+ if [[ "$RUNNER_OS" == "Windows" ]]; then
55+ if ! ls -a "$PYBIND11_INSTALL_PATH"/* >/dev/null 2>&1; then
56+ # directory does not exist or is empty
57+ git clone -b v$PYBIND11_VERSION --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp"
58+ cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} && \
59+ cd /d ${{ runner.temp }}/pybind11_tmp && \
60+ cmake \
61+ -GNinja \
62+ -DCMAKE_BUILD_TYPE=Release \
63+ -DPYBIND11_TEST=OFF \
64+ -DCMAKE_INSTALL_PREFIX=$PYBIND11_INSTALL_PATH \
65+ -DPYTHON_ROOT=$PYTHON_ROOT \
66+ -DPython_ROOT=$PYTHON_ROOT \
67+ -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python.exe \
68+ -DPython_EXECUTABLE=$PYTHON_ROOT/python.exe \
69+ . && \
70+ ninja install"
71+ fi
72+ echo "pybind11_ROOT=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV
73+ echo "$PYBIND11_INSTALL_PATH" >> $GITHUB_PATH
74+ else
75+ git clone -b v${PYBIND11_VERSION} --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp"
76+ cd "${{ runner.temp }}/pybind11_tmp"
77+ cmake \
78+ -GNinja \
79+ -DCMAKE_BUILD_TYPE=Release \
80+ -DPYBIND11_TEST=OFF \
81+ -DPYTHON_ROOT=$PYTHON_ROOT \
82+ -DPython_ROOT=$PYTHON_ROOT \
83+ -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python \
84+ -DPython_EXECUTABLE=$PYTHON_ROOT/python \
85+ .
86+ sudo ninja install
87+ fi
88+
89+ - name : Setup cache for ccache files
90+ if : ${{ runner.os != 'Windows' }}
91+ uses : actions/cache@v2
92+ with :
93+ path : ${{ env.CCACHE_DIR }}
94+ key : ccache_${{ runner.os }}
95+
96+ - name : Build and install
97+ shell : bash
98+ run : |
99+ if [[ "$RUNNER_OS" == "Windows" ]]; then
100+ cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
101+ && cd /d $WORKSPACE_BUILD_PATH \
102+ && cmake \
103+ -GNinja \
104+ -DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
105+ -DCMAKE_BUILD_TYPE=Release \
106+ -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
107+ -DPYTHON_ROOT=$PYTHON_ROOT \
108+ -DPython_ROOT=$PYTHON_ROOT \
109+ -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python.exe \
110+ -DPython_EXECUTABLE=$PYTHON_ROOT/python.exe \
111+ ../src \
112+ && ninja install"
113+ else
114+ cd "$WORKSPACE_BUILD_PATH"
115+ ccache -z
116+ cmake \
117+ -GNinja \
118+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
119+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
120+ -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
121+ -DCMAKE_BUILD_TYPE=Release \
122+ -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
123+ -DPYTHON_ROOT=$PYTHON_ROOT \
124+ -DPython_ROOT=$PYTHON_ROOT \
125+ -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python \
126+ -DPython_EXECUTABLE=$PYTHON_ROOT/python \
127+ ../src
128+ ninja install
129+ echo ${CCACHE_BASEDIR}
130+ ccache -s
131+ fi
132+
133+ - name : Create artifact
134+ uses : actions/upload-artifact@v2
135+ with :
136+ name : SofaPython3_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
137+ path : ${{ env.WORKSPACE_INSTALL_PATH }}
138+
139+ - name : Install artifact
140+ uses : actions/download-artifact@v2
141+ with :
142+ name : SofaPython3_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
143+ path : ${{ env.WORKSPACE_ARTIFACT_PATH }}
144+
145+ - name : Set env vars for tests
146+ shell : bash
147+ run : |
148+ # Set env vars for tests
149+ if [[ "$RUNNER_OS" == "Windows" ]]; then
150+ echo "$(cd $WORKSPACE_ARTIFACT_PATH/lib && pwd -W)" >> $GITHUB_PATH
151+ echo "$(cd $WORKSPACE_ARTIFACT_PATH/bin && pwd -W)" >> $GITHUB_PATH
152+ elif [[ "$RUNNER_OS" == "macOS" ]]; then
153+ echo "DYLD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$DYLD_LIBRARY_PATH" | tee -a $GITHUB_ENV
154+ fi
155+ echo "LD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV
156+ echo "PYTHONPATH=$WORKSPACE_ARTIFACT_PATH/lib/python3/site-packages" | tee -a $GITHUB_ENV
157+ # Add execution right on the tests
158+ chmod +x $WORKSPACE_ARTIFACT_PATH/bin/*.Tests${{ steps.sofa.outputs.exe }}
159+
160+ - name : Check environment for tests
161+ shell : bash
162+ run : |
163+ echo '------ ls -la "$WORKSPACE_SRC_PATH" ------'
164+ ls -la "$WORKSPACE_SRC_PATH"
165+ echo '------ ls -la "$WORKSPACE_BUILD_PATH" ------'
166+ ls -la "$WORKSPACE_BUILD_PATH"
167+ echo '------ ls -la "$WORKSPACE_INSTALL_PATH" ------'
168+ ls -la "$WORKSPACE_INSTALL_PATH"
169+ echo '------ ls -la "$WORKSPACE_ARTIFACT_PATH" ------'
170+ ls -la "$WORKSPACE_ARTIFACT_PATH"
171+ echo '----------------------'
172+ echo "SOFA_ROOT = $SOFA_ROOT"
173+ echo "PYTHONPATH = $PYTHONPATH"
174+ echo '----------------------'
175+ echo "which python = $(which python)"
176+ python -c "import sys; print('sys.version = ' + str(sys.version)); print('sys.path = ' + str(sys.path))"
177+
178+ - name : Run test Binding.Sofa.Tests
179+ if : always()
180+ shell : bash
181+ run : |
182+ cd $WORKSPACE_ARTIFACT_PATH
183+ ./bin/Bindings.Sofa.Tests${{ steps.sofa.outputs.exe }}
184+
185+ - name : Run test Bindings.SofaRuntime.Tests
186+ if : always()
187+ shell : bash
188+ run : |
189+ cd $WORKSPACE_ARTIFACT_PATH
190+ ./bin/Bindings.SofaRuntime.Tests${{ steps.sofa.outputs.exe }}
191+
192+ - name : Run test Bindings.SofaTypes.Tests
193+ if : always()
194+ shell : bash
195+ run : |
196+ cd $WORKSPACE_ARTIFACT_PATH
197+ ./bin/Bindings.SofaTypes.Tests${{ steps.sofa.outputs.exe }}
198+
199+ - name : Run test Bindings.Modules.Tests
200+ if : always()
201+ shell : bash
202+ run : |
203+ cd $WORKSPACE_ARTIFACT_PATH
204+ ./bin/Bindings.Modules.Tests${{ steps.sofa.outputs.exe }}
205+
206+ deploy :
207+ name : Deploy artifacts
208+ if : always() && startsWith(github.ref, 'refs/heads/') # we are on a branch (not a PR)
209+ needs : [build-and-test]
210+ runs-on : ubuntu-latest
211+ continue-on-error : true
212+ steps :
213+ - name : Get artifacts
214+ uses : actions/download-artifact@v2
215+ with :
216+ path : artifacts
217+
218+ - name : Zip artifacts
219+ shell : bash
220+ run : |
221+ cd $GITHUB_WORKSPACE/artifacts
222+ for artifact in *; do
223+ zip $artifact.zip -r $artifact/*
224+ done
225+
226+ - name : Upload release
227+ uses : softprops/action-gh-release@v1
228+ with :
229+ tag_name : ${{ github.ref_name }}
230+ fail_on_unmatched_files : true
231+ files : |
232+ artifacts/SofaPython3_*_Linux.zip
233+ artifacts/SofaPython3_*_Windows.zip
234+ artifacts/SofaPython3_*_macOS.zip
235+
0 commit comments