Enable musllinux builds for Python 3.10 and 3.11. #810
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Compile, Test, and Deploy | |
on: | |
pull_request: {} | |
push: | |
branches: | |
- master | |
release: | |
types: [published] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
lint-python: | |
runs-on: ${{ matrix.os }} | |
continue-on-error: true | |
strategy: | |
matrix: | |
python-version: ['3.11'] | |
os: ['ubuntu-20.04'] | |
name: Lint Python | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Install lint dependencies | |
env: | |
# on macOS and with Python 3.10: building NumPy from source fails without these options: | |
NPY_BLAS_ORDER: "" | |
NPY_LAPACK_ORDER: "" | |
run: | | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r test-requirements.txt | |
- name: Lint Python code | |
run: flake8 . --count --ignore=W503,E203 --exclude .git,dist,doc,build,vendors --show-source --statistics --max-line-length 100 | |
- name: Check Python formatting | |
run: black pedalboard tests --line-length 100 --preview --diff --check | |
lint-cpp: | |
runs-on: 'ubuntu-20.04' | |
continue-on-error: true | |
name: Lint C++ | |
steps: | |
- uses: actions/checkout@v2 | |
# Don't check out submodules, as the action below will look at ALL C++ code! | |
- name: Check C++ Formatting | |
uses: jidicula/clang-format-action@v4.4.1 | |
with: | |
clang-format-version: 14 | |
fallback-style: LLVM | |
run-tests: | |
runs-on: ${{ matrix.os }} | |
continue-on-error: false | |
env: | |
MINIMUM_COVERAGE_PERCENTAGE: 80 | |
strategy: | |
matrix: | |
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] | |
# TODO: Switch back to macos-latest once https://github.com/actions/python-versions/pull/114 is fixed | |
os: ['ubuntu-20.04', windows-latest, macos-12] | |
name: Test with Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Install Linux dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update \ | |
&& sudo apt-get install -y pkg-config libsndfile1 \ | |
libx11-dev libxrandr-dev libxinerama-dev \ | |
libxrender-dev libxcomposite-dev libxcb-xinerama0-dev \ | |
libxcursor-dev libfreetype6 libfreetype6-dev | |
- name: Install test dependencies | |
env: | |
# on macOS and with Python 3.10: building NumPy from source fails without these options: | |
NPY_BLAS_ORDER: "" | |
NPY_LAPACK_ORDER: "" | |
run: | | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r test-requirements.txt | |
- name: Install JQ for coverage badge on Linux | |
run: sudo apt-get install -y jq | |
if: runner.os == 'Linux' | |
- name: Install JQ for coverage badge on macOS | |
run: brew install jq | |
if: runner.os == 'macOS' | |
- name: Install JQ for coverage badge on Windows | |
if: runner.os == 'Windows' | |
uses: crazy-max/ghaction-chocolatey@v2 | |
with: | |
args: install jq | |
- name: Build pedalboard locally | |
run: python setup.py develop | |
- name: Install VSTs for testing | |
env: | |
GCS_ASSET_BUCKET_NAME: ${{ secrets.GCS_ASSET_BUCKET_NAME }} | |
GCS_READER_SERVICE_ACCOUNT_KEY: ${{ secrets.GCS_READER_SERVICE_ACCOUNT_KEY }} | |
run: python ./tests/download_test_plugins.py | |
- name: Run tests | |
if: matrix.os != 'ubuntu-20.04' || matrix.python-version != '3.8' | |
run: pytest -v --cov-report term --cov-fail-under=${{ env.MINIMUM_COVERAGE_PERCENTAGE }} --cov=pedalboard --durations=100 | |
- name: Run tests with coverage reporting | |
if: matrix.os == 'ubuntu-20.04' && matrix.python-version == '3.8' | |
run: | | |
pytest -v --cov-report term --cov-fail-under=${{ env.MINIMUM_COVERAGE_PERCENTAGE }} --cov=pedalboard \ | |
&& coverage json --fail-under=${{ env.MINIMUM_COVERAGE_PERCENTAGE }} \ | |
&& jq -r 'def roundit: .*100.0 + 0.5|floor/100.0; .totals.percent_covered | round | "COVERAGE_PERCENTAGE=" + (. | tostring) + "%" ' coverage.json >> $GITHUB_ENV \ | |
&& jq -r 'if .totals.percent_covered > ${{ env.MINIMUM_COVERAGE_PERCENTAGE }} then "COVERAGE_COLOR=green" else "COVERAGE_COLOR=red" end' coverage.json >> $GITHUB_ENV | |
- name: Create coverage badge | |
uses: schneegans/dynamic-badges-action@v1.1.0 | |
if: matrix.os == 'ubuntu-20.04' && matrix.python-version == '3.8' && github.event_name == 'release' && github.event.action == 'published' | |
with: | |
auth: ${{ secrets.COVERAGE_GIST_SECRET }} | |
gistID: 8736467e9952991ef44a67915ee7c762 | |
filename: coverage.json | |
label: Test Coverage | |
message: ${{ env.COVERAGE_PERCENTAGE }} | |
color: ${{ env.COVERAGE_COLOR }} | |
run-tests-with-address-sanitizer: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] | |
os: ['ubuntu-20.04'] | |
name: Test with Python ${{ matrix.python-version }} + Address Sanitizer | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Install Linux dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update \ | |
&& sudo apt-get install -y pkg-config libsndfile1 \ | |
libx11-dev libxrandr-dev libxinerama-dev \ | |
libxrender-dev libxcomposite-dev libxcb-xinerama0-dev \ | |
libxcursor-dev libfreetype6 libfreetype6-dev | |
- name: Install test dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r test-requirements.txt | |
- name: Build pedalboard locally | |
env: | |
DEBUG: "0" | |
USE_ASAN: "1" | |
CC: clang | |
CXX: clang++ | |
run: python setup.py develop | |
- name: Run tests with ASan loaded | |
# pytest can exit before all Python objects have been destroyed, | |
# so we tell ASan to ignore leaks. | |
run: | | |
ASAN_OPTIONS=detect_leaks=0 \ | |
LD_PRELOAD=$(clang -print-file-name=libclang_rt.asan-x86_64.so) \ | |
pytest -v | |
test-docs: | |
runs-on: macos-12 | |
continue-on-error: true | |
needs: [run-tests] | |
name: Ensure docs match auto-generated docs | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Install test dependencies | |
env: | |
# on macOS and with Python 3.10: building NumPy from source fails without these options: | |
NPY_BLAS_ORDER: "" | |
NPY_LAPACK_ORDER: "" | |
run: | | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r test-requirements.txt | |
- name: Build pedalboard locally | |
run: python setup.py develop | |
- name: Generate type stubs and documentation, and validate they match | |
# Only validate documentation on macOS, as Linux and Windows have a subset of the classes | |
# TODO: 3.11.0-rc1 doesn't include type hints when generating type stubs. | |
run: python3 -m scripts.generate_type_stubs_and_docs --check | |
build-wheels: | |
needs: [lint-python, lint-cpp] | |
runs-on: ${{ matrix.os }} | |
continue-on-error: false | |
if: (github.event_name == 'release' && github.event.action == 'published') || contains(github.event.pull_request.labels.*.name, 'Also Test Wheels') | |
strategy: | |
matrix: | |
include: | |
- { os: macos-12, build: cp36-macosx_x86_64 } | |
- { os: macos-12, build: cp37-macosx_x86_64 } | |
- { os: macos-12, build: cp38-macosx_x86_64 } | |
- { os: macos-12, build: cp39-macosx_x86_64 } | |
- { os: macos-12, build: cp310-macosx_x86_64 } | |
- { os: macos-12, build: cp311-macosx_x86_64 } | |
- { os: macos-12, build: cp38-macosx_universal2 } | |
- { os: macos-12, build: cp39-macosx_universal2 } | |
- { os: macos-12, build: cp310-macosx_universal2 } | |
- { os: macos-12, build: cp311-macosx_universal2 } | |
- { os: macos-12, build: cp38-macosx_arm64 } | |
- { os: macos-12, build: cp39-macosx_arm64 } | |
- { os: macos-12, build: cp310-macosx_arm64 } | |
- { os: macos-12, build: cp311-macosx_arm64 } | |
- { os: macos-12, build: pp37-macosx_x86_64 } | |
- { os: macos-12, build: pp38-macosx_x86_64 } | |
- { os: macos-12, build: pp39-macosx_x86_64 } | |
- { os: windows-latest, build: cp36-win_amd64 } | |
- { os: windows-latest, build: cp37-win_amd64 } | |
- { os: windows-latest, build: cp38-win_amd64 } | |
- { os: windows-latest, build: cp39-win_amd64 } | |
- { os: windows-latest, build: cp310-win_amd64 } | |
- { os: windows-latest, build: cp311-win_amd64 } | |
- { os: windows-latest, build: pp37-win_amd64 } | |
- { os: windows-latest, build: pp38-win_amd64 } | |
- { os: windows-latest, build: pp39-win_amd64 } | |
- { os: 'ubuntu-20.04', build: cp36-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: cp36-manylinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: cp37-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: cp37-manylinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: cp38-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: cp38-manylinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: cp39-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: cp39-manylinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: cp310-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: cp310-manylinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: cp310-musllinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: cp310-musllinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: cp311-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: cp311-manylinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: cp311-musllinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: cp311-musllinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: pp37-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: pp37-manylinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: pp38-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: pp38-manylinux_aarch64 } | |
- { os: 'ubuntu-20.04', build: pp39-manylinux_x86_64 } | |
- { os: 'ubuntu-20.04', build: pp39-manylinux_aarch64 } | |
name: Build wheel for ${{ matrix.build }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
# Used to host cibuildwheel, so version doesn't really matter | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Install cibuildwheel | |
run: python -m pip install 'cibuildwheel>=2.11.0' | |
- name: Set up QEMU for aarch64 on Linux | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v1 | |
with: | |
platforms: all | |
- name: Build wheels | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_TEST_REQUIRES: -r test-requirements.txt | |
CIBW_TEST_COMMAND: "pytest {project}/tests" | |
CIBW_BUILD: ${{ matrix.build }} | |
CIBW_ARCHS: auto64 # Only support building 64-bit wheels. It's 2022! | |
CIBW_ARCHS_LINUX: auto64 aarch64 # Useful for building linux images with Apple Silicon | |
CIBW_ARCHS_MACOS: x86_64 universal2 arm64 # Support Apple Silicon | |
# on macOS and with Python 3.10: building NumPy from source fails without these options: | |
CIBW_ENVIRONMENT: NPY_BLAS_ORDER="" NPY_LAPACK_ORDER="" CIBW_BUILD="${{ matrix.build }}" | |
CIBW_REPAIR_WHEEL_COMMAND_LINUX: pip install auditwheel-symbols && (auditwheel repair -w {dest_dir} {wheel} || auditwheel-symbols --manylinux 2010 {wheel}) | |
# The manylinux container doesn't have a new enough glibc version, | |
# so we can't run post-wheel-build tests there. | |
# Also testing any pypy versions fails, as TensorFlow isn't pypy compatible. | |
CIBW_TEST_SKIP: "*manylinux* *pp* *-macosx_universal2:arm64" | |
# Use the minimum macOS deployment target that has C++17 support: | |
MACOSX_DEPLOYMENT_TARGET: "10.13" | |
- uses: actions/upload-artifact@v2 | |
with: | |
path: ./wheelhouse/*.whl | |
upload-pypi: | |
needs: [build-wheels, run-tests-with-address-sanitizer, run-tests] | |
runs-on: 'ubuntu-20.04' | |
name: "Upload wheels to PyPI" | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: artifact | |
path: dist | |
- uses: pypa/gh-action-pypi-publish@v1.4.2 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_DEPLOY_TOKEN }} |