-
Notifications
You must be signed in to change notification settings - Fork 0
/
codecov.sh
75 lines (60 loc) · 1.79 KB
/
codecov.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
set -euox pipefail
# Uploads coverage reports to CodeCov
# Check whether this script was called on it's own
if [[ "${CURL_USER_AGENT:-}" == "" ]]
then
CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$CI_DIR/../.azure-pipelines/lib.sh"
fi
# CodeCov gets confused by lst files which it can't match
rm -rf test/runnable/extra-files \
test/*.lst \
./*test_results-runner.lst \
__main.lst
# Save the file from URL passed as $1 to the location in $2
doCurl()
{
curl -fsSL -A "$CURL_USER_AGENT" --connect-timeout 5 --speed-time 30 --speed-limit 1024 --retry 5 --retry-delay 5 "$1" -o "$2"
}
# Determine the correct uploader + url + arguments
UPLOADER="codecov"
UPLOADER_OS="$OS_NAME"
UPLOADER_ARGS=""
case "$UPLOADER_OS" in
windows)
UPLOADER="$UPLOADER.exe"
;;
darwin | osx)
UPLOADER_OS="macos"
;;
# No FreeBSD support for the new uploader (yet?)
freebsd)
doCurl "https://codecov.io/bash" "codecov.sh"
bash ./codecov.sh -p . -Z
rm codecov.sh
return 0
;;
esac
# Determine the host name
for file in "$UPLOADER" "$UPLOADER.SHA256SUM" "$UPLOADER.SHA256SUM.sig"
do
doCurl "https://uploader.codecov.io/latest/$UPLOADER_OS/$file" "$file"
done
# Obtain the key if missing
if ! gpg --list-keys ED779869
then
echo "Importing CodeCov key..."
doCurl "https://keybase.io/codecovsecurity/pgp_keys.asc" "pgp_keys.asc"
gpg --import pgp_keys.asc
rm pgp_keys.asc
fi
# Verify the uploader
gpg --verify "$UPLOADER.SHA256SUM.sig" "$UPLOADER.SHA256SUM"
shasum -a 256 -c "$UPLOADER.SHA256SUM"
# Remove signature files as the uploader apparently includes them...
rm $UPLOADER.*
# Upload the sources
chmod +x "$UPLOADER"
"./$UPLOADER" -p . -Z $UPLOADER_ARGS
rm "$UPLOADER"