diff --git a/.github/workflow/ci_ubuntu.yml b/.github/workflow/ci_ubuntu.yml new file mode 100644 index 000000000..ef8b94f07 --- /dev/null +++ b/.github/workflow/ci_ubuntu.yml @@ -0,0 +1,105 @@ +name: CI +on: + workflow_dispatch: + pull_request: + push: + tags: + - '*' +env: + FORCE_COLOR: 1 +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ubuntu-20.04 + host: + - x64 + target: + - x64 + node: + - 18 + include: + - os: windows-latest + node: 18 + host: x86 + target: x86 + - os: macos-m1 + node: 18 + host: arm64 + target: arm64 + name: ${{ matrix.os }} (host=${{ matrix.host }}, target=${{ matrix.target }}) + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + architecture: ${{ matrix.host }} + + - name: Add yarn (self-hosted) + if: matrix.os == 'macos-m1' + run: npm install -g yarn + + - name: Add setuptools for Python 3.12 (temp) + if: matrix.os != 'macos-m1' + run: pip install setuptools + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.3 + if: contains(matrix.os, 'windows') + with: + msbuild-architecture: ${{ matrix.target }} + + - name: Install dependencies + run: yarn install --ignore-scripts + + - name: Check Node compatibility + run: node tools/semver-check.js + + - name: Add env vars + shell: bash + run: | + echo "V=1" >> $GITHUB_ENV + + if [ "${{ matrix.target }}" = "x86" ]; then + echo "TARGET=ia32" >> $GITHUB_ENV + else + echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV + fi + + - name: Add Linux env vars + if: contains(matrix.os, 'ubuntu') + run: | + echo "CFLAGS=${CFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV + echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV + + - name: Build binaries + run: yarn prebuild --arch ${{ env.TARGET }} + + - name: Print binary info + if: contains(matrix.os, 'ubuntu') + run: | + ldd build/**/node_sqlite3.node + echo "---" + nm build/**/node_sqlite3.node | grep "GLIBC_" | c++filt || true + echo "---" + file build/**/node_sqlite3.node + + - name: Run tests + run: yarn test + + - name: Upload binaries to commit artifacts + uses: actions/upload-artifact@v4 + if: matrix.node == 18 + with: + name: prebuilt-binaries + path: prebuilds/* + retention-days: 7 + + - name: Upload binaries to GitHub Release + run: yarn upload --upload-all ${{ github.token }} + if: matrix.node == 18 && startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81c22d94b..8757331f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,6 @@ on: workflow_dispatch: pull_request: push: - branches: - - master tags: - '*' env: @@ -83,7 +81,7 @@ jobs: echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV - name: Build binaries - run: yarn prebuild -a ${{ env.TARGET }} + run: yarn prebuild --arch ${{ env.TARGET }} - name: Print binary info if: contains(matrix.os, 'ubuntu') diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml new file mode 100644 index 000000000..c477f6326 --- /dev/null +++ b/.github/workflows/ci_ubuntu.yml @@ -0,0 +1,102 @@ +name: CI in ubuntu +on: + workflow_dispatch: + pull_request: + push: + tags: + - '*' +env: + FORCE_COLOR: 1 +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + node: 18 + host: x86 + target: x86 + - os: macos-m1 + node: 18 + host: arm64 + target: arm64 + - os: unbuntu-20.04 + host: x64 + target: x64 + node: 18 + name: ${{ matrix.os }} (host=${{ matrix.host }}, target=${{ matrix.target }}) + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + architecture: ${{ matrix.host }} + + - name: Add yarn (self-hosted) + if: matrix.os == 'macos-m1' + run: npm install -g yarn + + - name: Add setuptools for Python 3.12 (temp) + if: matrix.os != 'macos-m1' + run: pip install setuptools + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.3 + if: contains(matrix.os, 'windows') + with: + msbuild-architecture: ${{ matrix.target }} + + - name: Install dependencies + run: yarn install --ignore-scripts + + - name: Check Node compatibility + run: node tools/semver-check.js + + - name: Add env vars + shell: bash + run: | + echo "V=1" >> $GITHUB_ENV + + if [ "${{ matrix.target }}" = "x86" ]; then + echo "TARGET=ia32" >> $GITHUB_ENV + else + echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV + fi + + - name: Add Linux env vars + if: contains(matrix.os, 'ubuntu') + run: | + echo "CFLAGS=${CFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV + echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV + + - name: Build binaries + run: yarn prebuild --arch ${{ env.TARGET }} + + - name: Print binary info + if: contains(matrix.os, 'ubuntu') + run: | + ldd build/**/*.node + echo "---" + nm build/**/*.node | grep "GLIBC_" | c++filt || true + echo "---" + file build/**/*.node + + - name: Run tests + run: yarn test + + - name: Upload binaries to commit artifacts + uses: actions/upload-artifact@v4 + if: matrix.node == 18 + with: + name: prebuilt-binaries + path: prebuilds/* + retention-days: 7 + + - name: Upload binaries to GitHub Release + run: yarn upload --upload-all ${{ github.token }} + if: matrix.node == 18 && startsWith(github.ref, 'refs/tags/') diff --git a/binding.gyp b/binding.gyp index a8fccd0c4..2962c0191 100644 --- a/binding.gyp +++ b/binding.gyp @@ -52,7 +52,7 @@ "src/node_sqlite3.cc", "src/statement.cc" ], - "defines": [ "NAPI_VERSION=<(napi_build_version)", "NAPI_DISABLE_CPP_EXCEPTIONS=1" ] + "defines": [ "NAPI_VERSION=6", "NAPI_DISABLE_CPP_EXCEPTIONS=1" ] } ] } diff --git a/lib/sqlite3-binding.js b/lib/sqlite3-binding.js index 98d1b91b7..697401ed6 100644 --- a/lib/sqlite3-binding.js +++ b/lib/sqlite3-binding.js @@ -1 +1 @@ -module.exports = require('bindings')('node_sqlite3.node'); +module.exports = require('node-gyp-build')(__dirname + "/../"); diff --git a/package.json b/package.json index ab413ff4a..da6e767e2 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,6 @@ "name": "Mapbox", "url": "https://mapbox.com/" }, - "binary": { - "napi_versions": [ - 3, - 6 - ] - }, "contributors": [ "Daniel Lockyer ", "Konstantin Käfer ", @@ -37,22 +31,23 @@ "deps/", "lib/*.js", "lib/*.d.ts", - "src/" + "src/", + "prebuilds/", + "pacakge.json" ], "repository": { "type": "git", "url": "https://github.com/TryGhost/node-sqlite3.git" }, "dependencies": { - "bindings": "^1.5.0", "node-addon-api": "^7.0.0", - "prebuild-install": "^7.1.1", + "node-gyp-build": "^4.8.4", "tar": "^6.1.11" }, "devDependencies": { "eslint": "8.56.0", "mocha": "10.2.0", - "prebuild": "12.1.0" + "prebuildify": "6.0.1" }, "peerDependencies": { "node-gyp": "8.x" @@ -66,8 +61,8 @@ "node-gyp": "8.x" }, "scripts": { - "install": "prebuild-install -r napi || node-gyp rebuild", - "prebuild": "prebuild --runtime napi --all --verbose", + "install": "node-gyp-build", + "prebuild": "prebuildify --target=18.17.0 --tag-libc", "rebuild": "node-gyp rebuild", "upload": "prebuild --verbose --prerelease", "test": "node test/support/createdb.js && mocha -R spec --timeout 480000"