-
Notifications
You must be signed in to change notification settings - Fork 39
534 lines (432 loc) · 14.7 KB
/
CI.yaml
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
name: CI
env:
DEBUG: 'napi:*'
APP_NAME: 'package-template'
on:
push:
branches:
- main
tags-ignore:
- '**'
pull_request:
jobs:
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: stable - ${{ matrix.os }} - node@14
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: 14
check-latest: true
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-${{ matrix.os }}-node@14-${{ hashFiles('yarn.lock') }}
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: 'Build'
if: matrix.os != 'macos-latest'
run: yarn build
- name: 'Build'
if: matrix.os == 'macos-latest'
run: yarn build
env:
MACOSX_DEPLOYMENT_TARGET: '10.13'
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings-${{ matrix.os }}
path: ${{ env.APP_NAME }}.*.node
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache
build-linux-musl:
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: stable - linux-musl - node@10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to registry
run: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
env:
DOCKER_REGISTRY_URL: docker.pkg.github.com
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Pull docker image
run: |
docker pull docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts
docker tag docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts builder
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: stable-node-alpine-@10-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-node-alpine-@10-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-alpine-node@10-${{ hashFiles('yarn.lock') }}
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: 'Build'
run: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/${{ env.APP_NAME }} -e DEBUG="napi:*" -w /${{ env.APP_NAME }} builder sh -c "yarn build"
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings-linux-musl
path: ${{ env.APP_NAME }}.*.node
build-linux-aarch64:
name: stable - aarch64-unknown-linux-gnu - node@14
runs-on: ubuntu-latest
steps:
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: 14
check-latest: true
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install aarch64 toolchain
run: rustup target add aarch64-unknown-linux-gnu
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: stable-linux-aarch64-gnu-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-linux-aarch64-gnu-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-linux-aarch64-gnu-node@14-${{ hashFiles('yarn.lock') }}
- name: Install cross compile toolchain
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
- name: Install dependencies
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: Cross build aarch64
run: yarn build --target aarch64-unknown-linux-gnu
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings-linux-aarch64
path: ${{ env.APP_NAME }}.*.node
build-win32-i686:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Install node x86
run: |
choco install nodejs-lts --x86 -y --force
refreshenv
- name: Set 32bit NodeJS path
run: |
echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH
shell: bash
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-windows-i686-node@lts-${{ hashFiles('yarn.lock') }}
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install i686 toolchain
run: rustup target add i586-pc-windows-msvc
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: stable-windows-i686-node@lts-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-windows-i686-node@lts-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cross build i686
shell: bash
run: |
yarn build --target i586-pc-windows-msvc
mv package-template.win32-i586-msvc.node package-template.win32-ia32-msvc.node
- name: Test binary
run: |
node -v
node simple-test.js
yarn test
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings-win32-i586
path: ${{ env.APP_NAME }}.*.node
build-apple-silicon:
name: nightly - aarch64-apple-darwin - node@14
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: 14
check-latest: true
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
override: true
- name: Install aarch64 toolchain
run: rustup target add aarch64-apple-darwin
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: nightly-apple-aarch64-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: nightly-apple-aarch64-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-apple-aarch64-node@14-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: Cross build aarch64
run: yarn build --target aarch64-apple-darwin
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings-apple-aarch64
path: ${{ env.APP_NAME }}.*.node
test:
name: Test bindings on ${{ matrix.os }} - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['10', '12', '14', '15']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-test-${{ matrix.os }}-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: bindings-${{ matrix.os }}
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: yarn test
test-musl:
name: Test bindings on alpine - node@${{ matrix.node }}
needs:
- build-linux-musl
strategy:
fail-fast: false
matrix:
node: ['10', '12', '14', '15']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-alpine-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --ignore-scripts --registry https://registry.npmjs.org
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: bindings-linux-musl
path: .
- name: List files
run: ls -R .
shell: bash
- name: Run simple tests
run: docker run --rm -v $(pwd):/${{ env.APP_NAME }} -w /${{ env.APP_NAME }} node:${{ matrix.node }}-alpine sh -c "node ./simple-test.js"
test-aarch64:
name: stable - aarch64-unknown-linux-gnu - node@${{ matrix.node }}
runs-on: ubuntu-latest
needs:
- build-linux-aarch64
strategy:
fail-fast: false
matrix:
node: ['10', '12', '14', '15']
steps:
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-test-${{ matrix.os }}-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: bindings-linux-aarch64
path: .
- name: List
run: ls -a
- name: Run tests
uses: docker://multiarch/ubuntu-core:arm64-focal
with:
args: >
sh -c "
apt-get update && \
apt-get install -y ca-certificates gnupg2 curl && \
curl -sL https://deb.nodesource.com/setup_${{ matrix.node }}.x | bash - && \
apt-get install -y nodejs && \
node ./simple-test.js
"
dependabot:
needs:
- test
- test-musl
- test-aarch64
- build-win32-i686
- build-apple-silicon
runs-on: ubuntu-latest
steps:
- name: auto-merge
uses: ridedott/dependabot-auto-merge-action@master
with:
GITHUB_LOGIN: dependabot[bot]
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- test
- test-musl
- test-aarch64
- build-win32-i686
- build-apple-silicon
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: 14
check-latest: true
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-publish-ubuntu-latest-${{ hashFiles('yarn.lock') }}
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Move artifacts
run: yarn artifacts
- name: List packages
run: ls -R npm
shell: bash
- name: Publish
run: |
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}