@@ -179,6 +179,7 @@ jobs:
179179
180180
181181 - name : Build SOFA [MacOS/Linux/Windows]
182+ id : build-step
182183 shell : bash -el {0}
183184 env :
184185 SOFA_BUILD_TYPE : ${{ matrix.build_type }}
@@ -213,9 +214,139 @@ jobs:
213214 pixi run -e ${{ inputs.preset }} configure $CMAKE_OPTIONS
214215 pixi run -e ${{ inputs.preset }} build
215216
216- - name : Testing - Run SOFA in batch mode [MacOS/Linux/Windows]
217- shell : bash -el {0}
218- env :
219- SOFA_BUILD_TYPE : ${{ matrix.build_type }}
217+
218+ - name : Unit tests
219+ id : unit-tests-step
220+ if : always() && steps.build-step.outcome == 'success' && inputs.generate-binaries == false
221+ shell : bash
222+ run : |
223+ # If os has got docker then use it
224+ # Here no need to fetch it because it has already been taken care of in the build step
225+
226+ echo "Launching unit test suite."
227+ bash ${CI_DIR}/scripts/test.sh "${SOFA_BUILD_DIR}" "${SRC_DIR}" "${CI_DIR}/scripts/" "" "${{ inputs.python-version }}" "UNIT"
228+
229+ if [[ "$(cd "${{ env.SOFA_BUILD_DIR }}/tests_results/" && find . -maxdepth 1 -type f)" == *"unit-tests_"* ]]; then
230+ exit 1
231+ fi
232+
233+ - name : Scene tests
234+ id : scene-tests-step
235+ if : always() && matrix.os == 'windows-latest' && steps.build-step.outcome == 'success' && inputs.generate-binaries == false && inputs.with-all-tests == true
236+ shell : bash
237+ run : |
238+ # If os has got docker then use it
239+ # Here no need to fetch it because it has already been taken care of in the build step
240+
241+ echo "Launching scene test suite."
242+ bash ${CI_DIR}/scripts/test.sh "${SOFA_BUILD_DIR}" "${SRC_DIR}" "${CI_DIR}/scripts/" "" "${{ inputs.python-version }}" "SCENE"
243+
244+ if [[ "$(cd "${{ env.SOFA_BUILD_DIR }}/tests_results/" && find . -maxdepth 1 -type f)" == *"scene-tests_"* ]]; then
245+ exit 1
246+ fi
247+
248+ - name : Regression tests
249+ id : regression-tests-step
250+ if : always() && matrix.os == 'windows-latest' && steps.build-step.outcome == 'success' && inputs.generate-binaries == false && inputs.with-all-tests == true
251+ shell : bash
252+ run : |
253+ # If os has got docker then use it
254+ # Here no need to fetch it because it has already been taken care of in the build step
255+
256+ echo "Launching regression test suite"
257+ bash ${CI_DIR}/scripts/test.sh "${SOFA_BUILD_DIR}" "${SRC_DIR}" "${CI_DIR}/scripts/" "" "${{ inputs.python-version }}" "REGRESSION"
258+
259+ if [[ "$(cd "${{ env.SOFA_BUILD_DIR }}/tests_results/" && find . -maxdepth 1 -type f)" == *"regression-tests_"* ]]; then
260+ exit 1
261+ fi
262+
263+
264+ - name : Publish artifacts
265+ if : steps.build-step.outcome == 'success' && inputs.generate-binaries == true
266+ uses : actions/upload-artifact@v4
267+ with :
268+ name : binaries_${{ env.BUILDER_OS }}
269+ path : |
270+ ${{ env.SOFA_BUILD_DIR }}/SOFA_v*
271+
272+
273+ - name : Publish build logs
274+ id : publish-build-logs
275+ if : always()
276+ uses : actions/upload-artifact@v4
277+ with :
278+ name : build-logs_${{ env.BUILDER_OS }}
279+ path : |
280+ ${{ env.LOG_DIR }}/make-output.txt
281+ ${{ env.LOG_DIR }}/cmake-output.txt
282+
283+
284+ - name : Publish tests logs
285+ id : publish-tests-logs
286+ if : always()
287+ uses : actions/upload-artifact@v4
288+ with :
289+ name : tests-logs_${{ env.BUILDER_OS }}
290+ path : |
291+ ${{ env.SOFA_BUILD_DIR }}/tests_results/
292+
293+
294+ - name : Summarize results
295+ if : always()
296+ shell : bash
220297 run : |
221- pixi run -e ${{ inputs.preset }} runSofa -g batch
298+ bold="\033[1m"
299+ normal="\033[0m"
300+ if [[ "${{ steps.configure.outcome }}" == "failure" || "${{ steps.clone.outcome }}" == "failure" ]]; then
301+ echo "❌ Something whent wrong during the configure or clone steps..."
302+ echo -e "${bold}Please check those actions logs${normal}"
303+ exit 1
304+ else
305+ echo "✅ Setup OK."
306+ fi
307+
308+ if [[ "${{ steps.build-step.outcome }}" == "failure" ]]; then
309+ echo "❌ Build step failed"
310+ echo -e "${bold}You can download all logs here : ${{ steps.publish-build-logs.outputs.artifact-url }}${normal}"
311+ exit 1
312+ else
313+ echo "✅ Build OK."
314+ fi
315+
316+ if [[ "${{ inputs.generate-binaries }}" == "false" ]]; then
317+ if [[ "$(cd "${{ env.SOFA_BUILD_DIR }}/tests_results/" && find . -maxdepth 1 -type f)" != "" ]]; then
318+ echo "❌ Tests have resulted in : "
319+ echo ""
320+ python3 ${{ env.CI_DIR }}/scripts/generate-tests-table.py "${{ env.SOFA_BUILD_DIR }}/tests_results/"
321+ echo ""
322+ echo "#----------------------------------------#"
323+ echo "#---------------Quick Logs---------------#"
324+ echo "#----------------------------------------#"
325+ for testType in 'unit' 'scene' 'regression';
326+ do
327+ for errorType in 'errors' 'crashes' 'failures';
328+ do
329+ if [ -f "${{ env.SOFA_BUILD_DIR }}/tests_results/${testType}-tests_${errorType}" ]; then
330+ capitalized="$(echo "${testType:0:1}" | tr '[:lower:]' '[:upper:]')${testType:1}"
331+ echo ""
332+ echo -e "${bold}${capitalized} ${errorType}:${normal}"
333+ echo ""
334+ cat "${{ env.SOFA_BUILD_DIR }}/tests_results/${testType}-tests_${errorType}"
335+ echo ""
336+ echo "#----------------------------------------#"
337+ fi
338+ done
339+ done
340+ echo -e "${bold}You can download all logs here : ${{ steps.publish-tests-logs.outputs.artifact-url }}${normal}"
341+ exit 1
342+ elif [[ "${{ steps.unit-tests-step.outcome }}" == "failure" || "${{ steps.scene-tests-step.outcome }}" == "failure" || "${{ steps.regression-tests-step.outcome }}" == "failure" ]]; then
343+ echo "❌ Something whent wrong during one of the tests steps"
344+ echo -e "${bold}Please check this action logs, and download tests logs here: ${{ steps.publish-tests-logs.outputs.artifact-url }}${normal}"
345+ exit 1
346+ else
347+ echo "✅ Tests where successful : "
348+ echo ""
349+ python3 ${{ env.CI_DIR }}/scripts/generate-tests-table.py "${{ env.SOFA_BUILD_DIR }}/tests_results/"
350+ echo ""
351+ fi
352+ fi
0 commit comments