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
|
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: test and deploy
on:
push:
branches:
- main
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
test:
name: ${{ matrix.platform }}, py${{ matrix.python-version }}, napari ${{ matrix.napari }}, ${{ matrix.tool }}
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.12"]
napari: ["latest", "repo", '0.6.6']
tool: ["pip", "conda"]
include:
# add 3.13 on ubuntu
- platform: ubuntu-latest
napari: repo
tool: pip
python-version: "3.13"
# only run macos intel on py3.12
- platform: macos-15-intel
napari: repo
tool: pip
python-version: "3.12"
- platform: macos-15-intel
napari: repo
tool: conda
python-version: "3.12"
exclude:
# skip repo install on conda
- platform: ubuntu-latest
napari: repo
tool: conda
- platform: windows-latest
napari: repo
- platform: macos-15-intel
napari: repo
- platform: macos-latest
napari: repo
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }} - pip
if: matrix.tool == 'pip'
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }} - conda
if: matrix.tool == 'conda'
uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
with:
miniforge-version: latest
channels: conda-forge
conda-remove-defaults: "true"
python-version: ${{ matrix.python-version }}
- name: Setup headless display
uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2
with:
qt: true
wm: herbstluftwm
- name: Install dependencies without tox-conda
if: matrix.tool == 'pip'
run: |
python -m pip install --upgrade pip
python -m pip install setuptools tox tox-gh-actions tox-uv
- name: Install dependencies including tox-conda
if: matrix.tool == 'conda'
shell: bash -el {0}
run: |
python -m pip install --upgrade pip
python -m pip install setuptools 'tox<4' tox-gh-actions tox-conda
- name: Test with tox - pip
if: matrix.tool == 'pip'
run: python -m tox
env:
PYVISTA_OFF_SCREEN: True # required for opengl on windows
NAPARI: ${{ matrix.napari }}
TOOL: ${{ matrix.tool }}
FORCE_COLOR: 1
- name: Test with tox - conda
if: matrix.tool == 'conda'
shell: bash -el {0}
run: python -m tox
env:
PYVISTA_OFF_SCREEN: True # required for opengl on windows
NAPARI: ${{ matrix.napari }}
TOOL: ${{ matrix.tool }}
FORCE_COLOR: 1
- name: Upload coverage data
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: coverage reports ${{ matrix.platform }} py ${{ matrix.python-version }} ${{ matrix.tool }} ${{ matrix.napari }}
include-hidden-files: true
path: |
./.coverage.*
upload_coverage:
permissions:
id-token: write # Required for OIDC authentication
contents: read # Required for code checkout
name: Upload coverage
needs: [test]
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.x"
cache-dependency-path: pyproject.toml
cache: 'pip'
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install codecov
- name: Download coverage data
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
pattern: coverage reports*
path: coverage
merge-multiple: true
- name: combine coverage data
run: |
python -Im coverage combine coverage
python -Im coverage xml -o coverage.xml
# Report and write to summary.
python -Im coverage report --format=markdown --skip-empty --skip-covered >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage data
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
fail_ci_if_error: true
use_oidc: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }}
deploy:
# this will run when you have tagged a commit, starting with "v*"
# needs: [test]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
permissions:
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools build
- name: Build
run: |
git tag
python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
|