forked from Boddlnagg/midir
-
Notifications
You must be signed in to change notification settings - Fork 6
244 lines (209 loc) · 9.6 KB
/
ci.yml
File metadata and controls
244 lines (209 loc) · 9.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
name: CI
on:
pull_request:
push:
branches: "**"
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
build-stable:
name: Build (stable) — ${{ matrix.name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow_fail || false }}
strategy:
fail-fast: false
matrix:
include:
- { name: Linux (ALSA), os: ubuntu-latest, target: x86_64-unknown-linux-gnu, features: "", setup: linux-alsa }
- { name: Linux (JACK), os: ubuntu-latest, target: x86_64-unknown-linux-gnu, features: "jack", setup: linux-jack }
- { name: Linux (WASM), os: ubuntu-latest, target: wasm32-unknown-unknown, features: "", setup: wasm }
- { name: Windows (MSVC / WinMM), os: windows-latest, target: x86_64-pc-windows-msvc, features: "", setup: windows-msvc }
- { name: Windows (MSVC / WinRT), os: windows-latest, target: x86_64-pc-windows-msvc, features: "winrt", setup: windows-msvc }
- { name: Windows (GNU i686 / WinMM), os: windows-latest, target: i686-pc-windows-gnu, features: "", setup: windows-gnu }
- { name: Windows (GNU i686 / WinRT), os: windows-latest, target: i686-pc-windows-gnu, features: "winrt", setup: windows-gnu, allow_fail: true }
- { name: macOS (CoreMIDI), os: macos-latest, target: "", features: "", setup: macos }
- { name: macOS (JACK), os: macos-latest, target: "", features: "jack", setup: macos-jack, allow_fail: true }
- { name: iOS (Mac Catalyst aarch64-apple-ios-macabi), os: macos-latest, target: aarch64-apple-ios-macabi, features: "", setup: ios-macabi }
- { name: Linux (aarch64-unknown-linux-gnu), os: ubuntu-latest, target: aarch64-unknown-linux-gnu, features: "", setup: linux-aarch64 }
- { name: Windows (ARM64 MSVC), os: windows-latest, target: aarch64-pc-windows-msvc, features: "", setup: windows-msvc }
- { name: Android (aarch64/armv7/x86_64/i686; API 29), os: ubuntu-latest, target: "", features: "", setup: android }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
- name: Check format
run: cargo fmt --all -- --check
- name: Setup Linux dependencies
if: runner.os == 'Linux' && matrix.setup != 'linux-aarch64' && matrix.setup != 'wasm' && matrix.setup != 'android'
run: |
sudo apt-get update && sudo apt-get install -y libasound2-dev pkg-config
if [[ "${{ matrix.setup }}" == "linux-jack" ]]; then
sudo apt-get install -y libjack-jackd2-dev
fi
- name: Setup WASM
if: matrix.setup == 'wasm'
run: rustup target add wasm32-unknown-unknown
- name: Install Chrome for WASM tests
if: matrix.setup == 'wasm'
uses: browser-actions/setup-chrome@v2
with:
chrome-version: stable
install-dependencies: true
- name: Install wasm-pack
if: matrix.setup == 'wasm'
run: curl -sSf https://rustwasm.github.io/wasm-pack/installer/init.sh | sh -s -- -f
- name: Setup Linux aarch64 (cross-compile)
if: matrix.setup == 'linux-aarch64'
run: |
set -euxo pipefail
rustup target add aarch64-unknown-linux-gnu
sudo dpkg --add-architecture arm64
cat <<'EOF' | sudo tee /etc/apt/sources.list.d/ubuntu-arm64.sources
Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports
Suites: noble noble-updates noble-backports noble-security
Components: main restricted universe multiverse
Architectures: arm64
EOF
sudo sed -Ei 's|^Types: deb|Types: deb\nArchitectures: amd64|' \
/etc/apt/sources.list.d/ubuntu.sources
sudo apt-get update
sudo apt-get install -y \
gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross \
pkg-config \
libasound2-dev:arm64 \
libjack-jackd2-dev:arm64
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
- name: Setup Windows MSVC toolchain
if: matrix.setup == 'windows-msvc'
run: |
rustup update stable
if [ -n "${{ matrix.target }}" ]; then rustup target add ${{ matrix.target }}; fi
shell: bash
- name: Setup Windows GNU toolchain
if: matrix.setup == 'windows-gnu'
uses: msys2/setup-msys2@v2
with:
install: >-
base-devel
mingw-w64-i686-toolchain
msystem: MINGW32
update: true
- name: Setup macOS JACK
if: matrix.setup == 'macos-jack'
run: |
brew install jack
echo "PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig:/usr/local/lib/pkgconfig" >> $GITHUB_ENV
- name: Start JACK (macOS)
if: matrix.setup == 'macos-jack'
run: |
jackd -d dummy >/tmp/jack.log 2>&1 & disown
sleep 2
- name: Setup iOS (Mac Catalyst)
if: matrix.setup == 'ios-macabi'
run: rustup target add aarch64-apple-ios-macabi
- name: Setup Android NDK
if: matrix.setup == 'android'
uses: nttld/setup-ndk@v1
with:
ndk-version: r26d
local-cache: true
- name: Export ANDROID_NDK_HOME for cargo-ndk
if: matrix.setup == 'android'
run: echo "ANDROID_NDK_HOME=${ANDROID_NDK_HOME:-$NDK_HOME}" >> $GITHUB_ENV
- name: Install cargo-ndk and Android targets
if: matrix.setup == 'android'
run: |
cargo install cargo-ndk --locked
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
- name: Build (standard)
if: matrix.setup != 'windows-gnu' && matrix.setup != 'android' && matrix.setup != 'wasm'
run: |
if [ -n "${{ matrix.target }}" ]; then
cargo build --verbose --target ${{ matrix.target }} ${{ matrix.features && format('--features {0}', matrix.features) }}
else
cargo build --verbose ${{ matrix.features && format('--features {0}', matrix.features) }}
fi
shell: bash
- name: Build (Windows GNU)
if: matrix.setup == 'windows-gnu'
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$USERPROFILE")/.cargo/bin:$PATH"
rustup update stable
rustup target add ${{ matrix.target }}
export CARGO_TARGET_I686_PC_WINDOWS_GNU_LINKER=i686-w64-mingw32-gcc
export CARGO_TARGET_I686_PC_WINDOWS_GNU_AR=i686-w64-mingw32-ar
cargo build --verbose --target ${{ matrix.target }} ${{ matrix.features && format('--features {0}', matrix.features) }}
- name: Build (Android via cargo-ndk, API 29)
if: matrix.setup == 'android'
run: |
cargo ndk \
--platform 29 \
--target aarch64-linux-android \
--target armv7-linux-androideabi \
--target x86_64-linux-android \
--target i686-linux-android \
build --verbose
- name: Build WASM
if: matrix.setup == 'wasm'
run: cargo build --verbose --target wasm32-unknown-unknown ${{ matrix.features && format('--features {0}', matrix.features) }}
- name: Build WASM example (browser)
if: matrix.setup == 'wasm' && hashFiles('examples/browser/Cargo.toml') != ''
run: |
cd examples/browser
wasm-pack build --target=no-modules --dev
- name: Test WASM
if: matrix.setup == 'wasm'
run: wasm-pack test --chrome --headless
- name: Start JACK (Linux)
if: runner.os == 'Linux' && matrix.setup == 'linux-jack'
run: |
sudo apt-get update
sudo apt-get install -y jackd2
jackd -d dummy >/tmp/jack.log 2>&1 & disown
sleep 2
shell: bash
- name: Test (Linux JACK)
if: runner.os == 'Linux' && matrix.setup == 'linux-jack'
run: cargo test --verbose ${{ matrix.features && format('--features {0}', matrix.features) }}
shell: bash
- name: Test (Linux ALSA with gating)
if: runner.os == 'Linux' && matrix.setup == 'linux-alsa'
run: |
FEATURES='${{ matrix.features && format('--features {0}', matrix.features) }}'
if [ -e /dev/snd/seq ]; then
echo "ALSA sequencer present; running full tests"
cargo test --verbose ${FEATURES}
else
echo "ALSA sequencer not available; skipping end_to_end"
cargo test --verbose ${FEATURES} -- --skip end_to_end
fi
shell: bash
- name: Test (non-Linux hosted targets)
if: >
runner.os != 'Linux' &&
(matrix.target == '' ||
matrix.target == 'x86_64-pc-windows-msvc' ||
startsWith(matrix.name, 'macOS')) &&
matrix.setup != 'windows-gnu'
run: cargo test --verbose ${{ matrix.features && format('--features {0}', matrix.features) }}
- name: Test (Windows GNU)
if: matrix.setup == 'windows-gnu'
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$USERPROFILE")/.cargo/bin:$PATH"
export CARGO_TARGET_I686_PC_WINDOWS_GNU_LINKER=i686-w64-mingw32-gcc
export CARGO_TARGET_I686_PC_WINDOWS_GNU_AR=i686-w64-mingw32-ar
cargo test --verbose --target ${{ matrix.target }} ${{ matrix.features && format('--features {0}', matrix.features) }}