Skip to content

Merge pull request #679 from padix-key/deserialize #564

Merge pull request #679 from padix-key/deserialize

Merge pull request #679 from padix-key/deserialize #564

---
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"
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
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"
strategy:
matrix:
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# 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
make-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment.yml
miniforge-version: latest
- name: Build distribution
run: pip wheel --no-deps -w dist .
- 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
# Use the built distribution for other downstream jobs to reduce build time
- uses: actions/upload-artifact@v4
with:
name: internal-build
path: ./dist/*.whl
test-muscle5:
name: Test interface to Muscle 5
runs-on: ubuntu-latest
needs:
- test-interfaces
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: "3.12"
- 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
make-ccd:
name: Compile the CCD subset for structure.info from the wwPDB CCD
runs-on: ubuntu-latest
needs:
- test-interfaces
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: internal-build
path: dist
- uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install distribution
run: pip install dist//*.whl
- name: Compile CCD subset
run: python setup_ccd.py
- name: Zip CCD
run: |
cd src/biotite/structure/info
zip -r ${{ github.workspace }}//dist//ccd.zip ccd
cd ${{ github.workspace }}
- uses: actions/upload-artifact@v4
with:
name: ccd
path: dist//ccd.zip
make-docs:
name: Build documentation
runs-on: ubuntu-20.04
needs:
- test-interfaces
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:
- test-interfaces
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: internal-build
path: dist
- uses: actions/setup-python@v3
with:
python-version: "3.12"
- 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
- make-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-docs:
name: Upload documentation to GitHub Releases
permissions:
contents: write
needs:
- make-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