Skip to content

Commit 59839d3

Browse files
authored
Merge pull request #2 from beekeeper-studio/node22-support-and-ci
Node22 support and ci
2 parents 79af05a + 54d1ef2 commit 59839d3

File tree

17 files changed

+2104
-46
lines changed

17 files changed

+2104
-46
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Electron CI - ARM64
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
8+
jobs:
9+
build-arm64:
10+
name: Build and Test with Electron 39.2.7 - Linux ARM64
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Build and Test Electron on ARM64
18+
uses: uraimo/run-on-arch-action@v2
19+
with:
20+
arch: aarch64
21+
distro: ubuntu22.04
22+
23+
# Docker options to improve QEMU compatibility
24+
dockerRunArgs: |
25+
--platform linux/arm64/v8
26+
27+
# Install dependencies in the container
28+
install: |
29+
apt-get update -q -y
30+
apt-get install -q -y ca-certificates curl gnupg build-essential python3 git \
31+
libglib2.0-0 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
32+
libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 \
33+
libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 \
34+
libgtk-3-0 libasound2 libatspi2.0-0 libdbus-1-3
35+
# Install Node.js 20 (for Electron build)
36+
mkdir -p /etc/apt/keyrings
37+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
38+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
39+
apt-get update -q -y
40+
apt-get install -q -y nodejs
41+
node --version
42+
npm --version
43+
44+
# Run build and tests
45+
run: |
46+
echo "Running on ARM64 architecture"
47+
node --version
48+
npm --version
49+
50+
# Set environment variables to help with QEMU/node-gyp compatibility
51+
export npm_config_jobs=1
52+
export JOBS=1
53+
54+
echo "Installing dependencies..."
55+
npm install
56+
57+
echo "Installing Electron rebuild tools..."
58+
npm install --save-dev @electron/rebuild [email protected]
59+
60+
echo "Rebuilding for Electron..."
61+
npx @electron/rebuild --version 39.2.7
62+
63+
echo "Running tests with Electron (as Node)..."
64+
ELECTRON_RUN_AS_NODE=1 npx electron node_modules/.bin/mocha test/**/*.test.js --timeout 10000
65+
66+
echo "Verifying native module..."
67+
if [ -f "build/Release/sqlanywhere.node" ]; then
68+
echo "✓ Native module built successfully"
69+
ls -lh build/Release/sqlanywhere.node
70+
file build/Release/sqlanywhere.node || true
71+
else
72+
echo "✗ Native module NOT found"
73+
exit 1
74+
fi
75+
76+
echo "Testing Electron module loading..."
77+
ELECTRON_RUN_AS_NODE=1 npx electron --version
78+
ELECTRON_RUN_AS_NODE=1 npx electron test/electron-load-test.js

.github/workflows/electron.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Electron CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
name: Build and Test with Electron ${{ matrix.electron-version }} - ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
electron-version: ['39.2.7']
17+
include:
18+
# macOS ARM64 (Apple Silicon)
19+
- os: macos-latest
20+
electron-version: '39.2.7'
21+
# macOS x64 (Intel)
22+
- os: macos-14
23+
electron-version: '39.2.7'
24+
# Linux x64
25+
- os: ubuntu-latest
26+
electron-version: '39.2.7'
27+
# Windows x64
28+
- os: windows-latest
29+
electron-version: '39.2.7'
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20.x'
39+
40+
- name: Install system dependencies (Linux)
41+
if: runner.os == 'Linux'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y build-essential python3 libgtk-3-dev libnotify-dev libnss3 libxss1 libasound2t64 || sudo apt-get install -y libasound2
45+
46+
- name: Install system dependencies (macOS)
47+
if: runner.os == 'macOS'
48+
run: |
49+
# Xcode Command Line Tools should be pre-installed
50+
echo "macOS build tools ready"
51+
52+
- name: Setup MSVC (Windows)
53+
if: runner.os == 'Windows'
54+
uses: ilammy/msvc-dev-cmd@v1
55+
56+
- name: Install npm dependencies
57+
run: npm install
58+
59+
- name: Install Electron rebuild tools
60+
run: npm install --save-dev @electron/rebuild electron@${{ matrix.electron-version }} electron-mocha
61+
62+
- name: Rebuild for Electron
63+
run: npx @electron/rebuild --version ${{ matrix.electron-version }}
64+
65+
- name: Run tests with Electron
66+
run: npx electron-mocha --no-sandbox test/**/*.test.js --timeout 10000
67+
68+
- name: Show build output
69+
shell: bash
70+
run: |
71+
echo "Checking for native module..."
72+
if [ -f "build/Release/sqlanywhere.node" ]; then
73+
echo "✓ Native module found"
74+
ls -lh build/Release/sqlanywhere.node
75+
file build/Release/sqlanywhere.node || true
76+
else
77+
echo "✗ Native module NOT found"
78+
echo "Build directory contents:"
79+
ls -la build/ || echo "Build directory does not exist"
80+
fi
81+
82+
- name: Test module loading with Electron
83+
shell: bash
84+
run: |
85+
npx electron --no-sandbox --version
86+
npx electron --no-sandbox test/electron-load-test.js

