-
-
Notifications
You must be signed in to change notification settings - Fork 425
182 lines (162 loc) · 6.45 KB
/
pytest.yml
File metadata and controls
182 lines (162 loc) · 6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
name: pytest
on:
push:
branches:
- main
- releasebranch_*
pull_request:
permissions: {}
jobs:
pytest:
concurrency:
group: >-
${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}-${{
matrix.os }}-${{ matrix.python-version }}
cancel-in-progress: true
strategy:
matrix:
os:
- ubuntu-24.04
python-version:
- "3.10"
- "3.13"
fail-fast: true
runs-on: ${{ matrix.os }}
env:
FORCE_COLOR: 1 # for software including pip: https://force-color.org/
CLICOLOR_FORCE: 1 # for other software including ninja: https://bixense.com/clicolors/
PYTHONWARNINGS: always
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
cache: pip # zizmor: ignore[cache-poisoning] This pytest workflow not used for release artifacts
allow-prereleases: true
- name: Install non-Python dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y wget git gawk findutils
LC_ALL=C.UTF-8 sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update -y
xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \
sudo apt-get install -y --no-install-recommends --no-install-suggests
- uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install --break-system-packages -r .github/workflows/python_requirements.txt
pip install --break-system-packages -r .github/workflows/optional_requirements.txt
pip install --break-system-packages pytest pytest-timeout \
pytest-github-actions-annotate-failures pytest-xdist pytest-cov
- name: Create installation directory
run: |
mkdir "${HOME}/install"
- name: Set number of cores for compilation
run: |
echo "MAKEFLAGS=-j$(nproc)" >> "${GITHUB_ENV}"
- name: Build
run: |
".github/workflows/build_${MATRIX_OS}.sh" "${HOME}/install"
env:
MATRIX_OS: ${{ matrix.os }}
- name: Add the bin directory to PATH
run: |
echo "${HOME}/install/bin" >> "${GITHUB_PATH}"
- name: Print installed versions
if: always()
run: .github/workflows/print_versions.sh
- name: Test executing of the grass command
run: .github/workflows/test_simple.sh
- name: Run pytest with multiple workers in parallel
run: |
PYTHONPATH="$(grass --config python_path):${PYTHONPATH}"
LD_LIBRARY_PATH="$(grass --config path)/lib:${LD_LIBRARY_PATH}"
INITIAL_GISBASE="$(grass --config path)"
INITIAL_PWD="${PWD}"
export PYTHONPATH
export LD_LIBRARY_PATH
export INITIAL_GISBASE
export INITIAL_PWD
pytest \
@.github/workflows/pytest_args_ci.txt \
@.github/workflows/pytest_args_cov.txt \
@.github/workflows/pytest_args_parallel.txt \
--junitxml=pytest.xdist.junit.xml \
-k 'not testsuite'
- name: Run pytest with a single worker (for tests marked with needs_solo_run)
run: |
PYTHONPATH="$(grass --config python_path):${PYTHONPATH}"
LD_LIBRARY_PATH="$(grass --config path)/lib:${LD_LIBRARY_PATH}"
INITIAL_GISBASE="$(grass --config path)"
INITIAL_PWD="${PWD}"
export PYTHONPATH
export LD_LIBRARY_PATH
export INITIAL_GISBASE
export INITIAL_PWD
pytest \
@.github/workflows/pytest_args_ci.txt \
@.github/workflows/pytest_args_cov.txt \
@.github/workflows/pytest_args_not_parallel.txt \
--junitxml=pytest.needs_solo_run.junit.xml \
-k 'not testsuite'
- name: Run pytest with a single worker (for gunittest-based tests)
run: |
PYTHONPATH="$(grass --config python_path):${PYTHONPATH}"
LD_LIBRARY_PATH="$(grass --config path)/lib:${LD_LIBRARY_PATH}"
INITIAL_GISBASE="$(grass --config path)"
INITIAL_PWD="${PWD}"
export PYTHONPATH
export LD_LIBRARY_PATH
export INITIAL_GISBASE
export INITIAL_PWD
pytest \
@.github/workflows/pytest_args_cov.txt \
@.github/workflows/pytest_args_gunittest.txt \
--junitxml=pytest.gunittest.junit.xml
- name: Fix non-standard installed script paths in coverage data
run: |
PYTHONPATH="$(grass --config python_path):${PYTHONPATH}"
LD_LIBRARY_PATH="$(grass --config path)/lib:${LD_LIBRARY_PATH}"
INITIAL_GISBASE="$(grass --config path)"
INITIAL_PWD="${PWD}"
export PYTHONPATH
export LD_LIBRARY_PATH
export INITIAL_GISBASE
export INITIAL_PWD
python utils/coverage_mapper.py
coverage combine
coverage html
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
with:
exclude: gui
flags: pytest-python-${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
verbose: true
flags: pytest-python-${{ matrix.python-version }}
name: pytest-python-${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}
- name: Make python-only code coverage test report available
if: ${{ !cancelled() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: python-codecoverage-report-${{ matrix.os }}-${{ matrix.python-version }}
path: coverage_html_report
retention-days: 1
pytest-success:
name: pytest Result
needs:
- pytest
if: ${{ always() }}
uses: ./.github/workflows/verify-success.yml
with:
needs_context: ${{ toJson(needs) }}