Skip to content

Commit 00114e3

Browse files
authored
ci: Build and test in CI
2 parents 5332dbf + fe77582 commit 00114e3

File tree

6 files changed

+371
-28
lines changed

6 files changed

+371
-28
lines changed

.github/workflows/ci.yml

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
2+
name: "CI: Build & Test"
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/**
8+
pull_request:
9+
10+
jobs:
11+
job_lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out current commit
16+
uses: actions/checkout@v4
17+
- name: Set up Node
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: "package.json"
21+
- name: Install dependencies
22+
run: yarn install --ignore-engines --ignore-scripts --frozen-lockfile
23+
- name: Lint
24+
run: yarn lint
25+
26+
job_compile:
27+
name: Compile Binary (v${{ matrix.node }}) ${{ matrix.target_platform || matrix.os }}, ${{ matrix.arch || matrix.container }}, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }}
28+
runs-on: ${{ matrix.os }}
29+
container:
30+
image: ${{ matrix.container }}
31+
timeout-minutes: 30
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
include:
36+
# x64 glibc
37+
- os: ubuntu-22.04
38+
node: 18
39+
binary: linux-x64-glibc-108
40+
- os: ubuntu-22.04
41+
node: 20
42+
binary: linux-x64-glibc-115
43+
- os: ubuntu-22.04
44+
node: 22
45+
binary: linux-x64-glibc-127
46+
- os: ubuntu-22.04
47+
node: 24
48+
binary: linux-x64-glibc-137
49+
50+
# x64 musl
51+
- os: ubuntu-22.04
52+
container: node:18-alpine3.17
53+
node: 18
54+
binary: linux-x64-musl-108
55+
- os: ubuntu-22.04
56+
container: node:20-alpine3.17
57+
node: 20
58+
binary: linux-x64-musl-115
59+
- os: ubuntu-22.04
60+
container: node:22-alpine3.18
61+
node: 22
62+
binary: linux-x64-musl-127
63+
- os: ubuntu-22.04
64+
container: node:24-alpine3.20
65+
node: 24
66+
binary: linux-x64-musl-137
67+
68+
# arm64 glibc
69+
- os: ubuntu-22.04
70+
arch: arm64
71+
node: 18
72+
binary: linux-arm64-glibc-108
73+
- os: ubuntu-22.04
74+
arch: arm64
75+
node: 20
76+
binary: linux-arm64-glibc-115
77+
- os: ubuntu-22.04
78+
arch: arm64
79+
node: 22
80+
binary: linux-arm64-glibc-127
81+
- os: ubuntu-22.04
82+
arch: arm64
83+
node: 24
84+
binary: linux-arm64-glibc-137
85+
86+
# arm64 musl
87+
- os: ubuntu-22.04
88+
arch: arm64
89+
container: node:18-alpine3.17
90+
node: 18
91+
binary: linux-arm64-musl-108
92+
- os: ubuntu-22.04
93+
arch: arm64
94+
container: node:20-alpine3.17
95+
node: 20
96+
binary: linux-arm64-musl-115
97+
- os: ubuntu-22.04
98+
arch: arm64
99+
container: node:22-alpine3.18
100+
node: 22
101+
binary: linux-arm64-musl-127
102+
- os: ubuntu-22.04
103+
arch: arm64
104+
container: node:24-alpine3.20
105+
node: 24
106+
binary: linux-arm64-musl-137
107+
108+
# macos x64
109+
- os: macos-13
110+
node: 18
111+
arch: x64
112+
binary: darwin-x64-108
113+
- os: macos-13
114+
node: 20
115+
arch: x64
116+
binary: darwin-x64-115
117+
- os: macos-13
118+
node: 22
119+
arch: x64
120+
binary: darwin-x64-127
121+
- os: macos-13
122+
node: 24
123+
arch: x64
124+
binary: darwin-x64-137
125+
126+
# macos arm64
127+
- os: macos-13
128+
arch: arm64
129+
node: 18
130+
target_platform: darwin
131+
binary: darwin-arm64-108
132+
- os: macos-13
133+
arch: arm64
134+
node: 20
135+
target_platform: darwin
136+
binary: darwin-arm64-115
137+
- os: macos-13
138+
arch: arm64
139+
node: 22
140+
target_platform: darwin
141+
binary: darwin-arm64-127
142+
- os: macos-13
143+
arch: arm64
144+
node: 24
145+
target_platform: darwin
146+
binary: darwin-arm64-137
147+
148+
# windows x64
149+
- os: windows-2022
150+
node: 18
151+
arch: x64
152+
binary: win32-x64-108
153+
- os: windows-2022
154+
node: 20
155+
arch: x64
156+
binary: win32-x64-115
157+
- os: windows-2022
158+
node: 22
159+
arch: x64
160+
binary: win32-x64-127
161+
- os: windows-2022
162+
node: 24
163+
arch: x64
164+
binary: win32-x64-137
165+
166+
steps:
167+
- name: Setup (alpine)
168+
if: contains(matrix.container, 'alpine')
169+
run: |
170+
apk add --no-cache build-base git g++ make curl python3
171+
ln -sf python3 /usr/bin/python
172+
173+
- name: Check out current commit
174+
uses: actions/checkout@v4
175+
176+
# Note: On alpine images, this does nothing
177+
# The node version will be the one that is installed in the image
178+
# If you want to change the node version, you need to change the image
179+
# For non-alpine images, this will install the correct version of node
180+
- name: Setup Node
181+
uses: actions/setup-node@v4
182+
if: contains(matrix.container, 'alpine') == false
183+
with:
184+
node-version: ${{ matrix.node }}
185+
186+
- name: Increase yarn network timeout on Windows
187+
if: contains(matrix.os, 'windows')
188+
run: yarn config set network-timeout 600000 -g
189+
190+
- name: Install dependencies
191+
run: yarn install --ignore-engines --ignore-scripts --frozen-lockfile
192+
193+
- name: Configure safe directory
194+
run: |
195+
git config --global --add safe.directory "*"
196+
197+
- name: Setup python
198+
uses: actions/setup-python@v5
199+
if: ${{ !contains(matrix.container, 'alpine') }}
200+
id: python-setup
201+
with:
202+
python-version: "3.9.13"
203+
204+
- name: Setup (arm64| ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
205+
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
206+
run: |
207+
sudo apt-get update
208+
sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
209+
210+
- name: Setup Musl
211+
if: contains(matrix.container, 'alpine')
212+
run: |
213+
curl -OL https://musl.cc.timfish.dev/aarch64-linux-musl-cross.tgz
214+
tar -xzvf aarch64-linux-musl-cross.tgz
215+
$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc --version
216+
217+
# configure node-gyp
218+
- name: Configure node-gyp
219+
if: matrix.arch != 'arm64'
220+
run: yarn build:bindings:configure
221+
222+
- name: Configure node-gyp (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
223+
if: matrix.arch == 'arm64' && matrix.target_platform != 'darwin'
224+
run: yarn build:bindings:configure:arm64
225+
226+
- name: Configure node-gyp (arm64, darwin)
227+
if: matrix.arch == 'arm64' && matrix.target_platform == 'darwin'
228+
run: yarn build:bindings:configure:arm64
229+
230+
# build bindings
231+
- name: Build Bindings
232+
if: matrix.arch != 'arm64'
233+
run: |
234+
yarn build:bindings
235+
236+
- name: Build Bindings (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
237+
if: matrix.arch == 'arm64' && contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
238+
run: |
239+
CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc \
240+
CXX=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ \
241+
BUILD_ARCH=arm64 \
242+
yarn build:bindings
243+
244+
- name: Build Bindings (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
245+
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
246+
run: |
247+
CC=aarch64-linux-gnu-gcc \
248+
CXX=aarch64-linux-gnu-g++ \
249+
BUILD_ARCH=arm64 \
250+
yarn build:bindings:arm64
251+
252+
- name: Build Bindings (arm64, darwin)
253+
if: matrix.arch == 'arm64' && matrix.target_platform == 'darwin'
254+
run: |
255+
BUILD_PLATFORM=darwin \
256+
BUILD_ARCH=arm64 \
257+
yarn build:bindings:arm64
258+
259+
- name: Build
260+
run: yarn build:lib
261+
262+
- name: Archive Binary
263+
uses: actions/upload-artifact@v4
264+
with:
265+
name: stack-trace-${{ matrix.binary }}
266+
path: ${{ github.workspace }}/lib/stack-trace-${{matrix.binary}}.node
267+
if-no-files-found: error
268+
269+
job_build:
270+
name: Build Package
271+
needs: [job_compile]
272+
runs-on: ubuntu-latest
273+
steps:
274+
- name: Check out current commit
275+
uses: actions/checkout@v4
276+
- name: Set up Node
277+
uses: actions/setup-node@v4
278+
with:
279+
node-version-file: "package.json"
280+
281+
- name: Install dependencies
282+
run: yarn install --ignore-engines --ignore-scripts --frozen-lockfile
283+
284+
- name: Build TypeScript
285+
run: yarn build:lib
286+
287+
- name: Extract Prebuilt Binaries
288+
uses: actions/download-artifact@v4
289+
with:
290+
pattern: stack-trace-*
291+
path: ${{ github.workspace }}/lib/
292+
merge-multiple: true
293+
294+
- name: Pack tarball
295+
run: yarn build:tarball
296+
297+
- name: Archive artifacts
298+
uses: actions/upload-artifact@v4
299+
with:
300+
name: ${{ github.sha }}
301+
retention-days: 90
302+
path: ${{ github.workspace }}/*.tgz
303+
304+
job_test_bindings:
305+
name: Test (v${{ matrix.node }}) ${{ matrix.os }}
306+
needs: [job_build]
307+
runs-on: ${{ matrix.os }}
308+
strategy:
309+
fail-fast: false
310+
matrix:
311+
os: [
312+
ubuntu-24.04,
313+
ubuntu-22.04,
314+
ubuntu-22.04-arm,
315+
macos-latest, # macOS arm64
316+
macos-13, # macOS x64
317+
windows-latest,
318+
]
319+
node: [18, 20, 22, 24]
320+
steps:
321+
- name: Check out current commit
322+
uses: actions/checkout@v4
323+
- name: Set up Node
324+
uses: actions/setup-node@v4
325+
with:
326+
node-version: ${{ matrix.node }}
327+
- name: Install dependencies
328+
run: yarn install --ignore-engines --ignore-scripts --frozen-lockfile
329+
- name: Download Tarball
330+
uses: actions/download-artifact@v4
331+
with:
332+
name: ${{ github.sha }}
333+
- name: Run tests
334+
run: yarn test
335+
336+
job_required_jobs_passed:
337+
name: All required jobs passed
338+
needs: [job_lint, job_test_bindings]
339+
# Always run this, even if a dependent job failed
340+
if: always()
341+
runs-on: ubuntu-latest
342+
steps:
343+
- name: Check for failures
344+
if: contains(needs.*.result, 'failure')
345+
run: |
346+
echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
"build:dev": "yarn clean && yarn build:bindings:configure && yarn build",
2222
"build:tarball": "npm pack",
2323
"clean": "node-gyp clean && rm -rf lib && rm -rf build",
24-
"test": "vitest run --silent=false --disable-console-intercept"
24+
"test": "node ./test/prepare.mjs && vitest run --silent=false --disable-console-intercept"
2525
},
2626
"volta": {
2727
"node": "24.1.0"
2828
},
2929
"dependencies": {
3030
"detect-libc": "^2.0.4",
31-
"node-abi": "^4.9.0"
31+
"node-abi": "^3.73.0"
3232
},
3333
"devDependencies": {
3434
"@sentry-internal/eslint-config-sdk": "^9.22.0",
@@ -49,4 +49,4 @@
4949
"/scripts/check-build.mjs",
5050
"/scripts/copy-target.mjs"
5151
]
52-
}
52+
}

0 commit comments

Comments
 (0)