From 90fb07066bc559d2af61e2a7d4d4086da5be7662 Mon Sep 17 00:00:00 2001 From: binary1248 Date: Wed, 10 Apr 2024 21:37:45 +0200 Subject: [PATCH] Replaced Codecov with Coveralls. --- .github/.codecov.yml | 40 ---------------------------------------- .github/workflows/ci.yml | 26 ++++++++++++++++++-------- test/CMakeLists.txt | 20 ++++++++++++++++++-- 3 files changed, 36 insertions(+), 50 deletions(-) delete mode 100644 .github/.codecov.yml diff --git a/.github/.codecov.yml b/.github/.codecov.yml deleted file mode 100644 index c9a9e0379..000000000 --- a/.github/.codecov.yml +++ /dev/null @@ -1,40 +0,0 @@ -codecov: - require_ci_to_pass: yes - -coverage: - precision: 2 - round: down - range: "70...100" - status: - project: - default: - target: auto - threshold: 100% - base: auto - if_ci_failed: success - informational: true - patch: - default: - target: auto - threshold: 100% - base: auto - if_ci_failed: success - informational: true - -parsers: - gcov: - branch_detection: - conditional: yes - loop: yes - method: no - macro: no - -comment: - layout: "reach,diff,flags,files,footer" - behavior: default - require_changes: no - require_head: no - require_base: no - -github_checks: - annotations: false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 112bbe53d..c7378f7ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,16 +205,15 @@ jobs: gcovr -r $GITHUB_WORKSPACE -x build/coverage.out -s -f 'src/SFML/.*' -f 'include/SFML/.*' ${{ matrix.platform.gcovr_options }} $GITHUB_WORKSPACE fi - - name: Upload Coverage Report to Codecov - uses: codecov/codecov-action@v4 + - name: Upload Coverage Report to Coveralls if: matrix.type.name == 'Debug' && github.repository == 'SFML/SFML' # Disable upload in forks + uses: coverallsapp/github-action@v2 with: - fail_ci_if_error: false - name: ${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }} - directory: ./build - files: ./build/coverage.out - token: ${{ secrets.CODECOV_TOKEN }} - verbose: true + file: ./build/coverage.out + flag-name: ${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }} + parallel: true + allow-empty: true + base-path: ${{ github.workspace }} - name: Test Install Interface if: matrix.platform.name != 'Android' @@ -222,6 +221,17 @@ jobs: cmake -S test/install -B test/install/build -DSFML_ROOT=build/install -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} ${{matrix.platform.flags}} ${{matrix.config.flags}} ${{matrix.type.flags}} cmake --build test/install/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} + coverage: + name: Finalize Coverage Upload + needs: build + runs-on: ubuntu-22.04 + + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true + format: name: Formatting runs-on: ubuntu-22.04 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a234cc322..2e119f2ef 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -180,12 +180,28 @@ if(SFML_ENABLE_COVERAGE AND OpenCppCoverage_FOUND) string(REPLACE "/" "\\" COVERAGE_SRC "${PROJECT_SOURCE_DIR}/src") string(REPLACE "/" "\\" COVERAGE_INCLUDE "${PROJECT_SOURCE_DIR}/include") - set(COVERAGE_PREFIX ${OpenCppCoverage_BINARY} ARGS --quiet --export_type cobertura:${PROJECT_BINARY_DIR}/coverage.out --cover_children --excluded_modules "${COVERAGE_EXCLUDE}" --sources "${COVERAGE_SRC}" --sources "${COVERAGE_INCLUDE}" --) + # We need to patch the OpenCppCoverage output to remove path prefixes so Coveralls doesn't get confused + cmake_path(GET PROJECT_SOURCE_DIR ROOT_NAME COVERAGE_ROOT_NAME) + string(REPLACE "/" "\\\\" COVERAGE_PATH_PREFIX "${PROJECT_SOURCE_DIR}/") + string(REPLACE "${COVERAGE_ROOT_NAME}\\\\" "" COVERAGE_PATH_PREFIX "${COVERAGE_PATH_PREFIX}") + + file(WRITE "${PROJECT_BINARY_DIR}/patch_coverage.cmake" + "file(READ \"${PROJECT_BINARY_DIR}/coverage.out\" COVERAGE_OUT)\n\ + string(REPLACE \"${COVERAGE_PATH_PREFIX}\" \"\" COVERAGE_OUT \"\${COVERAGE_OUT}\")\n\ + string(REPLACE \"${COVERAGE_ROOT_NAME}\" \".\" COVERAGE_OUT \"\${COVERAGE_OUT}\")\n\ + file(WRITE \"${PROJECT_BINARY_DIR}/coverage.out\" \"\${COVERAGE_OUT}\")\n") + + set(COVERAGE_PREFIX ${OpenCppCoverage_BINARY} --quiet --export_type cobertura:${PROJECT_BINARY_DIR}/coverage.out --cover_children --excluded_modules "${COVERAGE_EXCLUDE}" --sources "${COVERAGE_SRC}" --sources "${COVERAGE_INCLUDE}" --) +else() + # On all other systems, we just run an empty script + file(WRITE "${PROJECT_BINARY_DIR}/patch_coverage.cmake" "") endif() # Convenience for building and running tests in a single command add_custom_target(runtests DEPENDS test-sfml-system test-sfml-window test-sfml-graphics test-sfml-network test-sfml-audio) add_custom_command(TARGET runtests COMMENT "Run tests" - POST_BUILD COMMAND ${COVERAGE_PREFIX} ${CMAKE_CTEST_COMMAND} --output-on-failure -C $ + POST_BUILD + COMMAND ${COVERAGE_PREFIX} ${CMAKE_CTEST_COMMAND} --output-on-failure -C $ + COMMAND ${CMAKE_COMMAND} -P "${PROJECT_BINARY_DIR}/patch_coverage.cmake" VERBATIM)