forked from RustAudio/cpal
-
Notifications
You must be signed in to change notification settings - Fork 0
366 lines (303 loc) · 10.6 KB
/
Copy pathcpal.yml
File metadata and controls
366 lines (303 loc) · 10.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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
name: cpal
on:
push:
branches: [master]
paths-ignore:
- "**.md"
- "docs/**"
- "LICENSE*"
- ".gitignore"
- "Dockerfile*"
- "Cross.toml"
pull_request:
branches: [master]
paths-ignore:
- "**.md"
- "docs/**"
- "LICENSE*"
- ".gitignore"
- "Dockerfile*"
- "Cross.toml"
release:
types: [published]
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Cache Linux audio packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libasound2-dev libjack-jackd2-dev libjack-jackd2-0 libdbus-1-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
targets: armv7-linux-androideabi
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy --all --all-features
- name: Run clippy for Android target
run: cargo clippy --all --features asio --target armv7-linux-androideabi
cargo-publish:
if: github.event_name == 'release'
needs: [test-native, test-cross, test-wasm, test-android, test-ios, test-windows-versions]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Cache Linux audio packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libasound2-dev libjack-jackd2-dev libjack-jackd2-0 libdbus-1-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
# Verify the release tag matches Cargo.toml version
- name: Verify release version
run: |
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
RELEASE_VERSION=${GITHUB_REF#refs/tags/v}
echo "Cargo.toml version: $CARGO_VERSION"
echo "Release tag version: $RELEASE_VERSION"
if [ "$CARGO_VERSION" != "$RELEASE_VERSION" ]; then
echo "Version mismatch! Cargo.toml has $CARGO_VERSION but release tag is v$RELEASE_VERSION"
exit 1
fi
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CRATESIO_TOKEN }}
# Native platform testing
test-native:
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- os: ubuntu-latest
name: linux-x64
# Linux ARM64 native
- os: ubuntu-24.04-arm
name: linux-arm64
# Windows x86_64
- os: windows-latest
name: windows-x64
target: x86_64-pc-windows-msvc
deps: |
curl -L -o asio.zip https://www.steinberg.net/asiosdk
7z x -oasio asio.zip
move asio\*\* asio\
choco install asio4all
choco install llvm
asio-env: true
# Windows i686
- os: windows-latest
name: windows-x86
target: i686-pc-windows-msvc
deps: |
curl -L -o asio.zip https://www.steinberg.net/asiosdk
7z x -oasio asio.zip
move asio\*\* asio\
choco install asio4all
choco install llvm
asio-env: true
# macOS (ARM64 M1/M2)
- os: macOS-latest
name: macos-arm64
deps: brew install llvm
build-beep: true
runs-on: ${{ matrix.os }}
name: test-${{ matrix.name }}
steps:
- uses: actions/checkout@v5
- name: Cache Linux audio packages
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libasound2-dev libjack-jackd2-dev libjack-jackd2-0 libdbus-1-dev
- name: Install non-Linux dependencies
if: runner.os != 'Linux'
run: ${{ matrix.deps }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build beep example (macOS only)
if: matrix.build-beep
run: cargo build --example beep
- name: Run tests without features
run: cargo test --all --no-default-features --verbose
- name: Run tests with all features
shell: bash
run: |
if [[ "${{ matrix.asio-env }}" == "true" ]]; then
export CPAL_ASIO_DIR="$GITHUB_WORKSPACE/asio"
fi
cargo test --all --all-features --verbose
# Cross-compilation for architectures without native runners
test-cross:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [armv7-unknown-linux-gnueabihf]
steps:
- uses: actions/checkout@v5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: cross-${{ matrix.target }}
- name: Install cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Test without features
run: cross test --target ${{ matrix.target }} --workspace --no-default-features --verbose
- name: Test all features
run: cross test --target ${{ matrix.target }} --workspace --all-features --verbose
# WebAssembly builds
test-wasm:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: wasm32-unknown-emscripten
setup-emscripten: true
args: --release
- target: wasm32-unknown-unknown
setup-emscripten: false
args: --features=wasm-bindgen
build-wasm-beep: true
- target: wasm32-wasip1
setup-emscripten: false
args: ""
steps:
- uses: actions/checkout@v5
- name: Setup Emscripten toolchain
if: matrix.setup-emscripten
uses: mymindstorm/setup-emsdk@v14
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: wasm-${{ matrix.target }}
- name: Build beep example
run: cargo build --example beep --target ${{ matrix.target }} ${{ matrix.args }}
- name: Build wasm-beep example
if: matrix.build-wasm-beep
working-directory: ./examples/wasm-beep
run: cargo build --target ${{ matrix.target }}
# Android cross-compilation
test-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Rust toolchain (Android targets)
uses: dtolnay/rust-toolchain@stable
with:
targets: armv7-linux-androideabi,aarch64-linux-android,i686-linux-android,x86_64-linux-android
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: android
- name: Check Android examples
run: |
cargo check --example beep --target armv7-linux-androideabi --verbose
cargo check --example enumerate --target armv7-linux-androideabi --verbose
cargo check --example feedback --target armv7-linux-androideabi --verbose
cargo check --example record_wav --target armv7-linux-androideabi --verbose
- name: Check Android project
working-directory: examples/android
run: cargo check --target armv7-linux-androideabi --verbose
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: platforms;android-30 build-tools;30.0.3
- name: Install cargo-apk
uses: taiki-e/install-action@v2
with:
tool: cargo-apk
- name: Build APK
working-directory: examples/android
run: cargo apk build
# iOS cross-compilation
test-ios:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v5
- name: Install dependencies
run: brew install llvm
- name: Install Rust toolchain (iOS targets)
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios,x86_64-apple-ios
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: ios
- name: Install cargo-lipo
uses: taiki-e/install-action@v2
with:
tool: cargo-lipo
- name: Build iOS example
run: cd examples/ios-feedback && xcodebuild -scheme cpal-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator
# Windows crate compatibility testing
test-windows-versions:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- windows-version: "0.61.3"
# Skip 0.62.x since we already test current version in test-native
name: test-windows-v${{ matrix.windows-version }}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
run: |
choco install llvm
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: windows-v${{ matrix.windows-version }}
- name: Lock windows crate to specific version
shell: bash
run: |
# Generate Cargo.lock first if it doesn't exist
cargo generate-lockfile
# Use cargo update --precise to lock the windows crate to a specific version
cargo update --precise ${{ matrix.windows-version }} windows
# Remove and re-add `windows-core` to force Cargo to re-resolve it
# I'd prefer a more surgical approach, but things get complicated once multiple `windows-core`
# versions are in play
cargo rm --target='cfg(target_os = "windows")' windows-core
cargo add --target='cfg(target_os = "windows")' windows-core@*
# Verify the version was locked correctly
echo "Locked windows crate version:"
cargo tree | grep "windows v" || echo "Windows crate not found in dependency tree"
# Also check Cargo.lock
echo "Cargo.lock entry:"
grep -A 5 "name = \"windows\"" Cargo.lock | head -10
- name: Check WASAPI with windows v${{ matrix.windows-version }}
run: |
cargo check --verbose