Skip to content

tests: Fix input_signal variable in test_returned_sample_count being too short #1315

tests: Fix input_signal variable in test_returned_sample_count being too short

tests: Fix input_signal variable in test_returned_sample_count being too short #1315

Workflow file for this run

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/[email protected]
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', '3.12']
os: ['ubuntu-20.04', windows-latest, macos-latest]
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
# TensorFlow is an optional dependency; if present, we'll run tests with it:
# There are no environment specifiers to select when TensorFlow binaries are available.
pip install tensorflow==2.13 || true
- 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/[email protected]
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
# TensorFlow is an optional dependency; if present, we'll run tests with it:
# There are no environment specifiers to select when TensorFlow binaries are available.
pip install tensorflow==2.13 || true
- 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
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: cp312-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: cp312-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: cp312-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: cp312-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: cp38-musllinux_x86_64 }
- { os: 'ubuntu-20.04', build: cp38-musllinux_aarch64 }
- { os: 'ubuntu-20.04', build: cp39-manylinux_x86_64 }
- { os: 'ubuntu-20.04', build: cp39-manylinux_aarch64 }
- { os: 'ubuntu-20.04', build: cp39-musllinux_x86_64 }
- { os: 'ubuntu-20.04', build: cp39-musllinux_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: cp312-manylinux_x86_64 }
- { os: 'ubuntu-20.04', build: cp312-manylinux_aarch64 }
- { os: 'ubuntu-20.04', build: cp312-musllinux_x86_64 }
- { os: 'ubuntu-20.04', build: cp312-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.
# The musllinux containers on aarch64 take 6+ hours to test.
# Also testing any pypy versions fails, as TensorFlow isn't pypy compatible.
CIBW_TEST_SKIP: "*manylinux* *musllinux_aarch* *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/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_DEPLOY_TOKEN }}