Skip to content

Commit dbb2406

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

File tree

3 files changed

+115
-1
lines changed

3 files changed

+115
-1
lines changed

.github/workflows/build_python.yml

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