Skip to content

Commit

Permalink
python: add ci and a minimal test
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Mar 1, 2025
1 parent d057cbe commit dbb2406
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
107 changes: 107 additions & 0 deletions .github/workflows/build_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Python

on:
push:
paths-ignore:
- 'docs/**'
- '**.md'
pull_request:
paths-ignore:
- '**.md'
- 'docs/**'

jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
header_only: [0, 1]
config:
- {
name: "Windows (MSVC)",
os: windows-latest,
generator: "",
cmakeflags: "-DLIBREMIDI_NO_WINUWP=0 -DBOOST_ROOT=$PWD/boost_1_86_0 -DCMAKE_GENERATOR_PLATFORM=version=10.0.22621.0",
environment: ""
}
- {
name: "Ubuntu (gcc)",
os: ubuntu-latest,
generator: "",
cmakeflags: "-DCMAKE_CXX_FLAGS='-Werror=return-type -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1 -D_GLIBCXX_ASSERTIONS=1 -D_GLIBCXX_SANITIZE_VECTOR=1'",
environment: "LD_PRELOAD=libasan.so:libubsan.so"
}
- {
name: "Ubuntu (clang, libstdc++)",
os: ubuntu-latest,
generator: "",
cmakeflags: "-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS='-Werror=return-type -fsanitize=address -fsanitize=undefined'",
environment: ""
}
- {
name: "Ubuntu (clang, libc++)",
os: ubuntu-latest,
generator: "",
cmakeflags: "-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS='-stdlib=libc++ -Werror=return-type'",
environment: ""
}
- {
name: "macOS",
os: macos-14,
generator: "",
cmakeflags: "-DCMAKE_CXX_FLAGS=-Werror=return-type -DBOOST_ROOT=$PWD/boost_1_86_0",
environment: ""
}

steps:
- uses: actions/checkout@v4

- name: Get latest release version number
id: get_version
uses: dhkatz/get-version-action@main

- uses: maxim-lobanov/setup-xcode@v1
if: runner.os == 'macOS'
with:
xcode-version: latest-stable

- name: Install dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt update
sudo apt install cmake libboost-dev libasound-dev libjack-jackd2-dev clang libc++-dev
else
curl -L https://github.com/ossia/sdk/releases/download/sdk31/boost_1_86_0.tar.gz > boost.tar.gz
tar -xzf boost.tar.gz
rm boost.tar.gz
fi
shell: bash

- name: Configure
shell: bash
run: |
cmake -S ./bindings/python -B build \
${{ matrix.config.generator }} \
${{ matrix.config.cmakeflags }} \
-DLIBREMIDI_FIND_BOOST=1 \
-DLIBREMIDI_HEADER_ONLY=${{ matrix.header_only }} \
-DLIBREMIDI_CI=1 \
-DCMAKE_INSTALL_PREFIX=install
- name: Build
run: |
cmake --build build --config Debug
- name: Test
shell: bash
run: |
export PYTHONPATH=$PWD/install
${{matrix.environment}} python tests/python/list_apis.py
2 changes: 1 addition & 1 deletion bindings/python/test.py → bindings/python/example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.13
#!/usr/bin/env python
import pylibremidi as lm
observer_config = lm.ObserverConfiguration()
observer = lm.Observer(observer_config, lm.midi2_default_api())
Expand Down
7 changes: 7 additions & 0 deletions tests/python/list_apis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python
import pylibremidi as lm
lm.available_apis()
lm.available_ump_apis()
lm.get_version()
lm.midi1_default_api()
lm.midi2_default_api()

0 comments on commit dbb2406

Please sign in to comment.