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
This commit is contained in:
Daniel Hahler 2019-06-25 15:35:33 +02:00 committed by GitHub
parent 027ebb23da
commit e13ae7cae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 14 deletions

View File

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

41
ci/common/submit_coverage.sh Executable file
View File

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

View File

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

View File

@ -24,12 +24,4 @@ coverage:
only_pulls: true
changes: no
parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no
comment: off