This repository was archived by the owner on Sep 17, 2024. It is now read-only.
Repository navigation
302 lines (262 loc) · 9.84 KB
/
Copy pathbuild.yml
File metadata and controls
302 lines (262 loc) · 9.84 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
name: Precompile binaries
on:
push:
branches:
- main
- release/**
- "**/*"
workflow_dispatch:
inputs:
commit:
description: If the commit you want to test isn't the head of a branch, provide its SHA here
required: false
jobs:
precompile-bindings:
name: ${{ matrix.os }} (${{ matrix.target_platform }} node=${{ matrix.node || matrix.container }}, arch=${{ matrix.arch || matrix.container }}, compiler=${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
# We will prebuild binaries for node v18 on linux
# with different versions of glibc to ensure that
# the binaries are compatible with a wide range of
# distributions and container images.
# linux x64 glibc
- os: ubuntu-20.04
node: 16
- os: ubuntu-20.04
node: 18
- os: ubuntu-20.04
node: 20
# linux x64 musl
- os: ubuntu-20.04
container: node:16-alpine3.16
node: 16
- os: ubuntu-20.04
container: node:18-alpine3.17
node: 18
- os: ubuntu-20.04
container: node:20-alpine3.17
node: 20
# linux arm64 glibc
- os: ubuntu-20.04
arch: arm64
node: 16
- os: ubuntu-20.04
arch: arm64
node: 18
- os: ubuntu-20.04
arch: arm64
node: 20
# linux arm64 musl
- os: ubuntu-20.04
container: node:16-alpine3.16
arch: arm64
node: 16
- os: ubuntu-20.04
arch: arm64
container: node:18-alpine3.17
node: 18
- os: ubuntu-20.04
arch: arm64
container: node:20-alpine3.17
node: 20
# macos x64
- os: macos-11
node: 16
arch: x64
- os: macos-11
node: 18
arch: x64
- os: macos-11
node: 20
arch: x64
# macos cross compile for darwin
- os: macos-12
arch: arm64
node: 16
target_platform: darwin
- os: macos-12
arch: arm64
node: 18
target_platform: darwin
- os: macos-12
arch: arm64
node: 20
target_platform: darwin
# windows x64
- os: windows-2019
node: 16
arch: x64
- os: windows-2019
node: 18
arch: x64
- os: windows-2019
node: 20
arch: x64
# For some reason it seems like it takes forever for
# the macos-m1 runners to start up, so we'll just skip it
# - os: macos-m1
# node: 18
# arch: arm64
# Build artifacts are only needed for releasing workflow.
# if: startsWith(github.ref, 'refs/heads/release/')
# alpine build dependencies
steps:
- name: setup (alpine)
if: contains(matrix.container, 'alpine')
run: |
apk add --no-cache build-base python3 g++ make curl
- name: Check out current commit
uses: actions/checkout@v3
with:
ref: ${{ env.HEAD_COMMIT }}
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: actions/setup-python@v4
name: Setup python
- name: Install dependencies
run: yarn install --ignore-scripts --frozen-lockfile
# configure build test copy x64
- name: Configure gyp
if: matrix.arch != 'arm64'
run: yarn build:configure
- name: Build bindings
if: matrix.arch != 'arm64'
run: yarn build:bindings
- name: Test
if: matrix.arch != 'arm64'
run: yarn test --silent
# configure build test copy arm64
- name: setup (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
run: |
sudo apt-get update
sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# linux arm64
- name: "Configure gyp (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})"
if: matrix.arch == 'arm64' && matrix.target_platform != 'darwin'
run: yarn build:configure:arm64
- name: Setup musl cross compiler
if: contains(matrix.container, 'alpine')
run: |
curl -OL https://musl.cc/aarch64-linux-musl-cross.tgz
tar -xzvf aarch64-linux-musl-cross.tgz
$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc --version
- name: "Build bindings (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})"
if: matrix.arch == 'arm64' && contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
run: |
CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc \
CXX=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ \
BUILD_ARCH=arm64 yarn build:bindings
- name: "Build bindings (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})"
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
run: |
CC=aarch64-linux-gnu-gcc \
CXX=aarch64-linux-gnu-g++ \
BUILD_ARCH=arm64 yarn build:bindings:arm64
# linux arm64 target darwin
- name: "Configure gyp (arm64, darwin)"
if: matrix.arch == 'arm64' && matrix.target_platform == 'darwin'
run: yarn build:configure:arm64
- name: "Build bindings (arm64, darwin)"
if: matrix.arch == 'arm64' && matrix.target_platform == 'darwin'
run: |
BUILD_PLATFORM=darwin BUILD_ARCH=arm64 yarn build:bindings:arm64
# continue with common steps
- name: Log binary
run: du -sh lib/*
- name: Archive binary
uses: actions/upload-artifact@v3
with:
name: binaries-${{ github.sha }}
path: |
${{ github.workspace }}/lib/*.node
test-bundle:
runs-on: ubuntu-latest
needs: [precompile-bindings]
# if: startsWith(github.ref, 'refs/heads/release/')
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn build:lib
- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: yarn test:bundle
build-and-pack:
runs-on: ubuntu-latest
needs: [precompile-bindings, test-bundle]
# Build artifacts are only needed for releasing workflow.
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn build:lib
- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: yarn pack
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
path: |
${{ github.workspace }}/*.tgz
test-app-build-run:
name: bundler tests
runs-on: ubuntu-20.04
needs: [precompile-bindings, test-bundle, build-and-pack]
# Build artifacts are only needed for releasing workflow.
strategy:
fail-fast: false
matrix:
# The matrix should really be ["webpack", "esbuild", "rollup"],
# however both rollup and webpack currently crash at runtime.
# The webpack generated bundle crashes at runtime with
# TypeError: profiling.ProfilingIntegration is not a constructor
# ^^ Seems like a generic import syntax erro, however when I log the bundle,
# it actually contains {LRUMap: [Function LRUMap]} which is incorrect.
# It seems like webpack either mangles the import, or pulls it from some
# unknown source? I currently dont have the bandwidth to debug why, but contributions
# are welcome.
# similarly to webpack, rollup build succeeds, but fails at runtime because
# rollup hoist and evaluate binary module imports. This means that all possible
# binaries are imported, which obviously causes a crash due to platform incompatibility.
# I have attempted the different options like strictRequires:true indicated by rollup's maintainer in
# https://twitter.com/lukastaegert/status/1680233261639892993?s=20, but I could not get it to
# build properly. Similarly to webpack, if someone wants to give this a spin, your contributions
# would be more than welcome.
# The general workflow for testing a bundler workflow
# is to build our library, download the generated binaries and
# use yarn link to link the what will be our final published library
# into the demo_app folder. From there, we run the different bundler
# build commands and attempt to run the demo app.
bundler: ["esbuild"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn build:lib
- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: ls -l lib/
- run: yarn link
- run: yarn test:setup:bundle
- run: yarn test:${{matrix.bundler}}:build
- run: yarn test:${{matrix.bundler}}:run
- run: rm -rf ./node_modules/ && yarn install && node scripts/check-build.mjs