Skip to content

Python Build Main

Python Build Main #112

Workflow file for this run

on:
push:
branches:
- main
schedule:
- cron: 0 18 * * 1
env:
CIBW_TEST_COMMAND: pytest {project}/aicspylibczi/tests
CIBW_TEST_EXTRAS: test
# skip python 3.6, 32-bit builds, and PyPy
CIBW_SKIP: cp36-* cp37-* *-win32 *-manylinux_i686 pp*
name: Python Build Main
jobs:
python-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install .[test]
- name: Test with pytest
run: |
pytest --cov-report xml --cov=aicspylibczi aicspylibczi/tests
- name: Upload codecov
uses: codecov/codecov-action@v4
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install .[test]
- name: Lint with flake8
run: |
flake8 aicspylibczi --count --verbose --max-line-length=127 --show-source --statistics
build_sdist:
name: Build SDist
needs: [python-test, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build SDist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
build_wheels:
name: Wheels on ${{ matrix.cibw-arch }}
needs: [python-test, lint]
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
cibw-arch: manylinux_x86_64
- runs-on: macos-latest
cibw-arch: macosx_x86_64
- runs-on: macos-latest
cibw-arch: macosx_arm64
- runs-on: macos-latest
cibw-arch: macosx_universal2
- runs-on: windows-latest
cibw-arch: win_amd64
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: pypa/[email protected]
env:
CIBW_BUILD: "*-${{ matrix.cibw-arch }}"
CIBW_BEFORE_ALL_LINUX: yum install -y zlib-devel libpng-devel
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: pytest {project}/aicspylibczi/tests
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
CMAKE_OSX_ARCHITECTURES: ${{ matrix.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.cibw-arch == 'macosx_arm64' && 'arm64' || matrix.cibw-arch == 'macosx_universal2' && 'arm64;x86_64' || '' }}
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
path: wheelhouse/*.whl
upload_all:
name: Upload if release
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Bump version')"
steps:
- uses: actions/setup-python@v5
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/[email protected]
with:
user: aicspypi
password: ${{ secrets.PYPI_TOKEN }}