Skip to content

Commit bca2a76

Browse files
tjtgLaurenceBeard
authored andcommitted
Fix codacy coverage and report combined unit/acceptance coverage (#1033)
* Fix codacy coverage reporting bin/improver uses lib as the working directory, so the previous coverage path was wrong. * Report combined unit and acceptance test coverage
1 parent d0f2625 commit bca2a76

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ python:
88
os: linux
99
git:
1010
depth: 10000
11+
env:
12+
- CI_COVERAGE=yes
1113

1214
install:
1315
# Install miniconda

bin/improver-tests

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,9 @@ function improver_test_unit {
148148
if [[ -n $DEBUG_OPT ]]; then
149149
VERBOSE_OPT='-v'
150150
fi
151-
if [[ -n "${CODACY_PROJECT_TOKEN:-}" || -n "${CODECOV_TOKEN:-}" ]]; then
152-
pytest -m 'not acc' --cov=lib/improver --cov-report xml:coverage.xml ${VERBOSE_OPT:-}
153-
if [[ -n "${CODACY_PROJECT_TOKEN:-}" ]]; then
154-
# Report coverage to Codacy if possible.
155-
python-codacy-coverage -r coverage.xml
156-
fi
157-
if [[ -n "${CODECOV_TOKEN:-}" ]]; then
158-
# Report coverage to CodeCov if possible.
159-
codecov
160-
fi
151+
if [[ -n "${CI_COVERAGE:-}" ]]; then
152+
pytest -m 'not acc' --cov=improver \
153+
--cov-report xml:coverage.xml ${VERBOSE_OPT:-}
161154
else
162155
pytest -m 'not acc' ${VERBOSE_OPT:-}
163156
fi
@@ -176,8 +169,21 @@ function improver_test_cli {
176169
if [[ -n $DEBUG_OPT ]]; then
177170
VERBOSE_OPT='-v'
178171
fi
179-
180-
pytest -m acc ${VERBOSE_OPT:-}
172+
if [[ -n "${CI_COVERAGE:-}" ]]; then
173+
pytest -m acc --cov-append --cov=improver \
174+
--cov-report xml:coverage.xml \
175+
--cov-report term ${VERBOSE_OPT:-}
176+
if [[ -n "${CODACY_PROJECT_TOKEN:-}" ]]; then
177+
# Report coverage to Codacy if possible.
178+
python-codacy-coverage -v -r coverage.xml
179+
fi
180+
if [[ -n "${CODECOV_TOKEN:-}" ]]; then
181+
# Report coverage to CodeCov if possible.
182+
codecov
183+
fi
184+
else
185+
pytest -m acc ${VERBOSE_OPT:-}
186+
fi
181187

182188
echo_ok "CLI tests"
183189
}

0 commit comments

Comments
 (0)