Skip to content

Commit 9436b43

Browse files
committed
ci(javascript/driver-manager): add build and packaging workflows
1 parent d4e61bd commit 9436b43

3 files changed

Lines changed: 380 additions & 0 deletions

File tree

.github/workflows/node.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Node.js Binding
19+
20+
env:
21+
DEBUG: napi:*
22+
APP_NAME: adbc-driver-manager
23+
MACOSX_DEPLOYMENT_TARGET: '10.13'
24+
CARGO_INCREMENTAL: '1'
25+
26+
on:
27+
push:
28+
branches:
29+
- main
30+
paths:
31+
- 'javascript/**'
32+
- 'rust/**'
33+
- '.github/workflows/node.yml'
34+
pull_request:
35+
paths:
36+
- 'javascript/**'
37+
- 'rust/**'
38+
- '.github/workflows/node.yml'
39+
40+
concurrency:
41+
group: ${{ github.workflow }}-${{ github.ref }}
42+
cancel-in-progress: true
43+
44+
jobs:
45+
lint:
46+
name: Lint
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Setup node
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: 22
54+
cache: 'npm'
55+
cache-dependency-path: javascript/package-lock.json
56+
- name: Install Rust
57+
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
58+
with:
59+
components: clippy, rustfmt
60+
- name: Install dependencies
61+
working-directory: javascript
62+
run: npm install
63+
- name: Cargo fmt
64+
working-directory: javascript
65+
run: cargo fmt -- --check
66+
- name: Clippy
67+
working-directory: javascript
68+
run: cargo clippy -- -D warnings
69+
70+
build:
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
settings:
75+
- host: macos-15-intel
76+
target: x86_64-apple-darwin
77+
arch: amd64
78+
os: macOS
79+
build: npm run build -- --target x86_64-apple-darwin
80+
- host: macos-latest
81+
target: aarch64-apple-darwin
82+
arch: arm64
83+
os: macOS
84+
build: npm run build -- --target aarch64-apple-darwin
85+
- host: windows-latest
86+
target: x86_64-pc-windows-msvc
87+
arch: amd64
88+
os: Windows
89+
build: npm run build -- --target x86_64-pc-windows-msvc
90+
- host: ubuntu-latest
91+
target: x86_64-unknown-linux-gnu
92+
arch: amd64
93+
os: Linux
94+
build: npm run build -- --target x86_64-unknown-linux-gnu --use-napi-cross
95+
- host: ubuntu-latest
96+
target: aarch64-unknown-linux-gnu
97+
arch: arm64
98+
os: Linux
99+
build: npm run build -- --target aarch64-unknown-linux-gnu --use-napi-cross
100+
name: Build Node.js ${{ matrix.settings.arch }} ${{ matrix.settings.os }}
101+
runs-on: ${{ matrix.settings.host }}
102+
steps:
103+
- uses: actions/checkout@v4
104+
- name: Setup node
105+
uses: actions/setup-node@v4
106+
with:
107+
node-version: 22
108+
cache: 'npm'
109+
cache-dependency-path: javascript/package-lock.json
110+
- name: Install Rust
111+
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
112+
with:
113+
toolchain: stable
114+
targets: ${{ matrix.settings.target }}
115+
- name: Install dependencies
116+
working-directory: javascript
117+
run: npm install
118+
- name: Build
119+
working-directory: javascript
120+
run: ${{ matrix.settings.build }}
121+
shell: bash
122+
- name: Ad-hoc sign binary (macOS)
123+
if: runner.os == 'macOS'
124+
working-directory: javascript
125+
run: codesign --sign - *.node
126+
- name: Upload artifact
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: bindings-${{ matrix.settings.target }}
130+
path: javascript/*.node
131+
if-no-files-found: error
132+
133+
test:
134+
name: Test ${{ matrix.settings.target }}
135+
needs: build
136+
runs-on: ${{ matrix.settings.host }}
137+
strategy:
138+
fail-fast: false
139+
matrix:
140+
settings:
141+
- host: ubuntu-latest
142+
target: x86_64-unknown-linux-gnu
143+
- host: macos-latest
144+
target: x86_64-apple-darwin
145+
# Windows testing is tricky without proper env setup for sqlite driver build
146+
steps:
147+
- uses: actions/checkout@v4
148+
- name: Setup node
149+
uses: actions/setup-node@v4
150+
with:
151+
node-version: 22
152+
cache: 'npm'
153+
cache-dependency-path: javascript/package-lock.json
154+
- name: Install dependencies
155+
working-directory: javascript
156+
run: npm install --omit=optional
157+
- name: Download artifacts
158+
uses: actions/download-artifact@v4
159+
with:
160+
name: bindings-${{ matrix.settings.target }}
161+
path: javascript
162+
- name: Build Driver
163+
# We need to build the SQLite driver for tests.
164+
# This assumes the host has CMake and C++ compiler.
165+
working-directory: javascript
166+
run: npm run build:driver
167+
env:
168+
# Point to vendored sqlite for reliable build in CI
169+
ADBC_CMAKE_ARGS: "-DSQLite3_INCLUDE_DIR=${{ github.workspace }}/c/vendor/sqlite3"
170+
- name: Run Tests
171+
working-directory: javascript
172+
run: npm test

.github/workflows/packaging.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,151 @@ jobs:
10961096
docker compose run python-sdist-test
10971097
popd
10981098
1099+
node-binaries:
1100+
name: "Node.js ${{ matrix.settings.arch }} ${{ matrix.settings.os }}"
1101+
runs-on: ${{ matrix.settings.host }}
1102+
needs:
1103+
- source
1104+
strategy:
1105+
fail-fast: false
1106+
matrix:
1107+
settings:
1108+
- host: macos-15-intel
1109+
target: x86_64-apple-darwin
1110+
arch: amd64
1111+
os: macOS
1112+
build: npx napi build --platform --release --target x86_64-apple-darwin
1113+
- host: macos-latest
1114+
target: aarch64-apple-darwin
1115+
arch: arm64
1116+
os: macOS
1117+
build: npx napi build --platform --release --target aarch64-apple-darwin
1118+
- host: windows-latest
1119+
target: x86_64-pc-windows-msvc
1120+
arch: amd64
1121+
os: Windows
1122+
build: npx napi build --platform --release --target x86_64-pc-windows-msvc
1123+
- host: ubuntu-latest
1124+
target: x86_64-unknown-linux-gnu
1125+
arch: amd64
1126+
os: Linux
1127+
build: npx napi build --platform --release --target x86_64-unknown-linux-gnu --use-napi-cross
1128+
- host: ubuntu-latest
1129+
target: aarch64-unknown-linux-gnu
1130+
arch: arm64
1131+
os: Linux
1132+
build: npx napi build --platform --release --target aarch64-unknown-linux-gnu --use-napi-cross
1133+
steps:
1134+
- uses: actions/download-artifact@v6
1135+
with:
1136+
name: source
1137+
1138+
- name: Extract source archive
1139+
run: |
1140+
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
1141+
VERSION=${source_archive#apache-arrow-adbc-}
1142+
VERSION=${VERSION%.tar.gz}
1143+
1144+
tar xf apache-arrow-adbc-${VERSION}.tar.gz
1145+
mv apache-arrow-adbc-${VERSION} adbc
1146+
1147+
- name: Setup Node
1148+
uses: actions/setup-node@v4
1149+
with:
1150+
node-version: 22
1151+
cache: 'npm'
1152+
cache-dependency-path: adbc/javascript/package-lock.json
1153+
1154+
- name: Setup Rust
1155+
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
1156+
with:
1157+
toolchain: stable
1158+
targets: ${{ matrix.settings.target }}
1159+
1160+
- name: Install Node dependencies
1161+
working-directory: adbc/javascript
1162+
run: npm install
1163+
1164+
- name: Build Node.js binaries
1165+
working-directory: adbc/javascript
1166+
run: ${{ matrix.settings.build }}
1167+
shell: bash
1168+
1169+
- name: Sign binary (macOS)
1170+
if: runner.os == 'macOS'
1171+
working-directory: adbc/javascript
1172+
run: codesign --sign - *.node
1173+
1174+
- name: Upload Node.js binaries
1175+
uses: actions/upload-artifact@v5
1176+
with:
1177+
name: bindings-${{ matrix.settings.target }}
1178+
path: adbc/javascript/*.node
1179+
if-no-files-found: error
1180+
1181+
node-dist:
1182+
name: "Node.js Package"
1183+
runs-on: ubuntu-latest
1184+
needs:
1185+
- source
1186+
- node-binaries
1187+
steps:
1188+
- uses: actions/download-artifact@v6
1189+
with:
1190+
name: source
1191+
1192+
- name: Extract source archive
1193+
run: |
1194+
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
1195+
VERSION=${source_archive#apache-arrow-adbc-}
1196+
VERSION=${VERSION%.tar.gz}
1197+
1198+
tar xf apache-arrow-adbc-${VERSION}.tar.gz
1199+
mv apache-arrow-adbc-${VERSION} adbc
1200+
1201+
- name: Setup Node
1202+
uses: actions/setup-node@v4
1203+
with:
1204+
node-version: 22
1205+
cache: 'npm'
1206+
cache-dependency-path: adbc/javascript/package-lock.json
1207+
1208+
- name: Install Node dependencies
1209+
working-directory: adbc/javascript
1210+
run: npm install
1211+
1212+
- name: Build Node.js JS
1213+
working-directory: adbc/javascript
1214+
run: npm run build:ts
1215+
1216+
- name: Download Node.js binaries
1217+
uses: actions/download-artifact@v6
1218+
with:
1219+
pattern: bindings-*
1220+
path: adbc/javascript/artifacts
1221+
merge-multiple: true
1222+
1223+
- name: Package Node.js artifacts
1224+
working-directory: adbc/javascript
1225+
env:
1226+
HUSKY: "0"
1227+
run: |
1228+
npx napi artifacts
1229+
# Pack the main package
1230+
npm pack
1231+
# Pack the platform-specific packages
1232+
for dir in npm/*; do
1233+
npm pack "./$dir"
1234+
done
1235+
1236+
- name: Upload Node.js packages
1237+
uses: actions/upload-artifact@v5
1238+
with:
1239+
name: node-packages
1240+
retention-days: 7
1241+
path: |
1242+
adbc/javascript/*.tgz
1243+
10991244
release:
11001245
name: "Create release"
11011246
runs-on: ubuntu-latest
@@ -1106,6 +1251,7 @@ jobs:
11061251
- source
11071252
- java
11081253
- linux
1254+
- node-dist
11091255
- python-manylinux
11101256
- python-macos
11111257
- python-windows
@@ -1140,6 +1286,9 @@ jobs:
11401286
')' \
11411287
-exec mv '{}' upload-staging \;
11421288
1289+
# Handle Node.js packages (in tarball form)
1290+
find ./release-artifacts/ -name 'adbc-driver-manager-*.tgz' -exec mv '{}' upload-staging \;
1291+
11431292
UPLOAD=$(find upload-staging -type f | sort | uniq)
11441293
11451294
echo "Uploading files:" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)