Skip to content

Commit 8b1ae08

Browse files
committed
Switch to using napi-rs
1 parent ff914ef commit 8b1ae08

Some content is hidden

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

52 files changed

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

0 commit comments

Comments
 (0)