4
4
pull_request :
5
5
paths :
6
6
- ' .github/workflows/test-python.yml'
7
+ - ' action-setup.sh'
7
8
- ' compilesketches/**'
8
9
9
10
push :
10
11
paths :
11
12
- ' .github/workflows/test-python.yml'
13
+ - ' action-setup.sh'
12
14
- ' compilesketches/**'
13
15
14
- # The actions/setup-python action will periodically break the workflow by dropping the Python version we have pinned
15
- # Better to catch that before it causes confusion for a contributor
16
+ # Catch issues resulting from new patch releases of Python in the APT repository
16
17
schedule :
17
18
# run every Tuesday at 3 AM UTC
18
19
- cron : " 0 3 * * 2"
@@ -32,29 +33,52 @@ jobs:
32
33
env :
33
34
PYTHON_PROJECT_PATH : ${GITHUB_WORKSPACE}/compilesketches
34
35
PYTHON_PROJECT_TESTS_PATH : ${GITHUB_WORKSPACE}/compilesketches/tests
36
+ COVERAGE_DATA_FILENAME : coverage.xml
35
37
36
38
steps :
37
39
- name : Checkout
38
40
uses : actions/checkout@v2
39
41
40
- - name : Set up Python
41
- uses : actions/ setup-python@v1
42
- with :
43
- python-version : ' 3.8.6 '
42
+ - name : Run the set up script
43
+ id : setup
44
+ run : |
45
+ "${{ github.workspace }}/action-setup.sh"
44
46
45
- - name : Install dependencies
47
+ - name : Install test dependencies
46
48
run : |
47
- python -m pip install --upgrade pip
48
- pip install --requirement "${{ env.PYTHON_PROJECT_TESTS_PATH }}/requirements.txt"
49
+ source "${{ steps.setup.outputs.python-venv-activate-script-path }}"
50
+ "${{ steps.setup.outputs.python-command }}" \
51
+ -m \
52
+ pip install \
53
+ --requirement "${{ env.PYTHON_PROJECT_TESTS_PATH }}/requirements.txt"
49
54
50
- - name : Run Python unit tests and report code coverage
55
+ - name : Run Python unit tests and record code coverage data
51
56
run : |
57
+ source "${{ steps.setup.outputs.python-venv-activate-script-path }}"
52
58
export PYTHONPATH="${{ env.PYTHON_PROJECT_PATH }}"
53
- coverage run --source="${{ env.PYTHON_PROJECT_PATH }}" --module pytest "${{ env.PYTHON_PROJECT_TESTS_PATH }}"
54
- # Display code coverage report in workflow run log
55
- coverage report
59
+ "${{ steps.setup.outputs.python-command }}" \
60
+ -m \
61
+ coverage run \
62
+ --rcfile="${{ env.PYTHON_PROJECT_TESTS_PATH }}/.coveragerc" \
63
+ --source="${{ env.PYTHON_PROJECT_PATH }}" \
64
+ --module \
65
+ pytest "${{ env.PYTHON_PROJECT_TESTS_PATH }}"
66
+ # Generate coverage data file for consumption by `codecov/codecov-action`.
67
+ # Otherwise that action generates the file using the system Python environment, which doesn't work.
68
+ "${{ steps.setup.outputs.python-command }}" \
69
+ -m \
70
+ coverage xml \
71
+ -o "${{ github.workspace }}/${{ env.COVERAGE_DATA_FILENAME }}"
72
+
73
+ - name : Display code coverage report
74
+ run : |
75
+ source "${{ steps.setup.outputs.python-venv-activate-script-path }}"
76
+ "${{ steps.setup.outputs.python-command }}" \
77
+ -m \
78
+ coverage report
56
79
57
80
- name : Upload coverage report to Codecov
58
81
uses : codecov/codecov-action@v1
59
82
with :
83
+ file : ${{ env.COVERAGE_DATA_FILENAME }}
60
84
fail_ci_if_error : true
0 commit comments