diff --git a/.github/docker/Dockerfile.glibc b/.github/docker/Dockerfile.glibc index e0a89d3..b6f833a 100644 --- a/.github/docker/Dockerfile.glibc +++ b/.github/docker/Dockerfile.glibc @@ -13,11 +13,10 @@ COPY . . RUN apt-get -qq update && apt-get -qq install -y python3 build-essential && ldd --version -RUN npm run install:libmongocrypt +RUN npm i --ddd ARG RUN_TEST -RUN [ -n "$RUN_TEST" ] && npm run test || echo 'skipping testing!' +RUN if [ -n "$RUN_TEST" ]; then npm test ; else echo "skipping tests" ; fi +# FROM scratch -FROM scratch - -COPY --from=build /mongodb-client-encryption/prebuilds/ / +# COPY --from=build /mongodb-client-encryption/prebuilds/ / diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dd07514..7b78bf5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,11 +20,11 @@ jobs: - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - cache: 'npm' - registry-url: 'https://registry.npmjs.org' + cache: "npm" + registry-url: "https://registry.npmjs.org" - name: Build with Node.js ${{ matrix.node }} on ${{ matrix.os }} - run: node .github/scripts/libmongocrypt.mjs ${{ runner.os == 'Windows' && '--build' || '' }} + run: npm i --ddd shell: bash - name: Test ${{ matrix.os }} @@ -37,6 +37,7 @@ jobs: matrix: linux_arch: [s390x, arm64, amd64] node: [16.x, 18.x, 20.x, 22.x] + fail-fast: false steps: - uses: actions/checkout@v4 @@ -60,7 +61,7 @@ jobs: - name: Run Buildx run: | docker buildx create --name builder --bootstrap --use - docker buildx build \ + docker buildx build \ --platform linux/${{ matrix.linux_arch }} \ --build-arg="NODE_ARCH=${{ matrix.linux_arch == 'amd64' && 'x64' || matrix.linux_arch }}" \ --build-arg="NODE_VERSION=${{ steps.get_nodejs_version.outputs.version }}" \ diff --git a/.mocharc.json b/.mocharc.json index 33df4eb..4fde4d0 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -11,5 +11,6 @@ "recursive": true, "failZero": true, "reporter": "test/tools/mongodb_reporter.js", - "color": true + "color": true, + "timeout": 0 } diff --git a/package-lock.json b/package-lock.json index 548a558..88fd5aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "bindings": "^1.5.0", "node-addon-api": "^4.3.0", "prebuild-install": "^7.1.2" }, @@ -31,7 +30,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", "mocha": "^10.8.2", - "node-gyp": "^10.1.0", + "node-gyp": "10.1.0", "prebuild": "^13.0.0", "prettier": "^3.2.5", "semver": "^7.6.2", @@ -1581,14 +1580,6 @@ "node": ">=8" } }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, "node_modules/bl": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.1.tgz", @@ -3405,11 +3396,6 @@ "node": ">=16.0.0" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -9353,14 +9339,6 @@ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "requires": { - "file-uri-to-path": "1.0.0" - } - }, "bl": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.1.tgz", @@ -10763,11 +10741,6 @@ "flat-cache": "^4.0.0" } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, "fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -13028,7 +13001,7 @@ "minimist": "^1.2.8", "napi-build-utils": "^1.0.2", "node-abi": "^3.54.0", - "node-gyp": "^10.1.0", + "node-gyp": "10.1.0", "node-ninja": "^1.0.2", "noop-logger": "^0.1.1", "npm-which": "^3.0.1", diff --git a/package.json b/package.json index 175b60d..6d0e6b6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "scripts": { "install:libmongocrypt": "node .github/scripts/libmongocrypt.mjs", - "install": "prebuild-install --runtime napi || node-gyp rebuild", + "install": "prebuild-install --download --runtime napi || node-gyp rebuild", "clang-format": "clang-format --style=file:.clang-format --Werror -i addon/*", "check:eslint": "ESLINT_USE_FLAT_CONFIG=false eslint src test", "check:clang-format": "clang-format --style=file:.clang-format --dry-run --Werror addon/*", @@ -37,7 +37,6 @@ "gypfile": true, "mongodb:libmongocrypt": "1.11.0", "dependencies": { - "bindings": "^1.5.0", "node-addon-api": "^4.3.0", "prebuild-install": "^7.1.2" }, @@ -58,7 +57,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", "mocha": "^10.8.2", - "node-gyp": "^10.1.0", + "node-gyp": "10.1.0", "prebuild": "^13.0.0", "prettier": "^3.2.5", "semver": "^7.6.2", @@ -97,4 +96,4 @@ "moduleResolution": "node" } } -} +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 85ab3d2..961f067 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,11 @@ +import { resolve } from 'path'; import { cryptoCallbacks } from './crypto_callbacks'; export { cryptoCallbacks }; -import bindings = require('bindings'); -const mc: MongoCryptBindings = bindings('mongocrypt'); +function loadBindings(): MongoCryptBindings { + return require(resolve(__dirname, '../build/Release/mongocrypt.node')); +} +const mc: MongoCryptBindings = loadBindings(); /** * The value returned by the native bindings