Skip to content

fixed tests to work with the workflow #12

fixed tests to work with the workflow

fixed tests to work with the workflow #12

Workflow file for this run

name: Publish to PyPI
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: System deps for Qt/OpenGL (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libgl1 libegl1 libopengl0 \
libglib2.0-0 libxkbcommon0 libxi6 libxtst6 \
libxcb1 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \
libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
- run: python -m pip install -U pip
- run: python -m pip install -e .[testing]
- name: Run tests with Qt backend
env:
QT_QPA_PLATFORM: offscreen
MPLBACKEND: Agg
run: pytest tests/ -v --cov=napari_flowreg
- name: Verify napari plugin registration
run: python -c "import napari_flowreg; print('napari-flowreg plugin loaded successfully')"
build:
if: startsWith(github.ref, 'refs/tags/v')
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Fail if README contains relative image links
run: |
python - <<'PY'
import re, sys, pathlib
t = pathlib.Path("README.md").read_text(encoding="utf-8")
# Check for relative links in Markdown or HTML img tags
bad = re.search(r'!\[[^\]]*\]\((?!https?://)[^)]+\)|<img[^>]*src="(?!https?://)', t)
if bad:
print(f"ERROR: README.md contains relative image links: {bad.group(0)}")
print("Please ensure README image links are normalized before tagging a release.")
sys.exit(1)
else:
print("✓ README.md has properly normalized image links")
PY
- run: python -m pip install -U build twine
- run: python -m build
- run: python -m twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
wheel-smoke:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.11"]
steps:
- uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: System deps for Qt/OpenGL (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libgl1 libegl1 libopengl0 \
libglib2.0-0 libxkbcommon0 libxi6 libxtst6 \
libxcb1 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \
libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
- name: Install wheel
run: |
python -m pip install napari[all]
python -c "import glob; import subprocess; wheels = glob.glob('dist/*.whl'); print(f'Found wheels: {wheels}'); subprocess.check_call(['pip', 'install'] + wheels)"
- run: |
python -c "import napari_flowreg; print('napari-flowreg version:', getattr(napari_flowreg, '__version__', 'unknown'))"
python -c "from napari_flowreg.flowreg_widget import FlowRegWidget; print('Widget imports working')"
python -c "import napari; print('napari imports working')"
sdist-smoke:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: System deps for Qt/OpenGL
run: |
sudo apt-get update
sudo apt-get install -y \
libgl1 libegl1 libopengl0 \
libglib2.0-0 libxkbcommon0 libxi6 libxtst6 \
libxcb1 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \
libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
- name: Install sdist
run: |
python -m pip install napari[all]
python -c "import glob; import subprocess; tarballs = glob.glob('dist/*.tar.gz'); print(f'Found sdists: {tarballs}'); subprocess.check_call(['pip', 'install'] + tarballs)"
- run: python -c "import napari_flowreg; print('sdist import OK')"
publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: [wheel-smoke, sdist-smoke]
runs-on: ubuntu-latest
environment: pypi
steps:
- uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish RCs to TestPyPI
if: contains(github.ref_name, 'rc')
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/
skip-existing: true
- name: Publish to PyPI
if: "!contains(github.ref_name, 'rc')"
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: true