diff options
author | Daniel Hahler <git@thequod.de> | 2019-06-25 15:35:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-25 15:35:33 +0200 |
commit | e13ae7cae641bde5cd744378051d0a7f8b892d33 (patch) | |
tree | 0da2d898862cd6be4e2e35e6b2e5adfb7bd9fe29 | |
parent | 027ebb23da0868655413e1850eb0b7d77e223850 (diff) | |
download | rneovim-e13ae7cae641bde5cd744378051d0a7f8b892d33.tar.gz rneovim-e13ae7cae641bde5cd744378051d0a7f8b892d33.tar.bz2 rneovim-e13ae7cae641bde5cd744378051d0a7f8b892d33.zip |
ci: revisit/fix coverage uploading (#10201)
* Add ci/common/submit_coverage.sh, used with Travis and AppVeyor
* use gcovr, with coverage.xml for better branch coverage reporting, and
easier processing of gcov files in general
* codecov: use flags again, with `uname -s` additionally
Ref: https://github.com/neovim/neovim/pull/10227#issuecomment-502923543
* remove now unused parsers.gcov config from codecov.yml
-rw-r--r-- | ci/build.ps1 | 8 | ||||
-rwxr-xr-x | ci/common/submit_coverage.sh | 41 | ||||
-rw-r--r-- | ci/common/test.sh | 5 | ||||
-rw-r--r-- | codecov.yml | 8 |
4 files changed, 48 insertions, 14 deletions
diff --git a/ci/build.ps1 b/ci/build.ps1 index d3686e2914..c68b3fccb4 100644 --- a/ci/build.ps1 +++ b/ci/build.ps1 @@ -43,6 +43,7 @@ if ($compiler -eq 'MINGW') { if ($compileOption -eq 'gcov') { $nvimCmakeVars['USE_GCOV'] = 'ON' $uploadToCodecov = $true + $env:GCOV = "C:\msys64\mingw$bits\bin\gcov" } # These are native MinGW builds, but they use the toolchain inside # MSYS2, this allows using all the dependencies and tools available @@ -119,13 +120,16 @@ cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGenera foreach { $failed = $failed -or $_ -match 'functional tests failed with error'; $_ } if ($failed) { + if ($uploadToCodecov) { + bash -l /c/projects/neovim/ci/common/submit_coverage.sh functionaltest + } exit $LastExitCode } Set-PSDebug -Strict -Trace 1 if ($uploadToCodecov) { - C:\msys64\usr\bin\bash -lc "cd /c/projects/neovim; bash <(curl -s https://codecov.io/bash) -c || echo 'codecov upload failed.'" + bash -l /c/projects/neovim/ci/common/submit_coverage.sh functionaltest } # Old tests @@ -135,7 +139,7 @@ $env:PATH = "C:\msys64\usr\bin;$env:PATH" & "C:\msys64\mingw$bits\bin\mingw32-make.exe" -C $(Convert-Path ..\src\nvim\testdir) VERBOSE=1 if ($uploadToCodecov) { - C:\msys64\usr\bin\bash -lc "cd /c/projects/neovim; bash <(curl -s https://codecov.io/bash) -c || echo 'codecov upload failed.'" + bash -l /c/projects/neovim/ci/common/submit_coverage.sh oldtest } # Build artifacts diff --git a/ci/common/submit_coverage.sh b/ci/common/submit_coverage.sh new file mode 100755 index 0000000000..7c343268d1 --- /dev/null +++ b/ci/common/submit_coverage.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Collect and submit coverage reports. +# +# Args: +# $1: Flag(s) for codecov, separated by comma. + +set -ex + +# Change to grandparent dir (POSIXly). +CDPATH='' cd -P -- "$(dirname -- "$0")/../.." || exit + +echo "=== running submit_coverage in $PWD: $* ===" +"$GCOV" --version + +# Download/install codecov-bash and gcovr once. +codecov_sh="${TEMP:-/tmp}/codecov.bash" +if ! [ -f "$codecov_sh" ]; then + curl --retry 5 --silent --fail -o "$codecov_sh" https://codecov.io/bash + chmod +x "$codecov_sh" + + python3 -m pip install --quiet --user gcovr +fi + +python3 -m gcovr --branches --exclude-unreachable-branches --print-summary -j 2 --exclude '.*/auto/.*' --root build --delete -o coverage.xml --xml + +# Upload to codecov. +# -X gcov: disable gcov, done manually above. +# -Z: exit non-zero on failure +# -F: flag(s) +# NOTE: ignoring flags for now, since this causes timeouts on codecov.io then, +# which they know about for about a year already... +# Flags must match pattern ^[\w\,]+$ ("," as separator). +codecov_flags="$(uname -s),${1}" +codecov_flags=$(echo "$codecov_flags" | sed 's/[^,_a-zA-Z0-9]/_/g') +if ! "$codecov_sh" -f coverage.xml -X gcov -Z -F "${codecov_flags}"; then + echo "codecov upload failed." +fi + +# Cleanup always, especially collected data. +find . \( -name '*.gcov' -o -name '*.gcda' \) -ls -delete | wc -l +rm -f coverage.xml diff --git a/ci/common/test.sh b/ci/common/test.sh index 0912c3965f..e25af4d56c 100644 --- a/ci/common/test.sh +++ b/ci/common/test.sh @@ -3,10 +3,7 @@ submit_coverage() { if [ -n "${GCOV}" ]; then - if curl --fail --output codecov.bash --silent https://codecov.io/bash; then - bash codecov.bash -c || echo "codecov upload failed." - rm -f codecov.bash - fi + "${CI_DIR}/common/submit_coverage.sh" "$@" || echo 'codecov upload failed.' fi } diff --git a/codecov.yml b/codecov.yml index 5acc64f756..a83fd916ee 100644 --- a/codecov.yml +++ b/codecov.yml @@ -24,12 +24,4 @@ coverage: only_pulls: true changes: no -parsers: - gcov: - branch_detection: - conditional: yes - loop: yes - method: no - macro: no - comment: off |