Skip to content

Commit e1a1ef9

Browse files
committed
Allow running test script with or without coverage
1 parent d6e22ae commit e1a1ef9

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@ jobs:
9797
pip install -e ".[validation]"
9898
9999
- name: Execute test suite
100-
# --fail-under=0 ensures we publish the coverage regardless of whether it meets
101-
# the minimum so we can use Codecov to evaluate gaps
102-
run: |
103-
coverage run --source=pystac/ -m unittest discover tests/
104-
coverage xml --fail-under=0
100+
run: ./scripts/test
101+
env:
102+
CHECK_COVERAGE: true
103+
104+
- name: Prepare ./coverage.xml
105+
# Ignore the configured fail-under to ensure we upload the coverage report. We
106+
# will trigger a failure for coverage drops in a later job
107+
run: coverage xml --fail-under 0
105108

106109
- name: Upload All coverage to Codecov
107110
uses: codecov/codecov-action@v1
@@ -111,6 +114,11 @@ jobs:
111114
file: ./coverage.xml
112115
fail_ci_if_error: false
113116

117+
- name: Check for coverage drop
118+
# This will use the configured fail-under, causing this job to fail if the
119+
# coverage drops.
120+
run: coverage report
121+
114122
lint:
115123
runs-on: ubuntu-latest
116124
strategy:

scripts/test

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ set -e
55
if [[ -z ${CI} ]]; then
66
pre-commit run --all-files
77
fi
8-
9-
echo
10-
echo " -- RUNNING UNIT TESTS --"
118
echo
129

13-
# Test suite with coverage enabled
14-
coverage run -m unittest discover tests
15-
coverage xml
10+
if [[ -z ${CI} || -n ${CHECK_COVERAGE} ]]; then
11+
echo " -- RUNNING UNIT TESTS (WITH COVERAGE) --"
12+
# Test suite with coverage enabled
13+
coverage run -m unittest discover tests
14+
else
15+
echo " -- RUNNING UNIT TESTS (WITHOUT COVERAGE) --"
16+
python -m unittest discover tests
17+
fi
18+
19+
echo

0 commit comments

Comments
 (0)