Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests CI workflows #6

Merged
merged 11 commits into from
Dec 20, 2023
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Lint

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0
env:
RUFF_OUTPUT_FORMAT: github
118 changes: 118 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Run tests

on:
push:
Natooz marked this conversation as resolved.
Show resolved Hide resolved
branches: [main]
pull_request:
branches: [main]

jobs:
build_wheels:
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
runs-on: ${{ matrix.buildplat[0] }}
strategy:
matrix:
# From wheel.yml of numpy (https://github.com/numpy/numpy/blob/main/.github/workflows/wheels.yml):
# Github Actions doesn't support pairing matrix values together, let's improvise
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
buildplat:
- [ubuntu-22.04, manylinux_x86_64]
- [ubuntu-22.04, musllinux_x86_64]
- [ubuntu-22.04, manylinux_aarch64]
- [ubuntu-22.04, musllinux_aarch64]
- [macos-12, macosx_x86_64]
- [macos-12, macosx_arm64]
- [windows-2022, win_amd64]
- [windows-2022, win32]
python: ["cp39", "cp310", "cp311", "cp312", "pp39"]
exclude:
- buildplat: [windows-2022, win32]
python: "pp39"
- buildplat: [ ubuntu-22.04, musllinux_x86_64 ]
python: "pp39"
- buildplat: [ ubuntu-22.04, musllinux_aarch64 ]
python: "pp39"
- buildplat: [macos-12, macosx_arm64]
python: "pp39"

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Set up QEMU
if: ${{ contains(matrix.buildplat[1], 'linux_aarch64') }}
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Setup MSVC (32-bit)
if: ${{ matrix.buildplat[1] == 'win32' }}
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
with:
architecture: 'x86'

- name: Build wheels for manylinux x86_64
if: ${{ matrix.buildplat[1] == 'manylinux_x86_64' }}
uses: pypa/cibuildwheel@v2.16.1
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64
CIBW_ARCHS: 'all'

- name: Build wheels for manylinux aarch64
if: ${{ matrix.buildplat[1] == 'manylinux_aarch64' }}
uses: pypa/cibuildwheel@v2.16.1
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64
CIBW_ARCHS: 'all'

- name: Build wheels for musllinux x86_64
if: ${{ matrix.buildplat[1] == 'musllinux_x86_64' }}
uses: pypa/cibuildwheel@v2.16.1
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
CIBW_MUSLLINUX_X86_64_IMAGE: quay.io/pypa/musllinux_1_2_x86_64
CIBW_ARCHS: 'all'

- name: Build wheels for musllinux aarch64
if: ${{ matrix.buildplat[1] == 'musllinux_aarch64' }}
uses: pypa/cibuildwheel@v2.16.1
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
CIBW_MUSLLINUX_AARCH64_IMAGE: quay.io/pypa/musllinux_1_2_aarch64
CIBW_ARCHS: 'all'

- name: Build wheels
if: ${{ !contains(matrix.buildplat[1], 'linux') }}
uses: pypa/cibuildwheel@v2.16.1
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
CIBW_ARCHS: 'all'

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
2 changes: 1 addition & 1 deletion tests/test_read_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_load_dump(midi_path, tmp_path):
midi2 = Score(dump_path) # Loading it back

# Sorting the notes, as after dump the order might have changed
for track1, track2 in zip(midi1.instruments, midi2.instruments):
for track1, track2 in zip(midi1.tracks, midi2.tracks):
track1.notes.sort(key=lambda x: (x.start, x.pitch, x.end, x.velocity))
track2.notes.sort(key=lambda x: (x.start, x.pitch, x.end, x.velocity))

Expand Down
Loading