Skip to content

Commit 78ad0a2

Browse files
committed
workflow: use codecov-action v2
The bash uploader is deprecated and the v1 version of the action will stop working on February 1, 2022. Unfortunately the new uploader does not accept python coverage data directly but requires a XML report.
1 parent e100699 commit 78ad0a2

File tree

2 files changed

+46
-37
lines changed

2 files changed

+46
-37
lines changed

.github/workflows/workflow.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
pip install PyYAML codecov schema python-magic pyparsing sphinx wheel
25+
pip install PyYAML coverage schema python-magic pyparsing sphinx wheel
2626
sudo apt-get update
2727
sudo apt-get install cvs
2828
2929
- name: Run unit tests
3030
run: |
3131
git config --global init.defaultBranch master # keep the old name
32-
eatmydata ./test/run-tests.sh
32+
eatmydata ./test/run-tests.sh -c xml
3333
3434
- name: Build Python package
3535
run: |
@@ -38,7 +38,7 @@ jobs:
3838
- name: Upload coverage to Codecov
3939
# Coverage is not complete on Python <3.7 (see pym/bob/utils.py)
4040
if: matrix.python-version != '3.6'
41-
uses: codecov/codecov-action@v1
41+
uses: codecov/codecov-action@v2
4242

4343
- name: Publish package
4444
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

test/run-tests.sh

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ usage: ${0##*/} [-h] [-b PATTERN] [-c] [-j JOBS] [-n] [-u PATTERN]
1010
optional arguments:
1111
-h show this help message and exit
1212
-b PATTERN Only execute black box tests matching PATTERN
13-
-c Create HTML coverage report
13+
-c TYPE Create coverage report (html, xml)
1414
-j JOBS Run JOBS tests in parallel (requires GNU parallel)
15-
-n Do not record coverage even if python3-coverage is found.
1615
-u PATTERN Only execute unit tests matching PATTERN
1716
EOF
1817
}
@@ -83,7 +82,6 @@ cd "${0%/*}/.."
8382
COVERAGE=
8483
FAILED=0
8584
RUN_TEST_DIRS=( )
86-
GEN_HTML=0
8785
RUN_JOBS=
8886
unset RUN_UNITTEST_PAT
8987
unset RUN_BLACKBOX_PAT
@@ -98,31 +96,8 @@ if [[ $(python3 --version) = "Python 3.9.7" ]] ; then
9896
PYTHONWARNINGS+=",ignore::DeprecationWarning"
9997
fi
10098

101-
# check if python coverage is installed
102-
if type -fp coverage3 >/dev/null; then
103-
COVERAGE=coverage3
104-
elif type -fp python3-coverage >/dev/null; then
105-
COVERAGE=python3-coverage
106-
fi
107-
108-
if [[ -n $COVERAGE ]] ; then
109-
# make sure coverage is installed in the current environment
110-
if python3 -c "import coverage" 2>/dev/null; then
111-
RUN_PYTHON3="$COVERAGE run --source $PWD/pym --parallel-mode"
112-
# The multiprocessing module is incompatible with coverage.py. Enable
113-
# the hack in pym/bob/utils.py to still get some data.
114-
export ENABLE_COVERAGE_HACK=1
115-
else
116-
RUN_PYTHON3=python3
117-
COVERAGE=
118-
echo "coverage3 is installed but not in the current environment" >&2
119-
fi
120-
else
121-
RUN_PYTHON3=python3
122-
fi
123-
12499
# option processing
125-
while getopts ":hb:cj:nu:" opt; do
100+
while getopts ":hb:c:j:u:" opt; do
126101
case $opt in
127102
h)
128103
usage
@@ -132,7 +107,15 @@ while getopts ":hb:cj:nu:" opt; do
132107
RUN_BLACKBOX_PAT="$OPTARG"
133108
;;
134109
c)
135-
GEN_HTML=1
110+
case "$OPTARG" in
111+
html|xml)
112+
COVERAGE="$OPTARG"
113+
;;
114+
*)
115+
echo "Invalid coverage format" >&2
116+
exit 1
117+
;;
118+
esac
136119
;;
137120
j)
138121
RUN_JOBS="$OPTARG"
@@ -151,6 +134,34 @@ while getopts ":hb:cj:nu:" opt; do
151134
esac
152135
done
153136

137+
# check if python coverage is installed if coverage is required
138+
if [[ -z $COVERAGE ]] ; then
139+
:
140+
elif type -fp coverage3 >/dev/null; then
141+
RUN_COVERAGE=coverage3
142+
elif type -fp python3-coverage >/dev/null; then
143+
RUN_COVERAGE=python3-coverage
144+
else
145+
echo "Coverage requeted but coverage3 is not installed" >&2
146+
echo "Try 'python3 -m pip install coverage'..." >&2
147+
exit 1
148+
fi
149+
150+
if [[ -n $RUN_COVERAGE ]] ; then
151+
# make sure coverage is installed in the current environment
152+
if python3 -c "import coverage" 2>/dev/null; then
153+
RUN_PYTHON3="$RUN_COVERAGE run --source $PWD/pym --parallel-mode"
154+
# The multiprocessing module is incompatible with coverage.py. Enable
155+
# the hack in pym/bob/utils.py to still get some data.
156+
export ENABLE_COVERAGE_HACK=1
157+
else
158+
echo "coverage3 is installed but not usable!" >&2
159+
exit 1
160+
fi
161+
else
162+
RUN_PYTHON3=python3
163+
fi
164+
154165
# execute everything if nothing was specified
155166
if [[ -z ${RUN_UNITTEST_PAT+isset} && -z ${RUN_BLACKBOX_PAT+isset} ]] ; then
156167
RUN_BLACKBOX_PAT='*'
@@ -230,12 +241,10 @@ fi
230241
popd > /dev/null
231242

232243
# collect coverage
233-
if [[ -n $COVERAGE ]]; then
234-
$COVERAGE combine $(find test/ -type f -name '.coverage.*' \
235-
-printf '%h\n' | sort -u)
236-
if [[ $GEN_HTML -eq 1 ]] ; then
237-
$COVERAGE html
238-
fi
244+
if [[ -n $RUN_COVERAGE ]]; then
245+
$RUN_COVERAGE combine $(find test/ -type f -name '.coverage.*' \
246+
-printf '%h\n' | sort -u)
247+
$RUN_COVERAGE $COVERAGE
239248
fi
240249

241250
if [[ $FAILED -gt 127 ]] ; then

0 commit comments

Comments
 (0)