Skip to content

Commit e2567a6

Browse files
committed
scripts: improve upload-coverage.sh
Mostly, verify the bash uploader hash and make it more strict and verbose.
1 parent b8f1b7c commit e2567a6

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

scripts/upload-coverage.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
#!/usr/bin/env bash
22

3-
set -e
3+
set -euo pipefail
44
set -x
55

6-
if [ -z "$TOXENV" ]; then
6+
# Install coverage.
7+
if [[ -z ${TOXENV+x} || -z $TOXENV ]]; then
78
python -m pip install coverage
89
else
910
# Add last TOXENV to $PATH.
1011
PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH"
1112
fi
1213

14+
# Run coverage.
1315
python -m coverage xml
16+
17+
# Download and verify latest Codecov bash uploader.
1418
# Set --connect-timeout to work around https://github.com/curl/curl/issues/4461
15-
curl -S -L --connect-timeout 5 --retry 6 -s https://codecov.io/bash -o codecov-upload.sh
16-
bash codecov-upload.sh -Z -X fix -f coverage.xml "$@"
19+
curl --silent --show-error --location --connect-timeout 5 --retry 6 -o codecov https://codecov.io/bash
20+
VERSION=$(grep --only-matching 'VERSION=\"[0-9\.]*\"' codecov | cut -d'"' -f2)
21+
if command -v sha256sum; then
22+
sha256sum --check --strict --ignore-missing --quiet <(curl --silent "https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA256SUM")
23+
else
24+
shasum --algorithm 256 --check --strict --ignore-missing --quiet <(curl --silent "https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA256SUM")
25+
fi
26+
27+
# Upload coverage.
28+
bash codecov -Z -X fix -f coverage.xml "$@"

0 commit comments

Comments
 (0)