Skip to content

Commit 7955f29

Browse files
author
Maxime LUCE
committed
ci: use cross
1 parent 341f85e commit 7955f29

2 files changed

Lines changed: 110 additions & 93 deletions

File tree

.github/workflows/CI.yml

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- uses: actions/checkout@v6
32+
- name: install system deps
33+
run: sudo apt install libasound2-dev libpulse-dev
3234
- name: setup pnpm
3335
uses: pnpm/action-setup@v4
3436
- name: Setup node
@@ -64,22 +66,22 @@ jobs:
6466
target: i686-pc-windows-msvc
6567
- host: ubuntu-latest
6668
target: x86_64-unknown-linux-gnu
67-
build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross
69+
build: pnpm build --target x86_64-unknown-linux-gnu
6870
- host: ubuntu-latest
6971
target: x86_64-unknown-linux-musl
70-
build: pnpm build --target x86_64-unknown-linux-musl -x
72+
build: pnpm build --target x86_64-unknown-linux-musl --use-cross
7173
- host: macos-latest
7274
target: aarch64-apple-darwin
7375
build: pnpm build --target aarch64-apple-darwin
74-
- host: ubuntu-latest
76+
- host: ubuntu-24.04-arm
7577
target: aarch64-unknown-linux-gnu
76-
build: pnpm build --target aarch64-unknown-linux-gnu --use-napi-cross
78+
build: pnpm build --target aarch64-unknown-linux-gnu
7779
- host: ubuntu-latest
7880
target: armv7-unknown-linux-gnueabihf
79-
build: pnpm build --target armv7-unknown-linux-gnueabihf --use-napi-cross
80-
- host: ubuntu-latest
81-
target: aarch64-unknown-linux-musl
82-
build: pnpm build --target aarch64-unknown-linux-musl -x
81+
build: pnpm build --target armv7-unknown-linux-gnueabihf --use-cross
82+
# - host: ubuntu-latest
83+
# target: aarch64-unknown-linux-musl
84+
# build: pnpm build --target aarch64-unknown-linux-musl --use-cross
8385
- host: windows-latest
8486
target: aarch64-pc-windows-msvc
8587
build: pnpm build --target aarch64-pc-windows-msvc
@@ -110,20 +112,18 @@ jobs:
110112
.cargo-cache
111113
target/
112114
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
113-
- uses: mlugg/setup-zig@v2
114-
if: ${{ contains(matrix.settings.target, 'musl') }}
115-
with:
116-
version: 0.15.2
117-
- name: Install cargo-zigbuild
115+
- name: Install cross
118116
uses: taiki-e/install-action@v2
119-
if: ${{ contains(matrix.settings.target, 'musl') }}
117+
if: ${{ contains(matrix.settings.build, '--use-cross') }}
120118
env:
121119
GITHUB_TOKEN: ${{ github.token }}
122120
with:
123-
tool: cargo-zigbuild
124-
- name: Install libasound2-dev
125-
run: sudo apt install libasound2-dev
126-
if: ${{ contains(matrix.settings.target, 'linux') }}
121+
tool: cross
122+
- name: Install libasound / libpulse
123+
run: |
124+
sudo apt update
125+
sudo apt install libasound2-dev libpulse-dev
126+
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' || matrix.settings.target == 'aarch64-unknown-linux-gnu' }}
127127
- name: Setup toolchain
128128
run: ${{ matrix.settings.setup }}
129129
if: ${{ matrix.settings.setup }}
@@ -208,9 +208,9 @@ jobs:
208208
fail-fast: false
209209
matrix:
210210
settings:
211-
- host: windows-latest
212-
target: x86_64-pc-windows-msvc
213-
architecture: x64
211+
# - host: windows-latest
212+
# target: x86_64-pc-windows-msvc
213+
# architecture: x64
214214
- host: macos-latest
215215
target: x86_64-apple-darwin
216216
architecture: x64
@@ -244,85 +244,85 @@ jobs:
244244
shell: bash
245245
- name: Test bindings
246246
run: pnpm test
247-
test-linux-binding:
248-
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
249-
needs:
250-
- build
251-
strategy:
252-
fail-fast: false
253-
matrix:
254-
target:
255-
- x86_64-unknown-linux-gnu
256-
- x86_64-unknown-linux-musl
257-
- aarch64-unknown-linux-gnu
258-
- aarch64-unknown-linux-musl
259-
- armv7-unknown-linux-gnueabihf
260-
node:
261-
- "20"
262-
- "22"
263-
- "24"
264-
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
265-
steps:
266-
- uses: actions/checkout@v6
267-
- name: setup pnpm
268-
uses: pnpm/action-setup@v4
269-
- name: Setup node
270-
uses: actions/setup-node@v6
271-
with:
272-
node-version: ${{ matrix.node }}
273-
cache: pnpm
274-
- name: Output docker params
275-
id: docker
276-
run: |
277-
node -e "
278-
if ('${{ matrix.target }}'.startsWith('aarch64')) {
279-
console.log('PLATFORM=linux/arm64')
280-
} else if ('${{ matrix.target }}'.startsWith('armv7')) {
281-
console.log('PLATFORM=linux/arm/v7')
282-
} else {
283-
console.log('PLATFORM=linux/amd64')
284-
}
285-
" >> $GITHUB_OUTPUT
286-
node -e "
287-
if ('${{ matrix.target }}'.endsWith('-musl')) {
288-
console.log('IMAGE=node:${{ matrix.node }}-alpine')
289-
} else {
290-
console.log('IMAGE=node:${{ matrix.node }}-slim')
291-
}
292-
" >> $GITHUB_OUTPUT
293-
echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
294-
- name: Install dependencies
295-
run: pnpm install --force
296-
- name: Download artifacts
297-
uses: actions/download-artifact@v8
298-
with:
299-
name: bindings-${{ matrix.target }}
300-
path: .
301-
- name: List packages
302-
run: ls -R .
303-
shell: bash
304-
- name: Set up QEMU
305-
uses: docker/setup-qemu-action@v4
306-
if: ${{ contains(matrix.target, 'armv7') }}
307-
with:
308-
platforms: all
309-
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
310-
if: ${{ contains(matrix.target, 'armv7') }}
311-
- name: Test bindings
312-
uses: tj-actions/docker-run@v2
313-
with:
314-
image: ${{ steps.docker.outputs.IMAGE }}
315-
name: test-binding
316-
options: "-v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}"
317-
args: npm run test
247+
# test-linux-binding:
248+
# name: Test ${{ matrix.target }} - node@${{ matrix.node }}
249+
# needs:
250+
# - build
251+
# strategy:
252+
# fail-fast: false
253+
# matrix:
254+
# target:
255+
# - x86_64-unknown-linux-gnu
256+
# - x86_64-unknown-linux-musl
257+
# - aarch64-unknown-linux-gnu
258+
# - aarch64-unknown-linux-musl
259+
# - armv7-unknown-linux-gnueabihf
260+
# node:
261+
# - "20"
262+
# - "22"
263+
# - "24"
264+
# runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
265+
# steps:
266+
# - uses: actions/checkout@v6
267+
# - name: setup pnpm
268+
# uses: pnpm/action-setup@v4
269+
# - name: Setup node
270+
# uses: actions/setup-node@v6
271+
# with:
272+
# node-version: ${{ matrix.node }}
273+
# cache: pnpm
274+
# - name: Output docker params
275+
# id: docker
276+
# run: |
277+
# node -e "
278+
# if ('${{ matrix.target }}'.startsWith('aarch64')) {
279+
# console.log('PLATFORM=linux/arm64')
280+
# } else if ('${{ matrix.target }}'.startsWith('armv7')) {
281+
# console.log('PLATFORM=linux/arm/v7')
282+
# } else {
283+
# console.log('PLATFORM=linux/amd64')
284+
# }
285+
# " >> $GITHUB_OUTPUT
286+
# node -e "
287+
# if ('${{ matrix.target }}'.endsWith('-musl')) {
288+
# console.log('IMAGE=node:${{ matrix.node }}-alpine')
289+
# } else {
290+
# console.log('IMAGE=node:${{ matrix.node }}-slim')
291+
# }
292+
# " >> $GITHUB_OUTPUT
293+
# echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
294+
# - name: Install dependencies
295+
# run: pnpm install --force
296+
# - name: Download artifacts
297+
# uses: actions/download-artifact@v8
298+
# with:
299+
# name: bindings-${{ matrix.target }}
300+
# path: .
301+
# - name: List packages
302+
# run: ls -R .
303+
# shell: bash
304+
# - name: Set up QEMU
305+
# uses: docker/setup-qemu-action@v4
306+
# if: ${{ contains(matrix.target, 'armv7') }}
307+
# with:
308+
# platforms: all
309+
# - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
310+
# if: ${{ contains(matrix.target, 'armv7') }}
311+
# - name: Test bindings
312+
# uses: tj-actions/docker-run@v2
313+
# with:
314+
# image: ${{ steps.docker.outputs.IMAGE }}
315+
# name: test-binding
316+
# options: "-v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}"
317+
# args: npm run test
318318
publish:
319319
name: Publish
320320
runs-on: ubuntu-latest
321321
needs:
322322
- lint
323323
# - build-freebsd
324324
- test-macOS-windows-binding
325-
- test-linux-binding
325+
# - test-linux-binding
326326
steps:
327327
- uses: actions/checkout@v6
328328
- name: setup pnpm

Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,20 @@ napi-build = "2"
1919
lto = true
2020
codegen-units = 1
2121
strip = "symbols"
22+
23+
[package.metadata.cross.target.x86_64-unknown-linux-musl]
24+
pre-build = [
25+
"apt-get update && apt-get --assume-yes install libasound2-dev libpulse-dev",
26+
]
27+
28+
[package.metadata.cross.target.armv7-unknown-linux-gnueabihf]
29+
pre-build = [
30+
"dpkg --add-architecture $CROSS_DEB_ARCH",
31+
"apt-get update && apt-get --assume-yes install libasound2-dev:$CROSS_DEB_ARCH libpulse-dev:$CROSS_DEB_ARCH",
32+
]
33+
34+
[package.metadata.cross.target.aarch64-unknown-linux-musl]
35+
pre-build = [
36+
"dpkg --add-architecture arm64",
37+
"apt-get update && apt-get --assume-yes install libasound2-dev:arm64 libpulse-dev:arm64",
38+
]

0 commit comments

Comments
 (0)