diff --git a/.github/workflows/CI_build_and_test.yml b/.github/workflows/CI_build_and_test.yml index cb94bac76a7..9e886fa1262 100644 --- a/.github/workflows/CI_build_and_test.yml +++ b/.github/workflows/CI_build_and_test.yml @@ -103,7 +103,7 @@ jobs: echo "Workspace folder for this build will be $WORKSPACE" - - name: Clone SOFA and CI + - name: Clone SOFA, CI and Regression id: clone shell: bash run: | @@ -169,6 +169,33 @@ jobs: cd $WORKSPACE + ## Clone Regression and use ci-depends-on structure + regression_branch=${{ inputs.sofa-branch-name }} + regression_repo_url="https://www.github.com/sofa-framework/Regression" + + + # check if ci has a ci-depends-on + regression_ci_depends_on=$(echo "${{ inputs.ci-depends-on }}" | jq .Regression) + if [ -n "${{ inputs.ci-depends-on }}" ] && [ "$regression_ci_depends_on" != "null" ]; then + echo "ci-depends-on for Regression repository detected." + regression_repo_url=$(echo "${{ inputs.ci-depends-on }}" | jq .Regression.repo_url) + regression_branch=$(echo "${{ inputs.ci-depends-on }}" | jq .Regression.branch_name) + fi + echo "REGRESSION_BRANCH=$regression_branch" >> $GITHUB_ENV + + + echo "Cloning Regression from remote ${regression_repo_url}, selecting branch ${regression_branch}" + + if [ -d $WORKSPACE/Regression ]; then + rm -rf $WORKSPACE/Regression + fi + REGRESSION_DIR=$WORKSPACE/Regression + echo "REGRESSION_DIR=$REGRESSION_DIR" >> $GITHUB_ENV + + git clone -b ${regression_branch//\"} --single-branch ${regression_repo_url//\"} + + cd $WORKSPACE + ## Setup build folder if [ "${{ inputs.force-full-build }}" == "true" ] && [ -d $WORKSPACE/build ]; then rm -rf $WORKSPACE/build @@ -285,11 +312,13 @@ jobs: DOCKER_SRC_DIR="/workspace/$(realpath --relative-to=$WORKSPACE $SRC_DIR)" DOCKER_BUILD_DIR="/workspace/$(realpath --relative-to=$WORKSPACE $BUILD_DIR)" DOCKER_CI_DIR="/workspace/$(realpath --relative-to=$WORKSPACE $CI_DIR)" + DOCKER_REGRESSION_DIR="/workspace/$(realpath --relative-to=$WORKSPACE $REGRESSION_DIR)" DOCKER_LOG_DIR="/workspace/$(realpath --relative-to=$WORKSPACE ${{ env.LOG_DIR }})" echo "DOCKER_SRC_DIR=$DOCKER_SRC_DIR" >> $GITHUB_ENV echo "DOCKER_BUILD_DIR=$DOCKER_BUILD_DIR" >> $GITHUB_ENV echo "DOCKER_CI_DIR=$DOCKER_CI_DIR" >> $GITHUB_ENV + echo "DOCKER_REGRESSION_DIR=$DOCKER_REGRESSION_DIR" >> $GITHUB_ENV echo "DOCKER_LOG_DIR=$DOCKER_LOG_DIR" >> $GITHUB_ENV export XDG_CACHE_HOME="/cache" @@ -319,17 +348,24 @@ jobs: docker run --rm \ --user 1000:1000 --network=host -v $WORKSPACE:/workspace \ ${DOCKER_IMAGE} \ - /bin/bash -c "env ; cd /workspace; /bin/bash $DOCKER_CI_DIR/scripts/test.sh $DOCKER_BUILD_DIR $DOCKER_SRC_DIR $DOCKER_CI_DIR/scripts/ ${NODE_NAME} ${{ inputs.python-version }} UNIT" + /bin/bash -c "cd /workspace; . ${DOCKER_CI_DIR}/scripts/tests/setup-test-env.sh \"${DOCKER_BUILD_DIR}\" \"${DOCKER_CI_DIR}/scripts/\" \"${NODE_NAME}\" \"${{ inputs.python-version }}\"; env; \${VM_PYTHON3_EXECUTABLE} ${DOCKER_CI_DIR}/scripts/tests/sofa_unit_tests.py --build-dir ${DOCKER_BUILD_DIR} --results-dir \${RESULTS_DIR}/unit -j \${VM_MAX_PARALLEL_TESTS}" else echo "Launching unit test suite." - bash ${CI_DIR}/scripts/test.sh "${BUILD_DIR}" "${SRC_DIR}" "${CI_DIR}/scripts/" "${NODE_NAME}" "${{ inputs.python-version }}" "UNIT" + . ${CI_DIR}/scripts/tests/setup-test-env.sh "${BUILD_DIR}" "${CI_DIR}/scripts/" "${NODE_NAME}" "${{ inputs.python-version }}" + env + ${VM_PYTHON3_EXECUTABLE} ${CI_DIR}/scripts/tests/sofa_unit_tests.py --build-dir "${BUILD_DIR}" --results-dir "${RESULTS_DIR}/unit" -j ${VM_MAX_PARALLEL_TESTS} fi - if [[ "$(cd "${{ env.BUILD_DIR }}/tests_results/" && find . -maxdepth 1 -type f)" == *"unit-tests_"* ]]; then + if [[ ! "$(cd "${{ env.BUILD_DIR }}/tests_results/unit" && find . -maxdepth 1 -type f)" == *"summary"* ]]; then exit 1 + else + if [[ "$(awk -F= '$1=="crashes" {print $2}' ${{ env.BUILD_DIR }}/tests_results/unit/summary.txt)" != '0' || "$(awk -F= '$1=="failures" {print $2}' ${{ env.BUILD_DIR }}/tests_results/unit/summary.txt)" != "0" ]]; then + exit 1 + fi fi + - name: Scene tests id: scene-tests-step if: always() && steps.build-step.outcome == 'success' && inputs.generate-binaries == false && inputs.with-all-tests == true @@ -343,15 +379,21 @@ jobs: docker run --rm \ --user 1000:1000 --network=host -v $WORKSPACE:/workspace \ ${DOCKER_IMAGE} \ - /bin/bash -c "env ; cd /workspace; /bin/bash $DOCKER_CI_DIR/scripts/test.sh $DOCKER_BUILD_DIR $DOCKER_SRC_DIR $DOCKER_CI_DIR/scripts/ ${NODE_NAME} ${{ inputs.python-version }} SCENE" + /bin/bash -c "cd /workspace; . ${DOCKER_CI_DIR}/scripts/tests/setup-test-env.sh \"${DOCKER_BUILD_DIR}\" \"${DOCKER_CI_DIR}/scripts/\" \"${NODE_NAME}\" \"${{ inputs.python-version }}\"; env ; \${VM_PYTHON3_EXECUTABLE} ${DOCKER_CI_DIR}/scripts/tests/sofa_scene_tests.py --src-dir "${DOCKER_SRC_DIR}" --build-dir \"${DOCKER_BUILD_DIR}\" --results-dir \"\${RESULTS_DIR}/scene\" -j \${VM_MAX_PARALLEL_TESTS}" else echo "Launching scene test suite." - bash ${CI_DIR}/scripts/test.sh "${BUILD_DIR}" "${SRC_DIR}" "${CI_DIR}/scripts/" "${NODE_NAME}" "${{ inputs.python-version }}" "SCENE" + . ${CI_DIR}/scripts/tests/setup-test-env.sh "${BUILD_DIR}" "${CI_DIR}/scripts/" "${NODE_NAME}" "${{ inputs.python-version }}" + env + ${VM_PYTHON3_EXECUTABLE} ${CI_DIR}/scripts/tests/sofa_scene_tests.py --src-dir "${SRC_DIR}" --build-dir "${BUILD_DIR}" --results-dir "${RESULTS_DIR}/scene" -j ${VM_MAX_PARALLEL_TESTS} fi - if [[ "$(cd "${{ env.BUILD_DIR }}/tests_results/" && find . -maxdepth 1 -type f)" == *"scene-tests_"* ]]; then + if [[ ! "$(cd "${{ env.BUILD_DIR }}/tests_results/scene" && find . -maxdepth 1 -type f)" == *"summary"* ]]; then exit 1 + else + if [[ "$(awk -F= '$1=="crashes" {print $2}' ${{ env.BUILD_DIR }}/tests_results/scene/summary.txt)" != '0' || "$(awk -F= '$1=="failures" {print $2}' ${{ env.BUILD_DIR }}/tests_results/scene/summary.txt)" != "0" ]]; then + exit 1 + fi fi - name: Regression tests @@ -367,15 +409,21 @@ jobs: docker run --rm \ --user 1000:1000 --network=host -v $WORKSPACE:/workspace \ ${DOCKER_IMAGE} \ - /bin/bash -c "env ; cd /workspace; /bin/bash $DOCKER_CI_DIR/scripts/test.sh $DOCKER_BUILD_DIR $DOCKER_SRC_DIR $DOCKER_CI_DIR/scripts/ ${NODE_NAME} ${{ inputs.python-version }} REGRESSION" + /bin/bash -c "export REGRESSION_DIR="$DOCKER_REGRESSION_DIR"; cd /workspace;. ${DOCKER_CI_DIR}/scripts/tests/setup-test-env.sh \"${DOCKER_BUILD_DIR}\" \"${DOCKER_CI_DIR}/scripts/\" \"${NODE_NAME}\" \"${{ inputs.python-version }}\"; env ; \${VM_PYTHON3_EXECUTABLE} ${DOCKER_REGRESSION_DIR}/SofaRegressionProgram/SofaRegressionProgram.py --input "${DOCKER_SRC_DIR}/examples" --input "${DOCKER_SRC_DIR}/applications" --input "${DOCKER_BUILD_DIR}/external_directories/fetched" --output-logs-errors "\${RESULTS_DIR}/regression" --jobs \${VM_MAX_PARALLEL_TESTS} " else echo "Launching regression test suite" - bash ${CI_DIR}/scripts/test.sh "${BUILD_DIR}" "${SRC_DIR}" "${CI_DIR}/scripts/" "${NODE_NAME}" "${{ inputs.python-version }}" "REGRESSION" + . ${CI_DIR}/scripts/tests/setup-test-env.sh "${BUILD_DIR}" "${CI_DIR}/scripts/" "${NODE_NAME}" "${{ inputs.python-version }}" + env + ${VM_PYTHON3_EXECUTABLE} ${REGRESSION_DIR}/SofaRegressionProgram/SofaRegressionProgram.py --input "${SRC_DIR}/examples" --input "${SRC_DIR}/applications" --input "${BUILD_DIR}/external_directories/fetched" --output-logs-errors "${RESULTS_DIR}/regression" -j ${VM_MAX_PARALLEL_TESTS} fi - if [[ "$(cd "${{ env.BUILD_DIR }}/tests_results/" && find . -maxdepth 1 -type f)" == *"regression-tests_"* ]]; then - exit 1 + if [[ ! "$(cd "${{ env.BUILD_DIR }}/tests_results/regression" && find . -maxdepth 1 -type f)" == *"summary"* ]]; then + exit 1 + else + if [[ "$(awk -F= '$1=="crashes" {print $2}' ${{ env.BUILD_DIR }}/tests_results/regression/summary.txt)" != '0' || "$(awk -F= '$1=="failures" {print $2}' ${{ env.BUILD_DIR }}/tests_results/regression/summary.txt)" != "0" ]]; then + exit 1 + fi fi @@ -432,10 +480,12 @@ jobs: fi if [[ "${{ inputs.generate-binaries }}" == "false" ]]; then - if [[ "$(cd "${{ env.BUILD_DIR }}/tests_results/" && find . -maxdepth 1 -type f)" != "" ]]; then + if [[ "${{ steps.unit-tests-step.outcome }}" == "failure" || "${{ steps.scene-tests-step.outcome }}" == "failure" || "${{ steps.regression-tests-step.outcome }}" == "failure" ]] && + [[ -f "${{ env.SOFA_BUILD_DIR }}/tests_results/unit/summary.txt" ]] && + [[ "${{ inputs.with-all-tests }}" == "false" || "${{ inputs.with-all-tests }}" == "true" && ( -f "${{ env.SOFA_BUILD_DIR }}/tests_results/scene/summary.txt" && -f "${{ env.SOFA_BUILD_DIR }}/tests_results/regression/summary.txt" ) ]]; then echo "❌ Tests have resulted in : " echo "" - python3 ${{ env.CI_DIR }}/scripts/generate-tests-table.py "${{ env.BUILD_DIR }}/tests_results/" + python3 ${{ env.CI_DIR }}/scripts/tests/generate-tests-table.py "${{ env.SOFA_BUILD_DIR }}/tests_results/" echo "" echo "#----------------------------------------#" echo "#---------------Quick Logs---------------#" @@ -444,12 +494,12 @@ jobs: do for errorType in 'errors' 'crashes' 'failures'; do - if [ -f "${{ env.BUILD_DIR }}/tests_results/${testType}-tests_${errorType}" ]; then + if [ -f "${{ env.SOFA_BUILD_DIR }}/tests_results/${testType}/${testType}_${errorType}.txt" ]; then capitalized="$(echo "${testType:0:1}" | tr '[:lower:]' '[:upper:]')${testType:1}" echo "" echo -e "${bold}${capitalized} ${errorType}:${normal}" echo "" - cat "${{ env.BUILD_DIR }}/tests_results/${testType}-tests_${errorType}" + cat "${{ env.SOFA_BUILD_DIR }}/tests_results/${testType}/${testType}_${errorType}.txt" echo "" echo "#----------------------------------------#" fi @@ -458,13 +508,13 @@ jobs: echo -e "${bold}You can download all logs here : ${{ steps.publish-tests-logs.outputs.artifact-url }}${normal}" exit 1 elif [[ "${{ steps.unit-tests-step.outcome }}" == "failure" || "${{ steps.scene-tests-step.outcome }}" == "failure" || "${{ steps.regression-tests-step.outcome }}" == "failure" ]]; then - echo "❌ Something whent wrong during one of the tests steps" + echo "❌ Something went wrong during one of the tests steps" echo -e "${bold}Please check this action logs, and download tests logs here: ${{ steps.publish-tests-logs.outputs.artifact-url }}${normal}" exit 1 else - echo "✅ Tests where successful : " + echo "✅ Tests were successful : " echo "" - python3 ${{ env.CI_DIR }}/scripts/generate-tests-table.py "${{ env.BUILD_DIR }}/tests_results/" + python3 ${{ env.CI_DIR }}/scripts/tests/generate-tests-table.py "${{ env.SOFA_BUILD_DIR }}/tests_results/" echo "" fi fi diff --git a/.github/workflows/CI_macos_linux_windows_pixi.yml b/.github/workflows/CI_macos_linux_windows_pixi.yml index 334185561cf..17790c480c7 100644 --- a/.github/workflows/CI_macos_linux_windows_pixi.yml +++ b/.github/workflows/CI_macos_linux_windows_pixi.yml @@ -379,7 +379,6 @@ jobs: --input "$env:SRC_DIR\applications" ` --input "$env:BUILD_DIR\external_directories\fetched" ` --output-logs-errors "$RegResultsDir" ` - --legacy-regression ` -j $env:VM_MAX_PARALLEL_TESTS if (-not (Test-Path "$RegResultsDir\*summary*")) { exit 1 } diff --git a/.github/workflows/CI_trigger_build_and_tests.yml b/.github/workflows/CI_trigger_build_and_tests.yml index 16c977241a7..f7d76e94585 100644 --- a/.github/workflows/CI_trigger_build_and_tests.yml +++ b/.github/workflows/CI_trigger_build_and_tests.yml @@ -224,8 +224,8 @@ jobs: # Trigger the build and sharing all parameters from filter_build > outputs build-on: needs: filter_build - if: ${{ github.repository_owner == 'sofa-framework' && needs.filter_build.outputs.SH_BUILDER_OS != '[]' }} - uses: sofa-framework/sofa/.github/workflows/CI_build_and_test.yml@master + if: ${{ github.repository_owner == 'sofa-framework' }} + uses: bakpaul/sofa/.github/workflows/CI_build_and_test.yml@26_09_use_python_based_ci_script_on_unix_ci with: sofa-branch-name: ${{ needs.filter_build.outputs.SOFA_BRANCH_NAME }} sofa-commit-sha: ${{ needs.filter_build.outputs.SOFA_COMMIT_SHA }}