Skip to content

Commit 290c7db

Browse files
authored
chore(NODE-4250): build modifications (#8)
1 parent 6742455 commit 290c7db

File tree

16 files changed

+64
-1916
lines changed

16 files changed

+64
-1916
lines changed

.github/workflows/CI.yml

+64-57
Original file line numberDiff line numberDiff line change
@@ -27,87 +27,94 @@ jobs:
2727
target: x86_64-apple-darwin
2828
architecture: x64
2929
build: |
30-
yarn build
30+
npm run build
3131
strip -x *.node
3232
- host: windows-latest
33-
build: yarn build
33+
build: npm run build
3434
target: x86_64-pc-windows-msvc
3535
architecture: x64
3636
- host: ubuntu-latest
3737
target: x86_64-unknown-linux-gnu
3838
architecture: x64
39-
docker: |
40-
docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian
41-
docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian builder
42-
build: |
43-
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build && strip *.node
39+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig
40+
build: >-
41+
set -e &&
42+
rustup target add x86_64-unknown-linux-gnu &&
43+
npm run build -- --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
44+
llvm-strip -x *.node
4445
- host: macos-latest
4546
target: aarch64-apple-darwin
4647
build: |
47-
yarn build --target=aarch64-apple-darwin
48+
npm run build --target=aarch64-apple-darwin
4849
strip -x *.node
4950
- host: ubuntu-latest
5051
architecture: x64
5152
target: aarch64-unknown-linux-gnu
52-
setup: |
53-
sudo apt-get update
54-
sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu -y
55-
build: |
56-
yarn build --target=aarch64-unknown-linux-gnu
57-
aarch64-linux-gnu-strip *.node
53+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig
54+
build: >-
55+
set -e &&
56+
rustup target add aarch64-unknown-linux-gnu &&
57+
npm run build -- --target aarch64-unknown-linux-gnu --zig --zig-abi-suffix 2.17 &&
58+
llvm-strip -x *.node
5859
name: stable - ${{ matrix.settings.target }} - node@16
5960
runs-on: ${{ matrix.settings.host }}
6061
steps:
61-
- uses: actions/checkout@v2
62+
- uses: actions/checkout@v3
6263
- name: Setup node
63-
uses: actions/setup-node@v2
64+
uses: actions/setup-node@v3
6465
with:
6566
node-version: 16
6667
check-latest: true
67-
cache: yarn
68+
cache: npm
6869
architecture: ${{ matrix.settings.architecture }}
6970
- name: Install
7071
uses: actions-rs/toolchain@v1
72+
if: ${{ !matrix.settings.docker }}
7173
with:
7274
profile: minimal
7375
override: true
7476
toolchain: stable
7577
target: ${{ matrix.settings.target }}
7678
- name: Generate Cargo.lock
7779
uses: actions-rs/cargo@v1
80+
if: ${{ !matrix.settings.docker }}
7881
with:
7982
command: generate-lockfile
8083
- name: Cache cargo registry
81-
uses: actions/cache@v2
84+
uses: actions/cache@v3
8285
with:
8386
path: ~/.cargo/registry
84-
key: ${{ matrix.settings.target }}-node@16-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
87+
key: ${{ matrix.settings.target }}-cargo-registry
8588
- name: Cache cargo index
86-
uses: actions/cache@v2
89+
uses: actions/cache@v3
8790
with:
8891
path: ~/.cargo/git
89-
key: ${{ matrix.settings.target }}-node@16-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
92+
key: ${{ matrix.settings.target }}-cargo-index
9093
- name: Cache NPM dependencies
91-
uses: actions/cache@v2
94+
uses: actions/cache@v3
9295
with:
9396
path: node_modules
94-
key: npm-cache-${{ matrix.settings.target }}-node@16-${{ hashFiles('yarn.lock') }}
95-
- name: Pull latest image
96-
run: ${{ matrix.settings.docker }}
97-
env:
98-
DOCKER_REGISTRY_URL: ghcr.io
99-
if: ${{ matrix.settings.docker }}
97+
key: npm-cache-build-${{ matrix.settings.target }}-node@16
10098
- name: Setup toolchain
10199
run: ${{ matrix.settings.setup }}
102100
if: ${{ matrix.settings.setup }}
103101
shell: bash
104102
- name: Install dependencies
105-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
106-
- name: Build
103+
run: npm clean-install --ignore-scripts
104+
- name: Build in docker
105+
uses: addnab/docker-run-action@v3
106+
if: ${{ matrix.settings.docker }}
107+
with:
108+
image: ${{ matrix.settings.docker }}
109+
options: -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build
110+
run: ${{ matrix.settings.build }}
111+
112+
- name: 'Build'
107113
run: ${{ matrix.settings.build }}
114+
if: ${{ !matrix.settings.docker }}
108115
shell: bash
109116
- name: Upload artifact
110-
uses: actions/upload-artifact@v2
117+
uses: actions/upload-artifact@v3
111118
with:
112119
name: bindings-${{ matrix.settings.target }}
113120
path: ${{ env.APP_NAME }}.*.node
@@ -128,30 +135,30 @@ jobs:
128135
- '16'
129136
runs-on: ${{ matrix.settings.host }}
130137
steps:
131-
- uses: actions/checkout@v2
138+
- uses: actions/checkout@v3
132139
- name: Setup node
133-
uses: actions/setup-node@v2
140+
uses: actions/setup-node@v3
134141
with:
135142
node-version: ${{ matrix.node }}
136143
check-latest: true
137-
cache: yarn
144+
cache: npm
138145
- name: Cache NPM dependencies
139-
uses: actions/cache@v2
146+
uses: actions/cache@v3
140147
with:
141148
path: node_modules
142-
key: npm-cache-test-${{ matrix.settings.target }}-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
149+
key: npm-cache-test-${{ matrix.settings.target }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}
143150
- name: Install dependencies
144-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
151+
run: npm clean-install --ignore-scripts
145152
- name: Download artifacts
146-
uses: actions/download-artifact@v2
153+
uses: actions/download-artifact@v3
147154
with:
148155
name: bindings-${{ matrix.settings.target }}
149156
path: .
150157
- name: List packages
151158
run: ls -R .
152159
shell: bash
153160
- name: Test bindings
154-
run: yarn test
161+
run: npm test
155162
test-linux-x64-gnu-binding:
156163
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
157164
needs:
@@ -171,14 +178,14 @@ jobs:
171178
with:
172179
node-version: ${{ matrix.node }}
173180
check-latest: true
174-
cache: yarn
181+
cache: npm
175182
- name: Cache NPM dependencies
176183
uses: actions/cache@v2
177184
with:
178185
path: node_modules
179-
key: npm-cache-test-linux-x64-gnu-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
186+
key: npm-cache-test-linux-x64-gnu-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}
180187
- name: Install dependencies
181-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
188+
run: npm clean-install --ignore-scripts
182189
- name: Download artifacts
183190
uses: actions/download-artifact@v2
184191
with:
@@ -188,7 +195,7 @@ jobs:
188195
run: ls -R .
189196
shell: bash
190197
- name: Test bindings
191-
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn test
198+
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim npm test
192199
test-linux-aarch64-gnu-binding:
193200
name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
194201
needs:
@@ -203,30 +210,30 @@ jobs:
203210
runs-on: ubuntu-latest
204211
steps:
205212
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
206-
- uses: actions/checkout@v2
213+
- uses: actions/checkout@v3
207214
- name: Download artifacts
208-
uses: actions/download-artifact@v2
215+
uses: actions/download-artifact@v3
209216
with:
210217
name: bindings-aarch64-unknown-linux-gnu
211218
path: .
212219
- name: List packages
213220
run: ls -R .
214221
shell: bash
215222
- name: Cache NPM dependencies
216-
uses: actions/cache@v2
223+
uses: actions/cache@v3
217224
with:
218225
path: node_modules
219-
key: npm-cache-test-linux-aarch64-gnu-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
226+
key: npm-cache-test-linux-aarch64-gnu-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}
220227
- name: Install dependencies
221-
run: yarn install --ignore-scripts --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
228+
run: npm clean-install --ignore-scripts
222229
- name: Setup and run tests
223230
uses: addnab/docker-run-action@v3
224231
with:
225232
image: ghcr.io/napi-rs/napi-rs/nodejs:aarch64-${{ matrix.node }}
226233
options: '-v ${{ github.workspace }}:/build -w /build'
227234
run: |
228235
set -e
229-
yarn test
236+
npm test
230237
ls -la
231238
publish:
232239
name: Publish
@@ -236,28 +243,28 @@ jobs:
236243
- test-linux-x64-gnu-binding
237244
- test-linux-aarch64-gnu-binding
238245
steps:
239-
- uses: actions/checkout@v2
246+
- uses: actions/checkout@v3
240247
- name: Setup node
241-
uses: actions/setup-node@v2
248+
uses: actions/setup-node@v3
242249
with:
243250
node-version: 16
244251
check-latest: true
245-
cache: yarn
252+
cache: npm
246253
- name: Cache NPM dependencies
247-
uses: actions/cache@v2
254+
uses: actions/cache@v3
248255
with:
249256
path: node_modules
250-
key: npm-cache-ubuntu-latest-${{ hashFiles('yarn.lock') }}
257+
key: npm-cache-ubuntu-latest-${{ hashFiles('package-lock.json') }}
251258
restore-keys: |
252259
npm-cache-
253260
- name: Install dependencies
254-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
261+
run: npm clean-install --ignore-scripts
255262
- name: Download all artifacts
256-
uses: actions/download-artifact@v2
263+
uses: actions/download-artifact@v3
257264
with:
258265
path: artifacts
259266
- name: Move artifacts
260-
run: yarn artifacts
267+
run: npm run artifacts
261268
- name: List packages
262269
run: ls -R ./npm
263270
shell: bash

npm/android-arm-eabi/README.md

-3
This file was deleted.

npm/android-arm-eabi/package.json

-18
This file was deleted.

npm/android-arm64/README.md

-3
This file was deleted.

npm/android-arm64/package.json

-18
This file was deleted.

npm/freebsd-x64/README.md

-3
This file was deleted.

npm/freebsd-x64/package.json

-18
This file was deleted.

npm/linux-arm-gnueabihf/README.md

-3
This file was deleted.

npm/linux-arm-gnueabihf/package.json

-18
This file was deleted.

npm/linux-arm64-musl/README.md

-3
This file was deleted.

npm/linux-arm64-musl/package.json

-18
This file was deleted.

npm/linux-x64-musl/README.md

-3
This file was deleted.

0 commit comments

Comments
 (0)