-
Notifications
You must be signed in to change notification settings - Fork 108
233 lines (201 loc) · 7.36 KB
/
test.yaml
File metadata and controls
233 lines (201 loc) · 7.36 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 5 1,15 * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: "1"
MPLBACKEND: agg
UV_COMPILE_BYTECODE: "1"
COVERAGE_FILE: ${{ github.workspace }}/.coverage
defaults:
run:
# to fail on error in multiline statements (-e), in pipes (-o pipefail), and on unset variables (-u).
shell: bash -euo pipefail {0}
jobs:
ensure-data-is-cached:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: false
python-version: "3.13"
- name: Restore data cache
id: data-cache
uses: actions/cache@v4
with:
path: data # IMPORTANT: this will fail if scanpy.settings.datasetdir default changes
key: data-${{ hashFiles('**/download_data.py') }}
restore-keys: |
data-
enableCrossOsArchive: true
- name: Download datasets
# Always run to ensure any missing files are downloaded
# (restore-keys may provide partial cache)
run: uvx hatch run data:download
# Get the test environment from hatch as defined in pyproject.toml.
# This ensures that the pyproject.toml is the single point of truth for test definitions and the same tests are
# run locally and on continuous integration.
# Check [[tool.hatch.envs.hatch-test.matrix]] in pyproject.toml and https://hatch.pypa.io/latest/environment/ for more details.
get-environments:
runs-on: ubuntu-latest
outputs:
envs: ${{ steps.get-envs.outputs.envs }}
steps:
- uses: actions/checkout@v5
with:
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
- name: Get test environments
id: get-envs
run: |
ENVS_JSON=$(NO_COLOR=1 uvx --quiet hatch env show --json | jq -c 'to_entries
| map(
select(.key | startswith("hatch-test"))
| {
name: .key,
label: (if (.key | contains("pre")) then .key + " (PRE-RELEASE DEPENDENCIES)" else .key end),
python: .value.python
}
)')
echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
# Run tests through hatch. Spawns a separate runner for each environment defined in the hatch matrix obtained above.
test:
needs: [ensure-data-is-cached, get-environments]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
exclude:
- os: macos-latest
env: { name: hatch-test.py3.11-stable }
- os: macos-latest
env: { name: hatch-test.py3.12-stable }
- os: ubuntu-latest
env: { name: hatch-test.py3.13-stable } # skipping because we run this as a coverage job
name: ${{ matrix.env.label }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.env.python }}
cache-dependency-glob: pyproject.toml
- name: Ensure figure directory exists
run: mkdir -p "$GITHUB_WORKSPACE/tests/figures"
- name: Restore data cache
id: data-cache
uses: actions/cache@v4
with:
path: data # IMPORTANT: this will fail if scanpy.settings.datasetdir default changes
key: data-${{ hashFiles('**/download_data.py') }}
restore-keys: |
data-
enableCrossOsArchive: true
- name: System dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -y
sudo apt-get install automake -y
# PyQt5 related
sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 -y
sudo Xvfb :42 -screen 0 1920x1080x24 -ac +extension GLX </dev/null &
- name: System dependencies (macOS)
if: matrix.os == 'macos-latest'
run: brew install automake
- name: create hatch environment
run: uvx hatch env create ${{ matrix.env.name }}
- name: run tests using hatch
env:
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
run: uvx hatch run ${{ matrix.env.name }}:run -v --color=yes -n auto
- name: Archive figures generated during testing
if: always()
uses: actions/upload-artifact@v4
with:
name: visual_test_results_${{ runner.os }}_${{ matrix.env.name }}
path: ${{ github.workspace }}/tests/figures/*
coverage:
name: Coverage (ubuntu-latest, hatch-test.py3.13-stable)
needs: [ensure-data-is-cached]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"
cache-dependency-glob: pyproject.toml
- name: Ensure figure directory exists
run: mkdir -p "$GITHUB_WORKSPACE/tests/figures"
- name: Restore data cache
id: coverage-data-cache
uses: actions/cache@v4
with:
path: data # IMPORTANT: this will fail if scanpy.settings.datasetdir default changes
key: data-${{ hashFiles('**/download_data.py') }}
restore-keys: |
data-
enableCrossOsArchive: true
- name: System dependencies (Linux)
run: |
sudo apt-get update -y
sudo apt-get install automake -y
# PyQt5 related
sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 -y
sudo Xvfb :42 -screen 0 1920x1080x24 -ac +extension GLX </dev/null &
- name: create hatch environment
run: uvx hatch env create hatch-test.py3.13-stable
- name: run coverage tests
env:
PLATFORM: ubuntu-latest
DISPLAY: :42
run: |
uvx hatch run hatch-test.py3.13-stable:cov-erase
uvx hatch run hatch-test.py3.13-stable:run-cov -v --color=yes
uvx hatch run hatch-test.py3.13-stable:cov-combine
uvx hatch run hatch-test.py3.13-stable:cov-report
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
# Check that all tests defined above pass. This makes it easy to set a single "required" test in branch
# protection instead of having to update it frequently. See https://github.com/re-actors/alls-green#why.
check:
name: Tests pass in all hatch environments
if: always()
needs:
- get-environments
- test
- coverage
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}