| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: [main] |
| 6 |
tags: [v*] |
| 7 |
pull_request: |
| 8 |
workflow_dispatch: |
| 9 |
schedule: |
| 10 |
# run every week (for --pre release tests) |
| 11 |
- cron: "0 0 * * 0" |
| 12 |
|
| 13 |
concurrency: |
| 14 |
group: ${{ github.workflow }}-${{ github.ref }} |
| 15 |
cancel-in-progress: true |
| 16 |
|
| 17 |
jobs: |
| 18 |
check-manifest: |
| 19 |
runs-on: ubuntu-latest |
| 20 |
steps: |
| 21 |
- uses: actions/checkout@v5 |
| 22 |
- run: pipx run check-manifest |
| 23 |
|
| 24 |
pyright: |
| 25 |
runs-on: ubuntu-latest |
| 26 |
steps: |
| 27 |
- uses: actions/checkout@v5 |
| 28 |
- uses: astral-sh/setup-uv@v7 |
| 29 |
- run: uv run --with pyqt6 pyright |
| 30 |
|
| 31 |
test: |
| 32 |
name: ${{ matrix.platform }} py${{ matrix.python-version }} |
| 33 |
runs-on: ${{ matrix.platform }} |
| 34 |
env: |
| 35 |
UV_PRERELEASE: ${{ github.event_name == 'schedule' && 'allow' || 'if-necessary-or-explicit' }} |
| 36 |
UV_NO_SYNC: 1 |
| 37 |
strategy: |
| 38 |
fail-fast: false |
| 39 |
matrix: |
| 40 |
python-version: ["3.9", "3.11", "3.13"] |
| 41 |
platform: [ubuntu-latest, macos-latest, windows-latest] |
| 42 |
include: |
| 43 |
- python-version: "3.10" |
| 44 |
platform: "macos-latest" |
| 45 |
- python-version: "3.12" |
| 46 |
platform: "macos-latest" |
| 47 |
- python-version: "3.9" |
| 48 |
platform: "ubuntu-latest" |
| 49 |
resolution: "lowest-direct" |
| 50 |
|
| 51 |
steps: |
| 52 |
- uses: actions/checkout@v5 |
| 53 |
with: |
| 54 |
fetch-depth: 0 |
| 55 |
|
| 56 |
- name: ๐ Set up Python ${{ matrix.python-version }} |
| 57 |
uses: astral-sh/setup-uv@v7 |
| 58 |
with: |
| 59 |
python-version: ${{ matrix.python-version }} |
| 60 |
enable-cache: true |
| 61 |
cache-dependency-glob: "**/pyproject.toml" |
| 62 |
|
| 63 |
- name: Install Dependencies |
| 64 |
run: uv sync --no-dev --group test --resolution ${{ matrix.resolution || 'highest'}} |
| 65 |
|
| 66 |
- name: ๐งช Run Tests |
| 67 |
run: uv run coverage run -p -m pytest -v |
| 68 |
env: |
| 69 |
PYTEST_ADDOPTS: ${{ matrix.resolution == 'lowest-direct' && '-W ignore' || '' }} |
| 70 |
|
| 71 |
- name: Upload coverage |
| 72 |
uses: actions/upload-artifact@v5 |
| 73 |
with: |
| 74 |
name: covreport-${{ matrix.platform }}-py${{ matrix.python-version }} |
| 75 |
path: ./.coverage* |
| 76 |
include-hidden-files: true |
| 77 |
|
| 78 |
test-qt: |
| 79 |
name: ${{ matrix.platform }} py${{ matrix.python-version }} ${{matrix.extra }} ${{ matrix.resolution }} |
| 80 |
runs-on: ${{ matrix.platform }} |
| 81 |
env: |
| 82 |
UV_PRERELEASE: ${{ github.event_name == 'schedule' && 'allow' || 'if-necessary-or-explicit' }} |
| 83 |
UV_NO_SYNC: 1 |
| 84 |
strategy: |
| 85 |
fail-fast: false |
| 86 |
matrix: |
| 87 |
python-version: ["3.10", "3.12"] |
| 88 |
platform: [macos-latest, windows-latest] |
| 89 |
extra: [pyqt5, pyside2, pyside6, pyqt6] |
| 90 |
resolution: [highest, lowest-direct] |
| 91 |
exclude: |
| 92 |
- platform: "macos-latest" |
| 93 |
extra: "pyside2" |
| 94 |
- python-version: "3.12" |
| 95 |
extra: "pyside2" |
| 96 |
|
| 97 |
steps: |
| 98 |
- uses: actions/checkout@v5 |
| 99 |
with: |
| 100 |
fetch-depth: 0 |
| 101 |
|
| 102 |
- name: ๐ Set up Python ${{ matrix.python-version }} |
| 103 |
uses: astral-sh/setup-uv@v7 |
| 104 |
with: |
| 105 |
python-version: ${{ matrix.python-version }} |
| 106 |
enable-cache: true |
| 107 |
cache-dependency-glob: "**/pyproject.toml" |
| 108 |
|
| 109 |
- uses: pyvista/setup-headless-display-action@v4 |
| 110 |
with: |
| 111 |
qt: true |
| 112 |
|
| 113 |
- name: Install Dependencies |
| 114 |
run: uv sync --no-dev --group test-qt --extra ${{ matrix.extra }} --resolution ${{ matrix.resolution }} |
| 115 |
|
| 116 |
- name: ๐งช Run Tests |
| 117 |
run: uv run coverage run -p -m pytest -v |
| 118 |
env: |
| 119 |
PYTEST_ADDOPTS: ${{ matrix.resolution == 'lowest-direct' && '-W ignore' || '' }} |
| 120 |
|
| 121 |
# If something goes wrong with --pre tests, we can open an issue in the repo |
| 122 |
- name: ๐ Report --pre Failures |
| 123 |
if: failure() && github.event_name == 'schedule' |
| 124 |
uses: JasonEtco/create-an-issue@v2 |
| 125 |
env: |
| 126 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 127 |
PLATFORM: ${{ matrix.platform }} |
| 128 |
PYTHON: ${{ matrix.python-version }} |
| 129 |
RUN_ID: ${{ github.run_id }} |
| 130 |
TITLE: "[test-bot] pip install --pre is failing" |
| 131 |
with: |
| 132 |
filename: .github/TEST_FAIL_TEMPLATE.md |
| 133 |
update_existing: true |
| 134 |
|
| 135 |
- name: Upload coverage |
| 136 |
uses: actions/upload-artifact@v5 |
| 137 |
with: |
| 138 |
name: covreport-${{ matrix.platform }}-py${{ matrix.python-version }}-${{ matrix.extra }}-${{ matrix.resolution }} |
| 139 |
path: ./.coverage* |
| 140 |
include-hidden-files: true |
| 141 |
|
| 142 |
upload_coverage: |
| 143 |
if: always() |
| 144 |
needs: [test, test-qt] |
| 145 |
uses: pyapp-kit/workflows/.github/workflows/upload-coverage.yml@v2 |
| 146 |
secrets: inherit |
| 147 |
|
| 148 |
test_napari: |
| 149 |
uses: pyapp-kit/workflows/.github/workflows/test-dependents.yml@v2 |
| 150 |
with: |
| 151 |
dependency-repo: napari/napari |
| 152 |
dependency-extras: "testing" |
| 153 |
qt: ${{ matrix.qt }} |
| 154 |
pytest-args: 'src/napari/_qt/_qapp_model src/napari/_app_model src/napari/utils/_tests/test_key_bindings.py --import-mode=importlib -k "not async and not qt_dims_2"' |
| 155 |
python-version: "3.11" |
| 156 |
strategy: |
| 157 |
fail-fast: false |
| 158 |
matrix: |
| 159 |
qt: ["pyqt5", "pyside6"] |
| 160 |
|
| 161 |
build-and-inspect-package: |
| 162 |
name: Build & inspect package. |
| 163 |
needs: [check-manifest, test] |
| 164 |
runs-on: ubuntu-latest |
| 165 |
steps: |
| 166 |
- uses: actions/checkout@v5 |
| 167 |
with: |
| 168 |
fetch-depth: 0 |
| 169 |
- uses: hynek/build-and-inspect-python-package@v2 |
| 170 |
|
| 171 |
upload-to-pypi: |
| 172 |
name: Upload package to PyPI |
| 173 |
needs: build-and-inspect-package |
| 174 |
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule' |
| 175 |
runs-on: ubuntu-latest |
| 176 |
permissions: |
| 177 |
id-token: write |
| 178 |
contents: write |
| 179 |
|
| 180 |
steps: |
| 181 |
- name: Download built artifact to dist/ |
| 182 |
uses: actions/download-artifact@v6 |
| 183 |
with: |
| 184 |
name: Packages |
| 185 |
path: dist |
| 186 |
- name: ๐ข Publish to PyPI |
| 187 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 188 |
- uses: softprops/action-gh-release@v2 |
| 189 |
with: |
| 190 |
generate_release_notes: true |
| 191 |
files: "./dist/*" |