Replaced Codecov with Coveralls.

This commit is contained in:
binary1248 2024-04-10 21:37:45 +02:00 committed by Chris Thrasher
parent 6eaf300918
commit 90fb07066b
3 changed files with 36 additions and 50 deletions

40
.github/.codecov.yml vendored
View File

@ -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

View File

@ -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

View File

@ -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 $<CONFIG>
POST_BUILD
COMMAND ${COVERAGE_PREFIX} ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>
COMMAND ${CMAKE_COMMAND} -P "${PROJECT_BINARY_DIR}/patch_coverage.cmake"
VERBATIM)