Skip to content

Merge pull request #442 from Scottacus64/patch-1 #2

Merge pull request #442 from Scottacus64/patch-1

Merge pull request #442 from Scottacus64/patch-1 #2

Workflow file for this run

# GitHub Workflow to build, test, and upload wheels
# TODO: Implement GitHub's caching to speed up builds
# TODO: Decide on specific versions of dependencies, and our locking strategy
# TODO: Implement ARM-based macOS builds on a self-hosted runner
# TODO: Raspberry Pi builds
# TODO: Linting
name: Wheel Builder
on: [push, pull_request]
jobs:
build_wheels:
name: Build for ${{ matrix.cibw-build }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# - os: windows-latest
# python-version: 3.7
# cibw-build: cp37-win_amd64
# - os: windows-latest
# python-version: 3.8
# cibw-build: cp38-win_amd64
# - os: windows-latest
# python-version: 3.9
# cibw-build: cp39-win_amd64
- os: ubuntu-latest
python-version: 3.7
cibw-build: cp37-manylinux_x86_64
- os: ubuntu-latest
python-version: 3.8
cibw-build: cp38-manylinux_x86_64
- os: ubuntu-latest
python-version: 3.9
cibw-build: cp39-manylinux_x86_64
# - os: macos-latest # Github hosted and self-hosted ARM runners are not yet available, so I'll just build locally for now.
# python-version: 3.8
# cibw-build: cp38-macosx_arm64
# - os: macos-latest
# python-version: 3.9
# cibw-build: cp39-macosx_arm64
- os: macos-latest
python-version: 3.7
cibw-build: cp37-macosx_x86_64
- os: macos-latest
python-version: 3.8
cibw-build: cp38-macosx_x86_64
- os: macos-latest
python-version: 3.9
cibw-build: cp39-macosx_x86_64
steps:
- name: Checkout MPF-MC
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run cibuildwheel
uses: pypa/cibuildwheel@v2.8.1
env:
CIBW_BEFORE_ALL_LINUX: > # This is done here and not as its own step as this runs inside the cibw containered environment
yum install -y SDL2.x86_64 SDL2-devel.x86_64 SDL2_image.x86_64 SDL2_image-devel.x86_64
SDL2_mixer.x86_64 SDL2_mixer-devel.x86_64 gstreamer1.x86_64 gstreamer1-devel.x86_64 &&
python -m pip install --upgrade pip &&
pip install --upgrade setuptools wheel build &&
git clone --recursive --branch ${{ github.ref_name }} https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch `python get_version.py` https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch dev https://github.com/missionpinball/mpf.git _mpf &&
pip install -e _mpf
CIBW_BEFORE_ALL_MACOS: >
brew install SDL2 SDL2_mixer SDL2_image SDL2_ttf gstreamer
CIBW_BEFORE_ALL: >
python -m pip install --upgrade pip &&
pip install --upgrade setuptools wheel build &&
git clone --recursive --branch ${{ github.ref_name }} https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch `python get_version.py` https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch dev https://github.com/missionpinball/mpf.git _mpf &&
pip install -e _mpf
CIBW_BUILD: ${{ matrix.cibw-build }}
CIBW_BUILD_VERBOSITY: 3
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: mpf-mc_wheels
path: ./wheelhouse/*.whl
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- name: Check out MPF-MC
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build SDist
run: >
sudo apt-get update &&
sudo apt-get -y remove libunwind-14 &&
sudo apt-get -y install libunwind-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev
gstreamer1.0-plugins-base gstreamer1.0-plugins-base gstreamer1.0-plugins-bad
gstreamer1.0-plugins-ugly libgstreamer1.0-dev &&
pip install --upgrade setuptools wheel build &&
python -m build --sdist
- name: Upload SDist
uses: actions/upload-artifact@v3
with:
name: mpf-mc_wheels
path: dist/*.tar.gz
test_wheels:
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
needs: [build_wheels]
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
python-version: 3.9
run-tests: true
runs-on: ${{ matrix.os }}
env:
DISPLAY: ':99.0'
steps:
- name: Install runtime libraries on macOS
if: runner.os == 'macOS'
run: brew install SDL2 SDL2_mixer gstreamer
- name: Install runtime libraries on Linux
if: runner.os == 'linux'
run: |
sudo apt-get update
sudo apt-get -y install libsdl2-2.0 libsdl2-mixer-2.0 gstreamer-1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-base gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly xvfb
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install runtime dependencies via pip
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel coveralls prospector==1.3.1
- name: Download the newly-built wheel
uses: actions/download-artifact@v3
with:
name: mpf-mc_wheels
path: dist
- name: Clone & install MPF # try to find a matching version before we default to dev
run: >
git clone --recursive --branch ${{ github.ref_name }} https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch `python get_version.py` https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch dev https://github.com/missionpinball/mpf.git _mpf &&
pip install -e _mpf
- name: Install MPF-MC from new wheel
run: pip install --pre --find-links=dist mpf-mc
- name: Run tests # Can't figure out how to run tests on mac or windows, but I guess that's ok? At least we test the wheel installs? TODO?
if: ${{ matrix.run-tests }} # controlled via the matrix:include: section above
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1280x720x24 -ac +extension GLX
coverage3 run --concurrency=thread -m unittest discover mpfmc.tests
coverage3 run -a --concurrency=thread -m unittest discover mpfmc.integration
- name: Upload coverage data to coveralls.io
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}-${{ matrix.os }}
COVERALLS_PARALLEL: true
publish_to_pypi: # only if this release has a tag and is a push from us (e.g. not a pull request)
name: Publish to PYPI
needs: [test_wheels, make_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- name: Download wheels
uses: actions/download-artifact@v3
with:
name: mpf-mc_wheels
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
coveralls:
name: Finalize Coveralls
needs: test_wheels
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}