Skip to content

Commit 892d580

Browse files
committed
chore: update workflow
1 parent 000ab7d commit 892d580

File tree

1 file changed

+108
-53
lines changed

1 file changed

+108
-53
lines changed

.github/workflows/CI.yml

Lines changed: 108 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: CI
22
env:
33
DEBUG: napi:*
4+
APP_NAME: binarystream
45
MACOSX_DEPLOYMENT_TARGET: '10.13'
6+
CARGO_INCREMENTAL: '1'
57
permissions:
68
contents: write
79
id-token: write
810
'on':
911
push:
1012
branches:
1113
- main
12-
- dev/arm64
1314
tags-ignore:
1415
- '**'
1516
paths-ignore:
@@ -19,38 +20,63 @@ permissions:
1920
- .editorconfig
2021
- docs/**
2122
pull_request: null
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
2226
jobs:
27+
lint:
28+
name: Lint
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Setup node
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 22
36+
cache: yarn
37+
- name: Install
38+
uses: dtolnay/rust-toolchain@stable
39+
with:
40+
components: clippy, rustfmt
41+
- name: Install dependencies
42+
run: yarn install
43+
- name: Oxlint
44+
run: yarn lint
45+
- name: Cargo fmt
46+
run: cargo fmt -- --check
47+
- name: Clippy
48+
run: cargo clippy
2349
build:
2450
strategy:
2551
fail-fast: false
2652
matrix:
2753
settings:
2854
- host: macos-latest
2955
target: x86_64-apple-darwin
30-
build: yarn build
31-
- host: macos-latest
32-
target: aarch64-apple-darwin
33-
build: yarn build
56+
build: yarn build --target x86_64-apple-darwin
3457
- host: windows-latest
35-
build: yarn build
58+
build: yarn build --target x86_64-pc-windows-msvc
3659
target: x86_64-pc-windows-msvc
3760
- host: ubuntu-latest
3861
target: x86_64-unknown-linux-gnu
39-
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
40-
build: yarn build --target x86_64-unknown-linux-gnu
41-
name: stable - ${{ matrix.settings.target }} - node@20
62+
build: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross
63+
- host: macos-latest
64+
target: aarch64-apple-darwin
65+
build: yarn build --target aarch64-apple-darwin
66+
- host: ubuntu-latest
67+
target: aarch64-unknown-linux-gnu
68+
build: yarn build --target aarch64-unknown-linux-gnu --use-napi-cross
69+
name: stable - ${{ matrix.settings.target }} - node@22
4270
runs-on: ${{ matrix.settings.host }}
4371
steps:
4472
- uses: actions/checkout@v4
4573
- name: Setup node
4674
uses: actions/setup-node@v4
47-
if: ${{ !matrix.settings.docker }}
4875
with:
49-
node-version: 20
76+
node-version: 22
5077
cache: yarn
5178
- name: Install
5279
uses: dtolnay/rust-toolchain@stable
53-
if: ${{ !matrix.settings.docker }}
5480
with:
5581
toolchain: stable
5682
targets: ${{ matrix.settings.target }}
@@ -61,46 +87,37 @@ jobs:
6187
~/.cargo/registry/index/
6288
~/.cargo/registry/cache/
6389
~/.cargo/git/db/
90+
~/.napi-rs
6491
.cargo-cache
6592
target/
6693
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
6794
- uses: goto-bus-stop/setup-zig@v2
68-
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
95+
if: ${{ contains(matrix.settings.target, 'musl') }}
96+
with:
97+
version: 0.14.1
98+
- name: Install cargo-zigbuild
99+
uses: taiki-e/install-action@v2
100+
if: ${{ contains(matrix.settings.target, 'musl') }}
101+
env:
102+
GITHUB_TOKEN: ${{ github.token }}
69103
with:
70-
version: 0.11.0
104+
tool: cargo-zigbuild
71105
- name: Setup toolchain
72106
run: ${{ matrix.settings.setup }}
73107
if: ${{ matrix.settings.setup }}
74108
shell: bash
75-
- name: Setup node x86
76-
if: matrix.settings.target == 'i686-pc-windows-msvc'
77-
run: yarn config set supportedArchitectures.cpu "ia32"
78-
shell: bash
79109
- name: Install dependencies
80110
run: yarn install
81-
- name: Setup node x86
82-
uses: actions/setup-node@v4
83-
if: matrix.settings.target == 'i686-pc-windows-msvc'
84-
with:
85-
node-version: 20
86-
cache: yarn
87-
architecture: x86
88-
- name: Build in docker
89-
uses: addnab/docker-run-action@v3
90-
if: ${{ matrix.settings.docker }}
91-
with:
92-
image: ${{ matrix.settings.docker }}
93-
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
94-
run: ${{ matrix.settings.build }}
95111
- name: Build
96112
run: ${{ matrix.settings.build }}
97-
if: ${{ !matrix.settings.docker }}
98113
shell: bash
99114
- name: Upload artifact
100115
uses: actions/upload-artifact@v4
101116
with:
102117
name: bindings-${{ matrix.settings.target }}
103-
path: ${{ env.APP_NAME }}.*.node
118+
path: |
119+
${{ env.APP_NAME }}.*.node
120+
${{ env.APP_NAME }}.*.wasm
104121
if-no-files-found: error
105122
test-macOS-windows-binding:
106123
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
@@ -110,15 +127,18 @@ jobs:
110127
fail-fast: false
111128
matrix:
112129
settings:
113-
- host: macos-latest
114-
target: x86_64-apple-darwin
115-
- host: macos-latest
116-
target: aarch64-apple-darwin
117130
- host: windows-latest
118131
target: x86_64-pc-windows-msvc
132+
architecture: x64
133+
- host: macos-latest
134+
target: aarch64-apple-darwin
135+
architecture: arm64
136+
- host: macos-latest
137+
target: x86_64-apple-darwin
138+
architecture: x64
119139
node:
120-
- '18'
121140
- '20'
141+
- '22'
122142
runs-on: ${{ matrix.settings.host }}
123143
steps:
124144
- uses: actions/checkout@v4
@@ -127,6 +147,7 @@ jobs:
127147
with:
128148
node-version: ${{ matrix.node }}
129149
cache: yarn
150+
architecture: ${{ matrix.settings.architecture }}
130151
- name: Install dependencies
131152
run: yarn install
132153
- name: Download artifacts
@@ -139,60 +160,94 @@ jobs:
139160
shell: bash
140161
- name: Test bindings
141162
run: yarn test
142-
test-linux-x64-gnu-binding:
143-
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
163+
test-linux-binding:
164+
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
144165
needs:
145166
- build
146167
strategy:
147168
fail-fast: false
148169
matrix:
170+
target:
171+
- x86_64-unknown-linux-gnu
172+
- aarch64-unknown-linux-gnu
149173
node:
150-
- '18'
151174
- '20'
152-
runs-on: ubuntu-latest
175+
- '22'
176+
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
153177
steps:
154178
- uses: actions/checkout@v4
155179
- name: Setup node
156180
uses: actions/setup-node@v4
157181
with:
158182
node-version: ${{ matrix.node }}
159183
cache: yarn
184+
- name: Output docker params
185+
id: docker
186+
run: |
187+
node -e "
188+
if ('${{ matrix.target }}'.startsWith('aarch64')) {
189+
console.log('PLATFORM=linux/arm64')
190+
} else if ('${{ matrix.target }}'.startsWith('armv7')) {
191+
console.log('PLATFORM=linux/arm/v7')
192+
} else {
193+
console.log('PLATFORM=linux/amd64')
194+
}
195+
" >> $GITHUB_OUTPUT
196+
node -e "
197+
if ('${{ matrix.target }}'.endsWith('-musl')) {
198+
console.log('IMAGE=node:${{ matrix.node }}-alpine')
199+
} else {
200+
console.log('IMAGE=node:${{ matrix.node }}-slim')
201+
}
202+
" >> $GITHUB_OUTPUT
160203
- name: Install dependencies
161-
run: yarn install
204+
run: |
205+
yarn config set --json supportedArchitectures.cpu '["current", "arm64", "x64", "arm"]'
206+
yarn config set --json supportedArchitectures.libc '["current", "musl", "gnu"]'
207+
yarn install
162208
- name: Download artifacts
163209
uses: actions/download-artifact@v4
164210
with:
165-
name: bindings-x86_64-unknown-linux-gnu
211+
name: bindings-${{ matrix.target }}
166212
path: .
167213
- name: List packages
168214
run: ls -R .
169215
shell: bash
216+
- name: Set up QEMU
217+
uses: docker/setup-qemu-action@v3
218+
if: ${{ contains(matrix.target, 'armv7') }}
219+
with:
220+
platforms: all
221+
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
222+
if: ${{ contains(matrix.target, 'armv7') }}
170223
- name: Test bindings
171-
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn test
224+
uses: addnab/docker-run-action@v3
225+
with:
226+
image: ${{ steps.docker.outputs.IMAGE }}
227+
options: '-v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}'
228+
run: yarn test
172229
publish:
173230
name: Publish
174231
runs-on: ubuntu-latest
175232
needs:
233+
- lint
176234
- test-macOS-windows-binding
177-
- test-linux-x64-gnu-binding
235+
- test-linux-binding
178236
steps:
179237
- uses: actions/checkout@v4
180238
- name: Setup node
181239
uses: actions/setup-node@v4
182240
with:
183-
node-version: 20
241+
node-version: 22
184242
cache: yarn
185243
- name: Install dependencies
186244
run: yarn install
245+
- name: create npm dirs
246+
run: yarn napi create-npm-dirs
187247
- name: Download all artifacts
188248
uses: actions/download-artifact@v4
189249
with:
190250
path: artifacts
191-
- name: Rename Darwin Artifacts
192-
run: |
193-
mv ./artifacts/bindings-x86_64-apple-darwin/binarystream.darwin-arm64.node ./artifacts/bindings-x86_64-apple-darwin/binarystream.darwin-x64.node
194-
- name: List artifacts
195-
run: ls -R ./artifacts
196251
- name: Move artifacts
197252
run: yarn artifacts
198253
- name: List packages

0 commit comments

Comments
 (0)