ci #346
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: ci | |
| on: | |
| push: | |
| tags: | |
| - v* | |
| pull_request: | |
| branches: [main] | |
| schedule: | |
| - cron: "0 0 * * 1,3,5" | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-python@v3 | |
| - uses: pre-commit/action@v3.0.1 | |
| tests: | |
| needs: [pre-commit] | |
| name: "pytest and snakemake" | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install extra dependencies | |
| run: uv sync --extra cellpose --dev && uv pip install 'snakemake>=7.32.4,<9.0' 'pulp<2.8' 'cellpose==3.1.1' | |
| - name: Tests | |
| run: uv run poe test | |
| - name: Snakemake | |
| run: cd workflow && uv run snakemake --config sdata_path=tuto.zarr --configfile=config/toy/cellpose.yaml --workflow-profile profile/ci -c1 | |
| test_wsi: | |
| needs: [pre-commit] | |
| name: "pytest wsi" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Install extra dependencies | |
| run: uv sync --extra wsi --dev && uv pip install 'openslide-bin==4.0.0.8' 'openslide-python==1.4.2' 'slideio==2.7.1' 'timm==1.0.21' | |
| - name: Tests | |
| run: uv run poe test_wsi | |
| test_cellpose_v4: | |
| needs: [pre-commit] | |
| name: "pytest cellpose v4" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Install extra dependencies | |
| run: uv sync --extra cellpose --dev | |
| - name: Tests | |
| run: uv run poe test_long | |
| test_pip_install: | |
| needs: [pre-commit] | |
| name: "pytest with pip install" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Install sopa with pip | |
| run: pip install -e ".[wsi]" && pip install pytest-cov poethepoet | |
| - name: Run short tests | |
| run: poe test_short | |
| deploy-docs: | |
| needs: [tests, test_wsi, test_cellpose_v4, test_pip_install] | |
| if: contains(github.ref, 'tags') | |
| name: "Deploy documentation" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Install extra dependencies | |
| run: uv sync --dev | |
| - name: Build documentation | |
| run: uv run mkdocs gh-deploy --force | |
| pypi-release: | |
| needs: [tests, test_wsi, test_cellpose_v4, test_pip_install] | |
| if: contains(github.ref, 'tags') | |
| name: "PyPI release" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Build | |
| run: uv build | |
| - name: Publish | |
| run: uv publish -t ${{ secrets.PYPI_TOKEN }} | |
| wait-for-pypi: | |
| needs: [pypi-release] | |
| if: contains(github.ref, 'tags') | |
| name: "Wait until PyPI is ready" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Wait for sopa to be available on PyPI | |
| run: | | |
| SPEC="sopa==${GITHUB_REF#refs/tags/v}" | |
| attempt=0 | |
| max_attempts=20 | |
| echo "Waiting for ${SPEC} to be downloadable from PyPI..." | |
| while true; do | |
| if pip download --no-cache-dir --no-deps "${SPEC}" >/dev/null 2>&1; then | |
| break | |
| fi | |
| attempt=$((attempt+1)) | |
| if [ "${attempt}" -ge "${max_attempts}" ]; then | |
| echo "Timed out waiting for ${SPEC} to be downloadable from PyPI." | |
| exit 1 | |
| fi | |
| echo "Attempt ${attempt}/${max_attempts} failed, retrying..." | |
| sleep 30 | |
| done | |
| echo "${SPEC} is available on PyPI." | |
| docker-images-release: | |
| needs: [wait-for-pypi] | |
| if: contains(github.ref, 'tags') | |
| name: "Docker images release" | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| extra-name: | |
| [ | |
| "", | |
| "-baysor", | |
| "-cellpose", | |
| "-comseg", | |
| "-proseg", | |
| "-stardist", | |
| "-tangram", | |
| ] | |
| steps: | |
| - name: Export tag version | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/v}" | |
| echo "VERSION=$TAG" >> $GITHUB_ENV | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| platforms: linux/amd64 | |
| tags: | | |
| ${{ vars.DOCKERHUB_USERNAME }}/sopa:${{ env.VERSION }}${{ matrix.extra-name }} | |
| ${{ vars.DOCKERHUB_USERNAME }}/sopa:latest${{ matrix.extra-name }} | |
| context: ./docker/sopa${{ matrix.extra-name }} | |
| build-args: | | |
| SOPA_VERSION=${{ env.VERSION }} |