Skip to content

Commit edc040b

Browse files
committed
Switch to using napi-rs
1 parent d8a3c1d commit edc040b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4257
-3284
lines changed

.cargo/config.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
[target.x86_64-unknown-linux-musl]
2-
rustflags = ["-C", "target-feature=-crt-static"]
31
[target.aarch64-unknown-linux-musl]
2+
linker = "aarch64-alpine-linux-musl-gcc"
43
rustflags = ["-C", "target-feature=-crt-static"]
54
[target.arm-unknown-linux-musleabihf]
65
rustflags = ["-C", "target-feature=-crt-static"]

.github/workflows/CI.yml

Lines changed: 337 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,337 @@
1+
name: CI
2+
env:
3+
DEBUG: napi:*
4+
APP_NAME: libsql
5+
MACOSX_DEPLOYMENT_TARGET: '10.13'
6+
permissions:
7+
contents: write
8+
id-token: write
9+
'on':
10+
push:
11+
branches:
12+
- main
13+
tags-ignore:
14+
- '**'
15+
paths-ignore:
16+
- '**/*.md'
17+
- LICENSE
18+
- '**/*.gitignore'
19+
- .editorconfig
20+
- docs/**
21+
pull_request: null
22+
jobs:
23+
build:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
settings:
28+
- host: macos-latest
29+
target: x86_64-apple-darwin
30+
build: yarn build --target x86_64-apple-darwin
31+
- host: windows-latest
32+
build: yarn build --target x86_64-pc-windows-msvc
33+
target: x86_64-pc-windows-msvc
34+
- host: ubuntu-latest
35+
target: x86_64-unknown-linux-gnu
36+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
37+
build: yarn build --target x86_64-unknown-linux-gnu
38+
- host: ubuntu-latest
39+
target: x86_64-unknown-linux-musl
40+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
41+
build: apk add musl-dev musl-utils gcc && ls -l /usr/bin && CC=x86_64-alpine-linux-musl-gcc yarn build --target x86_64-unknown-linux-musl
42+
- host: macos-latest
43+
target: aarch64-apple-darwin
44+
build: yarn build --target aarch64-apple-darwin
45+
- host: ubuntu-24.04
46+
target: aarch64-unknown-linux-gnu
47+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
48+
build: yarn build --target aarch64-unknown-linux-gnu
49+
- host: ubuntu-24.04-arm
50+
target: aarch64-unknown-linux-musl
51+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
52+
build: |-
53+
set -e &&
54+
apk add gcc musl-dev &&
55+
ls -l /usr/bin &&
56+
rustup target add aarch64-unknown-linux-musl &&
57+
CC=aarch64-alpine-linux-musl-gcc yarn build --target aarch64-unknown-linux-musl
58+
name: stable - ${{ matrix.settings.target }} - node@20
59+
runs-on: ${{ matrix.settings.host }}
60+
steps:
61+
- uses: actions/checkout@v4
62+
- name: Setup node
63+
uses: actions/setup-node@v4
64+
if: ${{ !matrix.settings.docker }}
65+
with:
66+
node-version: 20
67+
cache: yarn
68+
- name: Install
69+
uses: dtolnay/rust-toolchain@stable
70+
if: ${{ !matrix.settings.docker }}
71+
with:
72+
toolchain: stable
73+
targets: ${{ matrix.settings.target }}
74+
- name: Cache cargo
75+
uses: actions/cache@v4
76+
with:
77+
path: |
78+
~/.cargo/registry/index/
79+
~/.cargo/registry/cache/
80+
~/.cargo/git/db/
81+
.cargo-cache
82+
target/
83+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
84+
- uses: goto-bus-stop/setup-zig@v2
85+
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
86+
with:
87+
version: 0.13.0
88+
- name: Setup toolchain
89+
run: ${{ matrix.settings.setup }}
90+
if: ${{ matrix.settings.setup }}
91+
shell: bash
92+
- name: Setup node x86
93+
if: matrix.settings.target == 'i686-pc-windows-msvc'
94+
run: yarn config set supportedArchitectures.cpu "ia32"
95+
shell: bash
96+
- name: Install dependencies
97+
run: yarn install
98+
- name: Setup node x86
99+
uses: actions/setup-node@v4
100+
if: matrix.settings.target == 'i686-pc-windows-msvc'
101+
with:
102+
node-version: 20
103+
cache: yarn
104+
architecture: x86
105+
- name: Build in docker
106+
uses: addnab/docker-run-action@v3
107+
if: ${{ matrix.settings.docker }}
108+
with:
109+
image: ${{ matrix.settings.docker }}
110+
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'
111+
run: ${{ matrix.settings.build }}
112+
shell: bash
113+
- name: Build
114+
run: ${{ matrix.settings.build }}
115+
if: ${{ !matrix.settings.docker }}
116+
shell: bash
117+
- name: Upload artifact
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: bindings-${{ matrix.settings.target }}
121+
path: ${{ env.APP_NAME }}.*.node
122+
if-no-files-found: error
123+
test-macOS-windows-binding:
124+
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
125+
needs:
126+
- build
127+
strategy:
128+
fail-fast: false
129+
matrix:
130+
settings:
131+
- host: macos-latest
132+
target: x86_64-apple-darwin
133+
- host: windows-latest
134+
target: x86_64-pc-windows-msvc
135+
node:
136+
- '18'
137+
- '20'
138+
runs-on: ${{ matrix.settings.host }}
139+
steps:
140+
- uses: actions/checkout@v4
141+
- name: Setup node
142+
uses: actions/setup-node@v4
143+
with:
144+
node-version: ${{ matrix.node }}
145+
cache: yarn
146+
architecture: x64
147+
- name: Install dependencies
148+
run: yarn install
149+
- name: Download artifacts
150+
uses: actions/download-artifact@v4
151+
with:
152+
name: bindings-${{ matrix.settings.target }}
153+
path: .
154+
- name: List packages
155+
run: ls -R .
156+
shell: bash
157+
- name: Test bindings
158+
run: yarn test
159+
test-linux-x64-gnu-binding:
160+
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
161+
needs:
162+
- build
163+
strategy:
164+
fail-fast: false
165+
matrix:
166+
node:
167+
- '18'
168+
- '20'
169+
runs-on: ubuntu-latest
170+
steps:
171+
- uses: actions/checkout@v4
172+
- name: Setup node
173+
uses: actions/setup-node@v4
174+
with:
175+
node-version: ${{ matrix.node }}
176+
cache: yarn
177+
- name: Install dependencies
178+
run: yarn install
179+
- name: Download artifacts
180+
uses: actions/download-artifact@v4
181+
with:
182+
name: bindings-x86_64-unknown-linux-gnu
183+
path: .
184+
- name: List packages
185+
run: ls -R .
186+
shell: bash
187+
- name: Test bindings
188+
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn test
189+
test-linux-x64-musl-binding:
190+
name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
191+
needs:
192+
- build
193+
strategy:
194+
fail-fast: false
195+
matrix:
196+
node:
197+
- '18'
198+
- '20'
199+
runs-on: ubuntu-latest
200+
steps:
201+
- uses: actions/checkout@v4
202+
- name: Setup node
203+
uses: actions/setup-node@v4
204+
with:
205+
node-version: ${{ matrix.node }}
206+
cache: yarn
207+
- name: Install dependencies
208+
run: |
209+
yarn config set supportedArchitectures.libc "musl"
210+
yarn install
211+
- name: Download artifacts
212+
uses: actions/download-artifact@v4
213+
with:
214+
name: bindings-x86_64-unknown-linux-musl
215+
path: .
216+
- name: List packages
217+
run: ls -R .
218+
shell: bash
219+
- name: Test bindings
220+
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-alpine yarn test
221+
test-linux-aarch64-gnu-binding:
222+
name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
223+
needs:
224+
- build
225+
strategy:
226+
fail-fast: false
227+
matrix:
228+
node:
229+
- '18'
230+
- '20'
231+
runs-on: ubuntu-latest
232+
steps:
233+
- uses: actions/checkout@v4
234+
- name: Download artifacts
235+
uses: actions/download-artifact@v4
236+
with:
237+
name: bindings-aarch64-unknown-linux-gnu
238+
path: .
239+
- name: List packages
240+
run: ls -R .
241+
shell: bash
242+
- name: Install dependencies
243+
run: |
244+
yarn config set supportedArchitectures.cpu "arm64"
245+
yarn config set supportedArchitectures.libc "glibc"
246+
yarn install
247+
- name: Set up QEMU
248+
uses: docker/setup-qemu-action@v3
249+
with:
250+
platforms: arm64
251+
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
252+
- name: Setup and run tests
253+
uses: addnab/docker-run-action@v3
254+
with:
255+
image: node:${{ matrix.node }}-slim
256+
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
257+
run: |
258+
set -e
259+
yarn test
260+
ls -la
261+
test-linux-aarch64-musl-binding:
262+
name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
263+
needs:
264+
- build
265+
runs-on: ubuntu-latest
266+
steps:
267+
- uses: actions/checkout@v4
268+
- name: Download artifacts
269+
uses: actions/download-artifact@v4
270+
with:
271+
name: bindings-aarch64-unknown-linux-musl
272+
path: .
273+
- name: List packages
274+
run: ls -R .
275+
shell: bash
276+
- name: Install dependencies
277+
run: |
278+
yarn config set supportedArchitectures.cpu "arm64"
279+
yarn config set supportedArchitectures.libc "musl"
280+
yarn install
281+
- name: Set up QEMU
282+
uses: docker/setup-qemu-action@v3
283+
with:
284+
platforms: arm64
285+
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
286+
- name: Setup and run tests
287+
uses: addnab/docker-run-action@v3
288+
with:
289+
image: node:lts-alpine
290+
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
291+
run: |
292+
set -e
293+
yarn test
294+
publish:
295+
name: Publish
296+
runs-on: ubuntu-latest
297+
needs:
298+
- test-macOS-windows-binding
299+
- test-linux-x64-gnu-binding
300+
- test-linux-x64-musl-binding
301+
- test-linux-aarch64-gnu-binding
302+
- test-linux-aarch64-musl-binding
303+
steps:
304+
- uses: actions/checkout@v4
305+
- name: Setup node
306+
uses: actions/setup-node@v4
307+
with:
308+
node-version: 20
309+
cache: yarn
310+
- name: Install dependencies
311+
run: yarn install
312+
- name: Download all artifacts
313+
uses: actions/download-artifact@v4
314+
with:
315+
path: artifacts
316+
- name: Move artifacts
317+
run: yarn artifacts
318+
- name: List packages
319+
run: ls -R ./npm
320+
shell: bash
321+
- name: Publish
322+
run: |
323+
npm config set provenance true
324+
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
325+
then
326+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
327+
npm publish --access public
328+
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
329+
then
330+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
331+
npm publish --tag next --access public
332+
else
333+
echo "Not a release, skipping publish"
334+
fi
335+
env:
336+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
337+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)