Skip to content

Commit 0b6639c

Browse files
committed
Switch to using napi-rs
1 parent ff914ef commit 0b6639c

Some content is hidden

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

57 files changed

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

0 commit comments

Comments
 (0)