diff --git a/.github/workflows/long-tests.yml b/.github/workflows/long-tests.yml index 5ae5ae4eb..06b8907eb 100644 --- a/.github/workflows/long-tests.yml +++ b/.github/workflows/long-tests.yml @@ -26,3 +26,5 @@ jobs: cmake_build_type: RelWithAssert add_cmake_cfg_args: -D LONG_TESTS=ON branch_name: ${{github.event.inputs.branch}} + code_coverage: true + secrets: inherit diff --git a/.github/workflows/main-job.yml b/.github/workflows/main-job.yml index 800578b08..1d6588c70 100644 --- a/.github/workflows/main-job.yml +++ b/.github/workflows/main-job.yml @@ -17,6 +17,12 @@ on: required: false type: string + code_coverage: + description: 'Code coverage' + required: false + default: true + type: boolean + # job jobs: ci: @@ -141,6 +147,24 @@ jobs: int: int64_t steps: + - name: Set cmake_build_type and export coverage flags + run: | + if ${{ matrix.os == 'ubuntu-20.04' && inputs.code_coverage == true }}; then + # if code coverage is enabled, linux build is runned in Debug mode + + if [[ ${{ inputs.cmake_build_type }} != Debug ]]; then + echo "WARNING: build type is forced to debug mode on ubuntu to allow coverage." + fi + + echo "BUILD_TYPE=Debug" >> "$GITHUB_ENV" + echo "C_FLG_PROF=-fprofile-arcs -ftest-coverage" >> "$GITHUB_ENV" + + else + echo "BUILD_TYPE=${{ inputs.cmake_build_type }}" >> "$GITHUB_ENV" + fi + + shell: bash + - name: Print options and set environment variables run: | echo "${{ github.event.inputs.name }}: @@ -149,7 +173,7 @@ jobs: Scotch: ${{ matrix.scotch }}, VTK: ${{ matrix.vtk }}, int: ${{ matrix.int }}, - Build: ${{ inputs.cmake_build_type }}" + Build: ${{ env.BUILD_TYPE }}" # gfortran compiler and scotch makefile depends on the os if [ "$RUNNER_OS" == "macOS" ]; then @@ -170,9 +194,14 @@ jobs: - name: Set environment variables for output comparison if: "! contains(github.event.head_commit.message, '[skip output comparison]')" run: | - echo "C_FLG=\"-DCMAKE_C_FLAGS=-DMMG_COMPARABLE_OUTPUT\"" >> "$GITHUB_ENV" + echo "C_FLG=-DMMG_COMPARABLE_OUTPUT" >> "$GITHUB_ENV" echo "MMG_ERROR_RULE=\"COMMAND_ERROR_IS_FATAL ANY\"" >> "$GITHUB_ENV" + - name: Assign CMAKE_C_FLAGS if needed + if: ${{ env.C_FLG || env.C_FLG_PROF }} + run: | + echo "CMAKE_C_FLG=-DCMAKE_C_FLAGS=\"${{ env.C_FLG }} ${{ env.C_FLG_PROF }}\"" >> "$GITHUB_ENV" + - name: Install VTK # Download vtk only if used if: matrix.vtk == 'on' @@ -235,11 +264,12 @@ jobs: - name: Test compilation with shared libs linkage run: | cmake -Smmg -Bbuild_shared \ - ${{ env.C_FLG }} \ + ${{ env.CMAKE_C_FLG }} \ ${{ env.FORT_FLG }} \ -DCI_CONTEXT=ON \ -DBUILD_TESTING=ON \ - -DCMAKE_BUILD_TYPE=${{ inputs.cmake_build_type }} \ + -DUSE_POINTMAP=${{ matrix.pointmap }} \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ -DMMG_PATTERN=${{ matrix.pattern }} \ -DUSE_SCOTCH=${{ matrix.scotch }} \ -DSCOTCH_DIR=scotch-install \ @@ -251,17 +281,18 @@ jobs: -DTEST_LIBMMG2D=ON \ -DTEST_LIBMMG3D=ON \ ${{ inputs.add_cmake_cfg_args }} - cmake --build build_shared --config ${{ inputs.cmake_build_type }} -j ${{ env.NJOBS }} + cmake --build build_shared --config ${{ env.BUILD_TYPE }} -j ${{ env.NJOBS }} shell: bash - name: Test compilation without library linkage run: | cmake -Smmg -Bbuild_nolibs \ - ${{ env.C_FLG }} \ + ${{ env.CMAKE_C_FLG }} \ ${{ env.FORT_FLG }} \ -DCI_CONTEXT=ON \ -DBUILD_TESTING=ON \ - -DCMAKE_BUILD_TYPE=${{ inputs.cmake_build_type }} \ + -DUSE_POINTMAP=${{ matrix.pointmap }} \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ -DMMG_PATTERN=${{ matrix.pattern }} \ -DUSE_SCOTCH=${{ matrix.scotch }} \ -DSCOTCH_DIR=scotch-install \ @@ -272,18 +303,19 @@ jobs: -DLIBMMG2D_STATIC=OFF \ -DLIBMMG3D_STATIC=OFF \ ${{ inputs.add_cmake_cfg_args }} - cmake --build build_nolibs --config ${{ inputs.cmake_build_type }} -j ${{ env.NJOBS }} + cmake --build build_nolibs --config ${{ env.BUILD_TYPE }} -j ${{ env.NJOBS }} shell: bash - name: Configure Mmg with static libs (default behaviour) run: | cmake -Smmg -Bbuild \ - ${{ env.C_FLG }} \ + ${{ env.CMAKE_C_FLG }} \ ${{ env.FORT_FLG }} \ -DCMAKE_INSTALL_PREFIX=mmg-install \ -DCI_CONTEXT=ON \ -DBUILD_TESTING=ON \ - -DCMAKE_BUILD_TYPE=${{ inputs.cmake_build_type }} \ + -DUSE_POINTMAP=${{ matrix.pointmap }} \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ -DMMG_PATTERN=${{ matrix.pattern }} \ -DUSE_SCOTCH=${{ matrix.scotch }} \ -DSCOTCH_DIR=scotch-install \ @@ -298,10 +330,10 @@ jobs: - name: Build Mmg run: | - cmake --build build --config ${{ inputs.cmake_build_type }} -j ${{ env.NJOBS }} + cmake --build build --config ${{ env.BUILD_TYPE }} -j ${{ env.NJOBS }} - name: Install Mmg run: | - cmake --build build --target install --config ${{ inputs.cmake_build_type }} -j ${{ env.NJOBS }} + cmake --build build --target install --config ${{ env.BUILD_TYPE }} -j ${{ env.NJOBS }} - name: Archive production artifacts uses: actions/upload-artifact@v4 @@ -315,25 +347,35 @@ jobs: if: matrix.vtk == 'off' && matrix.int == 'int32_t' run: | cd build - ctest --timeout 7200 -VV -C ${{ inputs.cmake_build_type }} -j ${{ env.NJOBS }} + ctest --timeout 7200 -VV -C ${{ env.BUILD_TYPE }} -j ${{ env.NJOBS }} - name: Test Mmg with in64_t integers # Run long tests only on ubuntu with pattern off, scotch on, vtk on and int64_t integers if: matrix.os == 'ubuntu-20.04' && matrix.pattern == 'off' && matrix.scotch == 'on' && matrix.vtk == 'on' && matrix.int == 'int64_t' run: | cd build - ctest --timeout 7200 -VV -C ${{ inputs.cmake_build_type }} -j ${{ env.NJOBS }} + ctest --timeout 7200 -VV -C ${{ env.BUILD_TYPE }} -j ${{ env.NJOBS }} - name: Test non native I/Os of Mmg if: matrix.vtk == 'on' run: | cd build - ctest -R "msh|vtk" -VV -C ${{ inputs.cmake_build_type }} -j ${{ env.NJOBS }} - - # - name: Archive production artifacts for tests - # if: success() || failure() - # uses: actions/upload-artifact@v2 - # with: - # name: Mmg-tests - # path: | - # build/TEST_OUTPUTS + ctest -R "msh|vtk" -VV -C ${{ env.BUILD_TYPE }} -j ${{ env.NJOBS }} + + - name: Archive production artifacts for tests + if: success() || failure() + uses: actions/upload-artifact@v4 + with: + name: Mmg-tests-${{ matrix.os }}-${{ matrix.pattern }}-${{ matrix.pointmap }}-${{ matrix.scotch }}-${{ matrix.vtk }}-${{ matrix.int }} + path: | + build/TEST_OUTPUTS + + - name: Upload coverage to Codecov + if: matrix.os == 'ubuntu-20.04' && inputs.code_coverage == true + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + root_dir: . + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}