Skip to content

Commit 8e99ebb

Browse files
committed
python: add ci and a minimal test
1 parent d057cbe commit 8e99ebb

File tree

3 files changed

+116
-1
lines changed

3 files changed

+116
-1
lines changed

.github/workflows/build_python.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Python
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '**.md'
8+
pull_request:
9+
paths-ignore:
10+
- '**.md'
11+
- 'docs/**'
12+
13+
jobs:
14+
build:
15+
name: ${{ matrix.config.name }}
16+
runs-on: ${{ matrix.config.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
boost: [0, 1]
21+
header_only: [0, 1]
22+
config:
23+
- {
24+
name: "Windows (MSVC)",
25+
os: windows-latest,
26+
generator: "",
27+
cmakeflags: "-DLIBREMIDI_NO_WINUWP=0 -DBOOST_ROOT=$PWD/boost_1_86_0 -DCMAKE_GENERATOR_PLATFORM=version=10.0.22621.0",
28+
environment: ""
29+
}
30+
- {
31+
name: "Ubuntu (gcc)",
32+
os: ubuntu-latest,
33+
generator: "",
34+
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'",
35+
environment: "LD_PRELOAD=libasan.so:libubsan.so"
36+
}
37+
- {
38+
name: "Ubuntu (clang, libstdc++)",
39+
os: ubuntu-latest,
40+
generator: "",
41+
cmakeflags: "-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS='-Werror=return-type -fsanitize=address -fsanitize=undefined'",
42+
environment: ""
43+
}
44+
- {
45+
name: "Ubuntu (clang, libc++)",
46+
os: ubuntu-latest,
47+
generator: "",
48+
cmakeflags: "-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS='-stdlib=libc++ -Werror=return-type'",
49+
environment: ""
50+
}
51+
- {
52+
name: "macOS",
53+
os: macos-14,
54+
generator: "",
55+
cmakeflags: "-DCMAKE_CXX_FLAGS=-Werror=return-type -DBOOST_ROOT=$PWD/boost_1_86_0",
56+
environment: ""
57+
}
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Get latest release version number
63+
id: get_version
64+
uses: dhkatz/get-version-action@main
65+
66+
- uses: maxim-lobanov/setup-xcode@v1
67+
if: runner.os == 'macOS'
68+
with:
69+
xcode-version: latest-stable
70+
71+
- name: Install dependencies
72+
run: |
73+
if [ "$RUNNER_OS" == "Linux" ]; then
74+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
75+
sudo apt update
76+
sudo apt install cmake libboost-dev libasound-dev libjack-jackd2-dev clang libc++-dev
77+
else
78+
curl -L https://github.com/ossia/sdk/releases/download/sdk31/boost_1_86_0.tar.gz > boost.tar.gz
79+
tar -xzf boost.tar.gz
80+
rm boost.tar.gz
81+
fi
82+
shell: bash
83+
84+
- name: Configure
85+
shell: bash
86+
run: |
87+
cmake -S ./bindings/python -B build \
88+
${{ matrix.config.generator }} \
89+
${{ matrix.config.cmakeflags }} \
90+
-DLIBREMIDI_FIND_BOOST=${{ matrix.boost }} \
91+
-DLIBREMIDI_HEADER_ONLY=${{ matrix.header_only }} \
92+
-DLIBREMIDI_CI=1 \
93+
-DCMAKE_INSTALL_PREFIX=install
94+
95+
- name: Build
96+
run: |
97+
cmake --build build --config Debug
98+
99+
- name: Test
100+
shell: bash
101+
run: |
102+
export PYTHONPATH=$PWD/install
103+
${{matrix.environment}} python tests/python/list_apis.py
104+
105+
106+
107+
108+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3.13
1+
#!/usr/bin/env python
22
import pylibremidi as lm
33
observer_config = lm.ObserverConfiguration()
44
observer = lm.Observer(observer_config, lm.midi2_default_api())

tests/python/list_apis.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python
2+
import pylibremidi as lm
3+
lm.available_apis()
4+
lm.available_ump_apis()
5+
lm.get_version()
6+
lm.midi1_default_api()
7+
lm.midi2_default_api()

0 commit comments

Comments
 (0)