Skip to content

tests

tests #17

Workflow file for this run

# adapted from:
# - https://github.com/matplotlib/matplotlib/blob/master/.github/workflows/cibuildwheel.yml
# - https://github.com/scikit-image/scikit-image/blob/master/.github/workflows/cibuildwheel.yml
# - https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
# - https://github.com/stardist/stardist/blob/master/.github/workflows/cibuildwheel.yml
name: tests
on:
push:
branches:
- wheels
release:
types:
- published
jobs:
build_wheels:
name: Build ${{ matrix.py }} wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
SETUPTOOLS_USE_DISTUTILS: stdlib
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-13]
py: [cp39, cp310, cp311, cp312]
steps:
- uses: actions/checkout@v3
name: Checkout repository
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.x'
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
# https://scikit-learn.org/stable/developers/advanced_installation.html#macos
- name: Setup OpenMP (macOS)
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
brew config
brew install libomp
eval `brew shellenv`
tee -a $GITHUB_ENV << END
CC=/usr/bin/clang
CXX=/usr/bin/clang++
CFLAGS=${CFLAGS} -I${HOMEBREW_PREFIX}/opt/libomp/include
CXXFLAGS=${CXXFLAGS} -I${HOMEBREW_PREFIX}/opt/libomp/include
LDFLAGS=${LDFLAGS} -Wl,-rpath,${HOMEBREW_PREFIX}/opt/libomp/lib -L${HOMEBREW_PREFIX}/opt/libomp/lib -lomp
END
- name: Build wheels for CPython (macOS)
if: startsWith(matrix.os, 'macos')
run: |
python -m cibuildwheel --output-dir dist
env:
CIBW_BUILD: "${{ matrix.py }}-*"
CIBW_ARCHS_MACOS: arm64
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: pytest pytest-cov
CIBW_TEST_COMMAND: pytest -v --cov=spotiflow {project}
- name: Build wheels for CPython (Linux and Windows)
if: startsWith(matrix.os, 'macos') == false
run: |
python -m cibuildwheel --output-dir dist
env:
# only build for specific platforms
CIBW_BUILD: "${{ matrix.py }}-*{x86_64,win_amd64}"
CIBW_SKIP: "*musllinux*"
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: pytest pytest-cov
CIBW_TEST_COMMAND: pytest -v --cov=spotiflow {project}
- uses: actions/upload-artifact@v3
name: Upload wheels
with:
name: dist
path: ./dist/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout repository
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
name: Upload sdist
with:
name: dist
path: dist/*.tar.gz
upload_pypi:
name: Upload to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published' # upload to pypi only on release
steps:
- uses: actions/download-artifact@v4
name: Download wheels and sdist
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
name: Publish to PyPI
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true