bump spec #328
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and Deploy bioimageio.core | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ "**" ] | |
defaults: | |
run: | |
shell: bash -el {0} | |
jobs: | |
black: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: psf/black@stable | |
with: | |
options: "--check" | |
src: "." | |
jupyter: true | |
version: "24.3" | |
populate-cache: | |
runs-on: ubuntu-latest | |
outputs: | |
cache-key: ${{steps.cache-key.outputs.cache-key}} | |
cache-key-light: ${{steps.cache-key.outputs.cache-key}}-light | |
steps: | |
- name: Get Date | |
id: get-date | |
run: | | |
echo "date=$(date +'%Y-%b')" | |
echo "date=$(date +'%Y-%b')" >> $GITHUB_OUTPUT | |
- id: cache-key | |
run: echo "cache-key=test-${{steps.get-date.outputs.date}}" >> $GITHUB_OUTPUT | |
- uses: actions/cache/restore@v4 | |
id: look-up | |
with: | |
path: bioimageio_cache | |
key: ${{steps.cache-key.outputs.cache-key}} | |
lookup-only: true | |
- uses: actions/checkout@v4 | |
if: steps.look-up.outputs.cache-hit != 'true' | |
- uses: actions/cache@v4 | |
if: steps.look-up.outputs.cache-hit != 'true' | |
with: | |
path: bioimageio_cache | |
key: ${{steps.cache-key.outputs.cache-key}} | |
- uses: actions/setup-python@v5 | |
if: steps.look-up.outputs.cache-hit != 'true' | |
with: | |
python-version: '3.12' | |
cache: 'pip' | |
- name: Install dependencies | |
if: steps.look-up.outputs.cache-hit != 'true' | |
run: | | |
pip install --upgrade pip | |
pip install -e .[dev] | |
- run: pytest --disable-pytest-warnings tests/test_bioimageio_collection.py::test_rdf_format_to_populate_cache | |
if: steps.look-up.outputs.cache-hit != 'true' | |
env: | |
BIOIMAGEIO_POPULATE_CACHE: '1' | |
BIOIMAGEIO_CACHE_PATH: bioimageio_cache | |
test: | |
needs: populate-cache | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- python-version: '3.8' | |
conda-env: py38 | |
spec: conda | |
- python-version: '3.8' | |
conda-env: py38 | |
spec: main | |
- python-version: '3.9' | |
conda-env: dev | |
spec: conda | |
- python-version: '3.10' | |
conda-env: dev | |
spec: conda | |
- python-version: '3.11' | |
conda-env: full | |
spec: main | |
run-expensive-tests: true | |
report-coverage: true | |
save-cache: true | |
- python-version: '3.12' | |
conda-env: dev | |
spec: conda | |
- python-version: '3.13' | |
conda-env: dev | |
spec: main | |
save-cache: true | |
steps: | |
- uses: actions/checkout@v4 | |
- id: setup | |
run: | | |
echo "env-name=${{ matrix.spec }}-${{ matrix.conda-env }}-${{ matrix.python-version }}" | |
echo "env-name=${{ matrix.spec }}-${{ matrix.conda-env }}-${{ matrix.python-version }}" >> $GITHUB_OUTPUT | |
echo "env-file=dev/env-${{ matrix.conda-env }}.yaml" | |
echo "env-file=dev/env-${{ matrix.conda-env }}.yaml" >> $GITHUB_OUTPUT | |
- name: check on env-file | |
shell: python | |
run: | | |
from pathlib import Path | |
from pprint import pprint | |
if not (env_path:=Path("${{steps.setup.outputs.env-file}}")).exists(): | |
if env_path.parent.exists(): | |
pprint(env_path.parent.glob("*")) | |
else: | |
pprint(Path().glob("*")) | |
raise FileNotFoundError(f"{env_path} does not exist") | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
auto-activate-base: true | |
activate-environment: ${{steps.setup.outputs.env-name}} | |
channel-priority: strict | |
miniforge-version: latest | |
- name: Get Date | |
id: get-date | |
run: | | |
echo "today=$(date -u '+%Y%m%d')" | |
echo "today=$(date -u '+%Y%m%d')" >> $GITHUB_OUTPUT | |
- name: Restore cached env | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{env.CONDA}}/envs/${{steps.setup.outputs.env-name}} | |
key: >- | |
conda-${{runner.os}}-${{runner.arch}} | |
-${{steps.get-date.outputs.today}} | |
-${{hashFiles(steps.setup.outputs.env-file)}} | |
-${{env.CACHE_NUMBER}} | |
env: | |
CACHE_NUMBER: 0 | |
id: cache-env | |
- name: Install env | |
run: conda env update --name=${{steps.setup.outputs.env-name}} --file=${{steps.setup.outputs.env-file}} python=${{matrix.python-version}} | |
if: steps.cache-env.outputs.cache-hit != 'true' | |
- name: Install uncached pip dependencies | |
run: | | |
pip install --upgrade pip | |
pip install --no-deps -e . | |
- name: Install uncached pip dependencies for 'full' environment | |
if: matrix.conda-env == 'full' | |
run: | | |
pip install git+https://github.com/ChaoningZhang/MobileSAM.git | |
- name: Cache env | |
if: steps.cache-env.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
path: ${{env.CONDA}}/envs/${{steps.setup.outputs.env-name}} | |
key: >- | |
conda-${{runner.os}}-${{runner.arch}} | |
-${{steps.get-date.outputs.today}} | |
-${{hashFiles(steps.setup.outputs.env-file)}} | |
-${{env.CACHE_NUMBER}} | |
env: | |
CACHE_NUMBER: 0 | |
- run: conda list | |
- name: Pyright | |
if: matrix.run-expensive-tests | |
run: | | |
pyright --version | |
pyright -p pyproject.toml --pythonversion ${{ matrix.python-version }} | |
- name: Restore bioimageio cache ${{matrix.run-expensive-tests && needs.populate-cache.outputs.cache-key || needs.populate-cache.outputs.cache-key-light}} | |
uses: actions/cache/restore@v4 | |
with: | |
path: bioimageio_cache | |
key: ${{matrix.run-expensive-tests && needs.populate-cache.outputs.cache-key || needs.populate-cache.outputs.cache-key-light}} | |
- name: pytest | |
run: pytest --cov bioimageio --cov-report xml --cov-append --capture no --disable-pytest-warnings | |
env: | |
BIOIMAGEIO_CACHE_PATH: bioimageio_cache | |
RUN_EXPENSIVE_TESTS: ${{ matrix.run-expensive-tests && 'true' || 'false' }} | |
- name: Save bioimageio cache ${{matrix.run-expensive-tests && needs.populate-cache.outputs.cache-key || needs.populate-cache.outputs.cache-key-light}} | |
if: matrix.save-cache | |
uses: actions/cache/save@v4 | |
with: | |
path: bioimageio_cache | |
key: ${{matrix.run-expensive-tests && needs.populate-cache.outputs.cache-key || needs.populate-cache.outputs.cache-key-light}} | |
- if: matrix.report-coverage && github.event_name == 'pull_request' | |
uses: orgoro/[email protected] | |
with: | |
coverageFile: coverage.xml | |
token: ${{secrets.GITHUB_TOKEN}} | |
- if: matrix.report-coverage && github.ref == 'refs/heads/main' | |
run: | | |
pip install genbadge[coverage] | |
genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg | |
coverage html -d dist/coverage | |
- if: matrix.report-coverage && github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage | |
retention-days: 1 | |
path: dist | |
conda-build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
auto-activate-base: true | |
activate-environment: "" | |
channel-priority: strict | |
miniforge-version: latest | |
conda-solver: libmamba | |
- name: install common conda dependencies | |
run: conda install -n base -c conda-forge conda-build -y | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
pkgs/noarch | |
pkgs/channeldata.json | |
key: ${{ github.sha }}-packages | |
- name: linux conda build test | |
shell: bash -l {0} | |
run: | | |
mkdir -p ./pkgs/noarch | |
conda-build -c conda-forge conda-recipe --no-test --output-folder ./pkgs | |
docs: | |
needs: test | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage | |
path: dist | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
cache: 'pip' | |
- run: pip install -e .[dev] | |
- name: Generate developer docs | |
run: ./scripts/pdoc/run.sh | |
- run: cp README.md ./dist/README.md | |
- name: copy rendered presentations | |
run: | | |
mkdir ./dist/presentations | |
cp -r ./presentations/*.html ./dist/presentations/ | |
- name: Deploy to gh-pages 🚀 | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: dist | |
publish-pypi: | |
name: Publish to PyPI | |
needs: test | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Upgrade pip | |
run: | | |
python -m pip install --upgrade pip | |
pip --version | |
pip install wheel .[tests] | |
- name: run tests | |
run: pytest --disable-pytest-warnings | |
- name: Check if there is a parent commit | |
id: check-parent-commit | |
run: | | |
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT | |
- name: Detect new version | |
id: check-version | |
if: steps.check-parent-commit.outputs.sha | |
uses: salsify/[email protected] | |
with: | |
create-tag: false | |
version-command: | | |
bash -o pipefail -c "cat bioimageio/core/VERSION | jq -r '.version'" | |
- name: Push tag | |
id: tag-version | |
if: steps.check-version.outputs.previous-version != steps.check-version.outputs.current-version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ steps.check-version.outputs.current-version }} | |
- name: Build package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Publish package on PyPI | |
if: steps.tag-version.outputs.new_tag | |
uses: pypa/gh-action-pypi-publish@release/v1.12 | |
with: | |
user: __token__ | |
password: "${{ secrets.PYPI_TOKEN }}" | |
packages-dir: dist/ | |
verbose: true | |
- name: Publish the release notes | |
uses: release-drafter/[email protected] | |
with: | |
publish: "${{ steps.tag-version.outputs.new_tag != '' }}" | |
tag: "${{ steps.tag-version.outputs.new_tag }}" | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |