Skip to content

Commit 60986ed

Browse files
rathbomaclaude
andcommitted
Add test suite and GitHub Actions CI/CD workflows
- Add comprehensive test suite using Mocha - Add GitHub Actions workflow for Node.js 18.x, 20.x, 22.x - Add GitHub Actions workflow for Electron 30.0.0, 32.0.0, 33.0.0, 39.2.7 - Test on Ubuntu, macOS, and Windows - Update README with testing and CI/CD documentation - Add CI status badges to README 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 39a3d6d commit 60986ed

File tree

7 files changed

+1837
-1
lines changed

7 files changed

+1837
-1
lines changed

.github/workflows/electron.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Electron CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
build:
11+
name: Build and Test with Electron ${{ matrix.electron-version }} - ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
electron-version: ['30.0.0', '32.0.0', '33.0.0', '39.2.7']
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20.x'
28+
29+
- name: Install system dependencies (Linux)
30+
if: runner.os == 'Linux'
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y build-essential python3 libgtk-3-dev libnotify-dev libnss3 libxss1 libasound2
34+
35+
- name: Install system dependencies (macOS)
36+
if: runner.os == 'macOS'
37+
run: |
38+
# Xcode Command Line Tools should be pre-installed
39+
echo "macOS build tools ready"
40+
41+
- name: Install npm dependencies
42+
run: npm install
43+
44+
- name: Install Electron rebuild tools
45+
run: npm install --save-dev @electron/rebuild electron@${{ matrix.electron-version }}
46+
47+
- name: Rebuild for Electron
48+
run: npx @electron/rebuild --version ${{ matrix.electron-version }}
49+
50+
- name: Run tests with Electron
51+
run: |
52+
npm test
53+
54+
- name: Verify Electron build
55+
shell: bash
56+
run: |
57+
if [ -f "build/Release/sqlanywhere.node" ]; then
58+
echo "Native module built successfully for Electron ${{ matrix.electron-version }}"
59+
ls -lh build/Release/sqlanywhere.node
60+
else
61+
echo "Error: Native module not found"
62+
exit 1
63+
fi
64+
65+
- name: Test module loading with Electron
66+
shell: bash
67+
run: |
68+
npx electron --version
69+
node -e "console.log('Testing module load...'); const db = require('./lib/index'); console.log('Module loaded successfully'); const conn = db.createConnection(); console.log('Connection created:', typeof conn);"

.github/workflows/nodejs.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
build:
11+
name: Build and Test on Node ${{ matrix.node-version }} - ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
node-version: [18.x, 20.x, 22.x]
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
29+
- name: Install dependencies (Linux)
30+
if: runner.os == 'Linux'
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y build-essential python3
34+
35+
- name: Install dependencies (macOS)
36+
if: runner.os == 'macOS'
37+
run: |
38+
# Xcode Command Line Tools should be pre-installed
39+
40+
- name: Install dependencies (Windows)
41+
if: runner.os == 'Windows'
42+
run: |
43+
npm install --global windows-build-tools || echo "Build tools may already be installed"
44+
45+
- name: Install npm dependencies
46+
run: npm install
47+
48+
- name: Run tests
49+
run: npm test
50+
51+
- name: Verify build output
52+
shell: bash
53+
run: |
54+
if [ -f "build/Release/sqlanywhere.node" ]; then
55+
echo "Native module built successfully"
56+
ls -lh build/Release/sqlanywhere.node
57+
else
58+
echo "Warning: Native module not found"
59+
exit 1
60+
fi

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)