-
Notifications
You must be signed in to change notification settings - Fork 103
390 lines (353 loc) · 10.9 KB
/
test_and_deploy.yml
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
---
name: "CI & CD"
on:
workflow_dispatch:
push:
branches:
- "main"
pull_request:
release:
types:
- published
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-*
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: >
pytest {project}
--durations=50
--ignore={project}//tests//sequence//align//test_statistics.py
--ignore={project}//tests//application
--ignore={project}//tests//database
--ignore={project}//tests//test_doctest.py
--ignore={project}//tests//test_modname.py
CIBW_DEPENDENCY_VERSIONS: "pinned"
# Once GHA and cibuildwheel are updated this can be removed
# mussllinux takes 6+ hrs to build and test so ignore it
CIBW_TEST_SKIP: "*musllinux* *-macosx_arm64"
# Configuration for the architecture-agnostic jobs
PY_VERSION: "3.12" # Keep in sync with version in environment.yml
jobs:
lint:
name: Check code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install ruff
# Keep in sync with the ruff version in pyproject.toml
run: pip install ruff==0.6.9
- name: Check code formatting
run: ruff format --diff
- name: Lint code base
run: ruff check
build-internal:
name: Build CCD and wheel for reusing it in several CI jobs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VERSION }}
- name: Get current CCD for hashing
run: wget https://files.wwpdb.org/pub/pdb/data/monomers/components.cif.gz
- name: Cache CCD
uses: actions/cache@v4
id: cache-ccd
with:
path: ./src/biotite/structure/info/components.bcif
key: cache-${{ hashFiles('setup_ccd.py') }}-${{ hashFiles('components.cif.gz') }}
- name: Remove CCD used for hashing
run: rm components.cif.gz
- name: Build internal CCD
if: steps.cache-ccd.outputs.cache-hit != 'true'
run: |
pip install .
python setup_ccd.py
- name: Install build backend
run: pip install build
- name: Build distribution
run: python -m build --wheel
- uses: actions/upload-artifact@v4
with:
name: internal-build
path: ./dist/*.whl
- uses: actions/upload-artifact@v4
with:
name: ccd
path: ./src/biotite/structure/info/components.bcif
generate-wheels-matrix:
name: "Generate wheels matrix"
runs-on: "ubuntu-latest"
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v4
- name: Install cibuildwheel
# MAKE SURE THIS STAYS IN SYNC WITH THE LOWER GHA cibuildwheel
run: pipx install cibuildwheel==2.20.0
- id: set-matrix
run: |
MATRIX=$(
{
cibuildwheel --print-build-identifiers --platform linux \
| jq -nRc '{"dist": inputs, "os": "ubuntu-latest"}' \
&& cibuildwheel --print-build-identifiers --platform macos \
| jq -nRc '{"dist": inputs, "os": "macos-latest"}' \
&& cibuildwheel --print-build-identifiers --platform windows \
| jq -nRc '{"dist": inputs, "os": "windows-latest"}'
} | jq -sc
)
echo "include=$MATRIX" | tee -a $GITHUB_OUTPUT
env:
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_WINDOWS: "x86 AMD64"
# Skip musllinux because it takes too long to compile on GHA
# since it is emulated. (6+ hours)
# *note* most of the build time is actually numpy for musllinux
CIBW_SKIP: "*musllinux* *-manylinux_i686 *-musllinux_i686 *-win32 pp*"
test-and-build:
name: "Build & Test"
needs:
- generate-wheels-matrix
- build-internal
strategy:
matrix:
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Add internal CCD to Biotite
uses: actions/download-artifact@v4
with:
name: ccd
path: src/biotite/structure/info
# QEMU enables building/testing for non-native architectures (ie arm64)
# at the cost of speed
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build & (optionally) test wheels
# MAKE SURE THIS STAYS IN SYNC WITH THE UPPER pipx call to cibuildwheel
uses: pypa/[email protected]
with:
only: ${{ matrix.dist }}
- uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.dist }}
path: ./wheelhouse/*.whl
sdist:
name: Build source distribution
runs-on: ubuntu-latest
needs:
- build-internal
steps:
- uses: actions/checkout@v4
- name: Add internal CCD to Biotite
uses: actions/download-artifact@v4
with:
name: ccd
path: src/biotite/structure/info
- name: Build source distribution
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: release-sdist
path: dist//*.tar.gz
test-interfaces:
name: Test interfaces to databases and applications
runs-on: ubuntu-latest
needs:
- build-internal
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: internal-build
path: dist
- uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment.yml
miniforge-version: latest
- name: Install distribution
run: pip install ./dist/*.whl
- name: "TEMP: Skip DSSP tests"
# TEMP: Omit DSSP tests for now until conda-forge DSSP is functional
# (https://github.com/conda-forge/dssp-feedstock/pull/4)
run: mamba uninstall dssp
- name: Run tests
# Running NCBI BLAST and SRA takes too long
# The tests on the NCBI Entrez database are not reliable enough
run: >
pytest
--durations=50
--ignore="tests//application//test_blast.py"
--ignore="tests//application//test_sra.py"
--ignore="tests//database//test_entrez.py"
tests//test_doctest.py
tests//test_modname.py
tests//database
tests//application
test-muscle5:
name: Test interface to Muscle 5
runs-on: ubuntu-latest
needs:
- build-internal
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: internal-build
path: dist
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: biotite-dev
miniforge-version: latest
python-version: ${{ env.PY_VERSION }}
- name: Install Muscle 5
run: conda install -c bioconda "muscle=5"
- name: Install distribution and pytest
run: pip install .//dist//*.whl pytest
- name: Test Muscle 5 interface
run: pytest --durations=50 tests//application//test_msa.py
docs:
name: Build documentation
runs-on: ubuntu-latest
needs:
- build-internal
defaults:
run:
shell: bash -l {0}
env:
NCBI_API_KEY: ${{ secrets.NCBI_API_KEY }}
steps:
- uses: actions/checkout@v4
with:
# Make sure to fetch the latest tag, so 'switcher.py' works correctly
fetch-depth: 0
fetch-tags: true
- uses: actions/download-artifact@v4
with:
name: internal-build
path: dist
- uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment.yml
miniforge-version: latest
- name: Install distribution
run: pip install dist/*.whl
- name: Build base documentation
run: sphinx-build -a -D plot_gallery=0 doc build//doc
- name: Build tutorial and gallery
if: >
(
github.event_name == 'release' &&
github.event.action == 'published'
)
|| github.event_name == 'workflow_dispatch'
run: sphinx-build -a doc build//doc
- name: Zip documentation
run: |
cd build
zip -r ..//dist//doc.zip doc
cd ..
- uses: actions/upload-artifact@v4
with:
name: documentation
path: dist//doc.zip
benchmark:
name: Run benchmarks
runs-on: ubuntu-latest
if: github.event_name != 'release'
needs:
- build-internal
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: internal-build
path: dist
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VERSION }}
- name: Install dependencies
run: pip install dist//*.whl pytest pytest-codspeed
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
run: pytest --codspeed benchmarks
upload-package:
name: Upload package to GitHub Releases & PyPI
permissions:
contents: write
needs:
- lint
- test-and-build
- sdist
- test-interfaces
- test-muscle5
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
path: dist
- name: List distributions to be uploaded
run: ls dist
- name: Upload to GitHub Releases
uses: softprops/[email protected]
if: github.event_name == 'release' && github.event.action == 'published'
with:
files: dist//*
- name: Upload to PyPI
uses: pypa/[email protected]
if: github.event_name == 'release' && github.event.action == 'published'
with:
password: ${{ secrets.PYPI_TOKEN }}
upload-ccd:
name: Upload CCD to GitHub Releases
permissions:
contents: write
needs:
- build-internal
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: ccd
path: dist
- name: Upload to GitHub Releases
uses: softprops/[email protected]
if: github.event_name == 'release' && github.event.action == 'published'
with:
files: dist//components.bcif
upload-docs:
name: Upload documentation to GitHub Releases
permissions:
contents: write
needs:
- docs
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: documentation
path: dist
- uses: softprops/[email protected]
if: github.event_name == 'release' && github.event.action == 'published'
with:
files: dist//doc.zip