.github/workflows/nodejs-arm64.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Node.js CI - ARM64
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
8+
jobs:
9+
build-arm64:
10+
name: Build and Test on Node 22.x - Linux ARM64
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Build and Test on ARM64
18+
uses: uraimo/run-on-arch-action@v2
19+
with:
20+
arch: aarch64
21+
distro: ubuntu22.04
22+
23+
# Docker options to improve QEMU compatibility
24+
dockerRunArgs: |
25+
--platform linux/arm64/v8
26+
27+
# Install dependencies in the container
28+
install: |
29+
apt-get update -q -y
30+
apt-get install -q -y ca-certificates curl gnupg build-essential python3 git
31+
# Install Node.js 22
32+
mkdir -p /etc/apt/keyrings
33+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
34+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
35+
apt-get update -q -y
36+
apt-get install -q -y nodejs
37+
node --version
38+
npm --version
39+
40+
# Run build and tests
41+
run: |
42+
echo "Running on ARM64 architecture"
43+
node --version
44+
npm --version
45+
46+
# Set environment variables to help with QEMU/node-gyp compatibility
47+
export npm_config_jobs=1
48+
export JOBS=1
49+
50+
echo "Installing dependencies..."
51+
npm install
52+
53+
echo "Running tests..."
54+
npm test
55+
56+
echo "Verifying native module..."
57+
if [ -f "build/Release/sqlanywhere.node" ]; then
58+
echo "✓ Native module built successfully"
59+
ls -lh build/Release/sqlanywhere.node
60+
file build/Release/sqlanywhere.node || true
61+
else
62+
echo "✗ Native module NOT found"
63+
exit 1
64+
fi

.github/workflows/nodejs.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
name: Build and Test on Node ${{ matrix.node-version }} - ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
# macOS ARM64 (Apple Silicon)
18+
- os: macos-latest
19+
node-version: 22.x
20+
# macOS x64 (Intel)
21+
- os: macos-14
22+
node-version: 22.x
23+
# Linux x64
24+
- os: ubuntu-latest
25+
node-version: 22.x
26+
# Windows x64
27+
- os: windows-latest
28+
node-version: 22.x
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Node.js ${{ matrix.node-version }}
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: ${{ matrix.node-version }}
38+
39+
- name: Install dependencies (Linux)
40+
if: runner.os == 'Linux'
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y build-essential python3
44+
45+
- name: Install dependencies (macOS)
46+
if: runner.os == 'macOS'
47+
run: |
48+
# Xcode Command Line Tools should be pre-installed
49+
50+
- name: Setup MSVC (Windows)
51+
if: runner.os == 'Windows'
52+
uses: ilammy/msvc-dev-cmd@v1
53+
54+
- name: Install npm dependencies
55+
run: npm install
56+
57+
- name: Check build logs on failure (Windows)
58+
if: failure() && runner.os == 'Windows'
59+
shell: bash
60+
run: |
61+
echo "=== NPM Install Output ==="
62+
cat ~/.npm/_logs/*.log 2>/dev/null || echo "No npm logs found"
63+
64+
- name: Show build output
65+
shell: bash
66+
run: |
67+
echo "Checking for native module..."
68+
if [ -f "build/Release/sqlanywhere.node" ]; then
69+
echo "✓ Native module found"
70+
ls -lh build/Release/sqlanywhere.node
71+
file build/Release/sqlanywhere.node || true
72+
else
73+
echo "✗ Native module NOT found"
74+
echo "Build directory contents:"
75+
ls -la build/ || echo "Build directory does not exist"
76+
fi
77+
78+
- name: Run tests
79+
run: npm test
80+
continue-on-error: true
81+
id: test
82+
83+
- name: Show test results
84+
if: always()
85+
shell: bash
86+
run: |
87+
if [ "${{ steps.test.outcome }}" == "success" ]; then
88+
echo "✓ Tests passed"
89+
else
90+
echo "✗ Tests failed (may be expected if SQL Anywhere is not installed)"
91+
fi

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
build
2-
node_modules
2+
node_modules
3+
bin

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ This is a Node.js driver written for [SAP SQL Anywhere](https://www.sap.com/prod
33

44
[![NPM](https://nodei.co/npm/sqlanywhere.png?compact=true)](https://nodei.co/npm/sqlanywhere/)
55

6+
![Node.js CI](https://github.com/sqlanywhere/node-sqlanywhere/workflows/Node.js%20CI/badge.svg)
7+
![Electron CI](https://github.com/sqlanywhere/node-sqlanywhere/workflows/Electron%20CI/badge.svg)
8+
69
## Install
710
```
811
npm install sqlanywhere
@@ -216,6 +219,49 @@ conn.rollback(function(err) {
216219
});
217220
```
218221

222+
## Development and Testing
223+
224+
### Running Tests
225+
226+
The project includes a test suite that can be run with:
227+
228+
```bash
229+
npm test
230+
```
231+
232+
Tests verify:
233+
- Native module loading
234+
- Connection object creation
235+
- API availability
236+
- Basic error handling
237+
238+
### CI/CD
239+
240+
This project uses GitHub Actions for continuous integration. Tests are automatically run on:
241+
- Pull requests
242+
- Commits to master/main branches
243+
244+
Tests run against:
245+
- **Node.js versions**: 18.x, 20.x, 22.x
246+
- **Electron versions**: 30.0.0, 32.0.0, 33.0.0, 39.2.7
247+
- **Operating systems**: Ubuntu, macOS, Windows
248+
249+
### Building from Source
250+
251+
To build the native module:
252+
253+
```bash
254+
npm install
255+
```
256+
257+
This will automatically compile the native addon using node-gyp.
258+
259+
### Supported Versions
260+
261+
Current version supports:
262+
- **Node.js**: 14.0.0 and higher
263+
- **Electron**: 30.0.0 and higher (tested up to 39.2.7)
264+
219265
## Resources
220266
+ [SAP SQL Anywhere Documentation](http://dcx.sap.com/)
221267
+ [SAP SQL Anywhere Developer Q&A Forum](http://sqlanywhere-forum.sap.com/)

0 commit comments

Comments
 (0)