diff --git a/.github/workflows/electron-arm64.yml b/.github/workflows/electron-arm64.yml index 27bfbc6..a5b542c 100644 --- a/.github/workflows/electron-arm64.yml +++ b/.github/workflows/electron-arm64.yml @@ -7,72 +7,71 @@ on: jobs: build-arm64: - name: Build and Test with Electron 39.2.7 - Linux ARM64 - runs-on: ubuntu-latest + name: Build and Test with Electron ${{ matrix.electron-version }} on Node ${{ matrix.node-version }} - Linux ARM64 + runs-on: ubuntu-24.04-arm + + strategy: + fail-fast: false + matrix: + electron-version: ['39.2.7', '44.3.0'] + # Each Electron version builds against its own Node line, so Node is + # paired with the Electron version rather than varied independently. + include: + - electron-version: '39.2.7' + node-version: '22' + - electron-version: '44.3.0' + node-version: '24' steps: - name: Checkout code uses: actions/checkout@v4 - - name: Build and Test Electron on ARM64 - uses: uraimo/run-on-arch-action@v2 + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 with: - arch: aarch64 - distro: ubuntu22.04 - - # Docker options to improve QEMU compatibility - dockerRunArgs: | - --platform linux/arm64/v8 - - # Install dependencies in the container - install: | - apt-get update -q -y - apt-get install -q -y ca-certificates curl gnupg build-essential python3 git \ - libglib2.0-0 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \ - libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 \ - libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 \ - libgtk-3-0 libasound2 libatspi2.0-0 libdbus-1-3 - # Install Node.js 20 (for Electron build) - mkdir -p /etc/apt/keyrings - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg - 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 - apt-get update -q -y - apt-get install -q -y nodejs - node --version - npm --version + node-version: ${{ matrix.node-version }} - # Run build and tests - run: | - echo "Running on ARM64 architecture" - node --version - npm --version + - name: Show tool versions + run: | + node --version + npm --version - # Set environment variables to help with QEMU/node-gyp compatibility - export npm_config_jobs=1 - export JOBS=1 + - name: Install system dependencies + run: | + sudo apt-get update + # Ubuntu 24.04 renamed several of these with a t64 suffix (the 64-bit + # time_t transition); fall back to the old names on older releases. + sudo apt-get install -y build-essential python3 \ + libgtk-3-0t64 libnss3 libasound2t64 libatspi2.0-0t64 libcups2t64 \ + libnotify4 libxss1 libgbm1 libdrm2 \ + || sudo apt-get install -y build-essential python3 \ + libgtk-3-0 libnss3 libasound2 libatspi2.0-0 libcups2 \ + libnotify4 libxss1 libgbm1 libdrm2 - echo "Installing dependencies..." - npm install + - name: Install npm dependencies + run: npm install - echo "Installing Electron rebuild tools..." - npm install --save-dev @electron/rebuild electron@39.2.7 + - name: Install Electron rebuild tools + run: npm install --save-dev @electron/rebuild electron@${{ matrix.electron-version }} - echo "Rebuilding for Electron..." - npx @electron/rebuild --version 39.2.7 + - name: Rebuild for Electron + run: npx @electron/rebuild --version ${{ matrix.electron-version }} - echo "Running tests with Electron (as Node)..." - ELECTRON_RUN_AS_NODE=1 npx electron node_modules/.bin/mocha test/**/*.test.js --timeout 10000 + - name: Run tests with Electron (as Node) + run: ELECTRON_RUN_AS_NODE=1 npx electron node_modules/.bin/mocha test/**/*.test.js --timeout 10000 - echo "Verifying native module..." - if [ -f "build/Release/sqlanywhere.node" ]; then - echo "✓ Native module built successfully" - ls -lh build/Release/sqlanywhere.node - file build/Release/sqlanywhere.node || true - else - echo "✗ Native module NOT found" - exit 1 - fi + - name: Verify native module + run: | + if [ -f "build/Release/sqlanywhere.node" ]; then + echo "✓ Native module built successfully" + ls -lh build/Release/sqlanywhere.node + file build/Release/sqlanywhere.node || true + else + echo "✗ Native module NOT found" + exit 1 + fi - echo "Testing Electron module loading..." - ELECTRON_RUN_AS_NODE=1 npx electron --version - ELECTRON_RUN_AS_NODE=1 npx electron test/electron-load-test.js + - name: Test Electron module loading + run: | + ELECTRON_RUN_AS_NODE=1 npx electron --version + ELECTRON_RUN_AS_NODE=1 npx electron test/electron-load-test.js diff --git a/.github/workflows/electron.yml b/.github/workflows/electron.yml index de689c2..2da8754 100644 --- a/.github/workflows/electron.yml +++ b/.github/workflows/electron.yml @@ -7,41 +7,49 @@ on: jobs: build: - name: Build and Test with Electron ${{ matrix.electron-version }} - ${{ matrix.os }} + name: Build and Test with Electron ${{ matrix.electron-version }} on Node ${{ matrix.node-version }} - ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - electron-version: ['39.2.7'] - include: - # macOS ARM64 (Apple Silicon) - - os: macos-latest - electron-version: '39.2.7' - # macOS x64 (Intel) - - os: macos-14 - electron-version: '39.2.7' - # Linux x64 - - os: ubuntu-latest - electron-version: '39.2.7' - # Windows x64 + os: [macos-latest, macos-14, ubuntu-latest, windows-latest] + electron-version: ['39.2.7', '44.3.0'] + exclude: + # Electron 39 builds on Node 22, whose bundled node-gyp (11.5.0) + # cannot identify the Visual Studio 2026 on windows-latest. - os: windows-latest electron-version: '39.2.7' + include: + - electron-version: '39.2.7' + node-version: '22' + - electron-version: '44.3.0' + node-version: '24' + # ...so that combination builds against VS 2022 on the older image. + - os: windows-2022 + electron-version: '39.2.7' + node-version: '22' steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js + - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: ${{ matrix.node-version }} + + - name: Show tool versions + shell: bash + run: | + node --version + npm --version - name: Install system dependencies (Linux) if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y build-essential python3 libgtk-3-dev libnotify-dev libnss3 libxss1 libasound2t64 || sudo apt-get install -y libasound2 + sudo apt-get install -y xvfb build-essential python3 libgtk-3-dev libnotify-dev libnss3 libxss1 libasound2t64 || sudo apt-get install -y xvfb libasound2 - name: Install system dependencies (macOS) if: runner.os == 'macOS' @@ -49,10 +57,6 @@ jobs: # Xcode Command Line Tools should be pre-installed echo "macOS build tools ready" - - name: Setup MSVC (Windows) - if: runner.os == 'Windows' - uses: ilammy/msvc-dev-cmd@v1 - - name: Install npm dependencies run: npm install @@ -63,7 +67,14 @@ jobs: run: npx @electron/rebuild --version ${{ matrix.electron-version }} - name: Run tests with Electron - run: npx electron-mocha --no-sandbox test/**/*.test.js --timeout 10000 + shell: bash + run: | + # Electron needs a display; the Linux runners are headless. + RUN=() + if [ "$RUNNER_OS" = "Linux" ]; then + RUN=(xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24") + fi + "${RUN[@]}" npx electron-mocha --no-sandbox test/**/*.test.js --timeout 10000 - name: Show build output shell: bash @@ -82,5 +93,10 @@ jobs: - name: Test module loading with Electron shell: bash run: | + RUN=() + if [ "$RUNNER_OS" = "Linux" ]; then + RUN=(xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24") + fi + # --version prints without starting the GUI, so it needs no display. npx electron --no-sandbox --version - npx electron --no-sandbox test/electron-load-test.js + "${RUN[@]}" npx electron --no-sandbox test/electron-load-test.js diff --git a/.github/workflows/nodejs-arm64.yml b/.github/workflows/nodejs-arm64.yml index 7f0ff9d..83d7c0b 100644 --- a/.github/workflows/nodejs-arm64.yml +++ b/.github/workflows/nodejs-arm64.yml @@ -7,58 +7,46 @@ on: jobs: build-arm64: - name: Build and Test on Node 22.x - Linux ARM64 - runs-on: ubuntu-latest + name: Build and Test on Node ${{ matrix.node-version }} - Linux ARM64 + runs-on: ubuntu-24.04-arm + + strategy: + fail-fast: false + matrix: + node-version: ['22', '24'] steps: - name: Checkout code uses: actions/checkout@v4 - - name: Build and Test on ARM64 - uses: uraimo/run-on-arch-action@v2 + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 with: - arch: aarch64 - distro: ubuntu22.04 - - # Docker options to improve QEMU compatibility - dockerRunArgs: | - --platform linux/arm64/v8 - - # Install dependencies in the container - install: | - apt-get update -q -y - apt-get install -q -y ca-certificates curl gnupg build-essential python3 git - # Install Node.js 22 - mkdir -p /etc/apt/keyrings - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg - 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 - apt-get update -q -y - apt-get install -q -y nodejs - node --version - npm --version - - # Run build and tests - run: | - echo "Running on ARM64 architecture" - node --version - npm --version - - # Set environment variables to help with QEMU/node-gyp compatibility - export npm_config_jobs=1 - export JOBS=1 - - echo "Installing dependencies..." - npm install - - echo "Running tests..." - npm test - - echo "Verifying native module..." - if [ -f "build/Release/sqlanywhere.node" ]; then - echo "✓ Native module built successfully" - ls -lh build/Release/sqlanywhere.node - file build/Release/sqlanywhere.node || true - else - echo "✗ Native module NOT found" - exit 1 - fi + node-version: ${{ matrix.node-version }} + + - name: Show tool versions + run: | + node --version + npm --version + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential python3 + + - name: Install npm dependencies + run: npm install + + - name: Run tests + run: npm test + + - name: Verify native module + run: | + if [ -f "build/Release/sqlanywhere.node" ]; then + echo "✓ Native module built successfully" + ls -lh build/Release/sqlanywhere.node + file build/Release/sqlanywhere.node || true + else + echo "✗ Native module NOT found" + exit 1 + fi diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 0151a99..7ee8bba 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -13,19 +13,20 @@ jobs: strategy: fail-fast: false matrix: - include: - # macOS ARM64 (Apple Silicon) - - os: macos-latest - node-version: 22.x - # macOS x64 (Intel) - - os: macos-14 - node-version: 22.x - # Linux x64 - - os: ubuntu-latest - node-version: 22.x - # Windows x64 + # macos-latest = ARM64 (Apple Silicon), macos-14 = x64 (Intel), + # ubuntu-latest = Linux x64, windows-latest = Windows x64 + os: [macos-latest, macos-14, ubuntu-latest, windows-latest] + node-version: ['22', '24'] + exclude: + # windows-latest ships Visual Studio 2026, which the node-gyp + # bundled with Node 22's npm (11.5.0) cannot identify - VS 18 + # support landed in node-gyp 12.2.0. Node 24's npm ships 12.4.0. - os: windows-latest - node-version: 22.x + node-version: '22' + include: + # ...so Node 22 builds against VS 2022 on the older image instead. + - os: windows-2022 + node-version: '22' steps: - name: Checkout code @@ -36,6 +37,12 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: Show tool versions + shell: bash + run: | + node --version + npm --version + - name: Install dependencies (Linux) if: runner.os == 'Linux' run: | @@ -47,10 +54,6 @@ jobs: run: | # Xcode Command Line Tools should be pre-installed - - name: Setup MSVC (Windows) - if: runner.os == 'Windows' - uses: ilammy/msvc-dev-cmd@v1 - - name: Install npm dependencies run: npm install diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..6ea5a7e --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +node = "24" diff --git a/package-lock.json b/package-lock.json index 879c699..ed94ebd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "sqlanywhere", - "version": "2.0.3", + "version": "2.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "sqlanywhere", - "version": "2.0.3", + "version": "2.0.6", "hasInstallScript": true, "dependencies": { "help": "^3.0.2", - "nan": "^2.24.0" + "nan": "^2.28.0" }, "devDependencies": { "mocha": "^10.2.0" @@ -629,9 +629,9 @@ "license": "MIT" }, "node_modules/nan": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.24.0.tgz", - "integrity": "sha512-Vpf9qnVW1RaDkoNKFUvfxqAbtI8ncb8OJlqZ9wwpXzWPEsvsB1nvdUi6oYrHIkQ1Y/tMDnr1h4nczS0VB9Xykg==", + "version": "2.28.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.28.0.tgz", + "integrity": "sha512-fTsDz99OTq2sVePhGdp4qQhggZFtKr64ZNVyVajRKtMOkJxYekplBh577PiJB12v/D3s2E5cGtOI45LWp6rnLQ==", "license": "MIT" }, "node_modules/normalize-path": { @@ -1345,9 +1345,9 @@ "dev": true }, "nan": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.24.0.tgz", - "integrity": "sha512-Vpf9qnVW1RaDkoNKFUvfxqAbtI8ncb8OJlqZ9wwpXzWPEsvsB1nvdUi6oYrHIkQ1Y/tMDnr1h4nczS0VB9Xykg==" + "version": "2.28.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.28.0.tgz", + "integrity": "sha512-fTsDz99OTq2sVePhGdp4qQhggZFtKr64ZNVyVajRKtMOkJxYekplBh577PiJB12v/D3s2E5cGtOI45LWp6rnLQ==" }, "normalize-path": { "version": "3.0.0", diff --git a/package.json b/package.json index 462bc4f..d81e478 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "SQL ANYWHERE", "name": "sqlanywhere", "description": "SQL Anywhere JavaScript Driver.", - "version": "2.0.5", + "version": "2.0.6", "repository": { "url": "https://github.com/sqlanywhere/node-sqlanywhere" }, @@ -16,7 +16,7 @@ }, "dependencies": { "help": "^3.0.2", - "nan": "^2.24.0" + "nan": "^2.28.0" }, "devDependencies": { "mocha": "^10.2.0" diff --git a/src/utils.cpp b/src/utils.cpp index 68b9822..08331ff 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -974,9 +974,16 @@ Connection::Connection(const FunctionCallbackInfo &args) if (args[0]->IsString()) { MaybeLocal str = args[0]->ToString(context); +#if V8_MAJOR_VERSION > 13 || ( V8_MAJOR_VERSION == 13 && V8_MINOR_VERSION >= 6 ) + size_t string_len = str.ToLocalChecked()->Utf8LengthV2(isolate); + char *buf = new char[string_len + 1]; + str.ToLocalChecked()->WriteUtf8V2(isolate, buf, string_len + 1, + String::WriteFlags::kNullTerminate); +#else int string_len = str.ToLocalChecked()->Utf8Length(isolate); char *buf = new char[string_len + 1]; str.ToLocalChecked()->WriteUtf8(isolate, buf); +#endif _arg.Reset(isolate, String::NewFromUtf8(isolate, buf).ToLocalChecked()); delete[] buf; }