Skip to content

Commit da74931

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 da74931

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

scripts/upload-coverage.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
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+
sha256sum --check --ignore-missing <(curl -s "https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA256SUM")
22+
23+
# Upload coverage.
24+
bash codecov -Z -X fix -f coverage.xml "$@"

0 commit comments

Comments
 (0)