diff --git a/.github/workflows/test-all-versions.yml b/.github/workflows/test-all-versions.yml index 934775c818..04d5e6772f 100644 --- a/.github/workflows/test-all-versions.yml +++ b/.github/workflows/test-all-versions.yml @@ -51,7 +51,7 @@ jobs: strategy: fail-fast: false matrix: - node: ["18", "20", "22"] + node: ["18", "20", "22", "24"] runs-on: ubuntu-latest services: mongo: diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 7c571d2d6d..af296ed5d6 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -48,6 +48,7 @@ jobs: - "20.6.0" - "20" - "22" + - "24" include: - node: 18 code-coverage: true diff --git a/package-lock.json b/package-lock.json index 2065cdaf52..89f56d3594 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11792,11 +11792,12 @@ "dev": true }, "node_modules/better-sqlite3": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.0.0.tgz", - "integrity": "sha512-1NnNhmT3EZTsKtofJlMox1jkMxdedILury74PwUbQBjWgo4tL4kf7uTAjU55mgQwjdzqakSTjkf+E1imrFwjnA==", + "version": "11.10.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.10.0.tgz", + "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==", "dev": true, "hasInstallScript": true, + "license": "MIT", "dependencies": { "bindings": "^1.5.0", "prebuild-install": "^7.1.1" @@ -32048,7 +32049,7 @@ "@opentelemetry/sdk-trace-node": "^2.0.0", "@types/mocha": "10.0.10", "@types/node": "18.18.14", - "better-sqlite3": "11.0.0", + "better-sqlite3": "^11.10.0", "knex": "3.1.0", "nyc": "17.1.0", "rimraf": "5.0.10", @@ -41149,7 +41150,7 @@ "@opentelemetry/semantic-conventions": "^1.33.1", "@types/mocha": "10.0.10", "@types/node": "18.18.14", - "better-sqlite3": "11.0.0", + "better-sqlite3": "^11.10.0", "knex": "3.1.0", "nyc": "17.1.0", "rimraf": "5.0.10", @@ -46448,9 +46449,9 @@ "dev": true }, "better-sqlite3": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.0.0.tgz", - "integrity": "sha512-1NnNhmT3EZTsKtofJlMox1jkMxdedILury74PwUbQBjWgo4tL4kf7uTAjU55mgQwjdzqakSTjkf+E1imrFwjnA==", + "version": "11.10.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.10.0.tgz", + "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==", "dev": true, "requires": { "bindings": "^1.5.0", diff --git a/packages/instrumentation-knex/package.json b/packages/instrumentation-knex/package.json index 206f6ebc1a..dc5ac86954 100644 --- a/packages/instrumentation-knex/package.json +++ b/packages/instrumentation-knex/package.json @@ -53,7 +53,7 @@ "@opentelemetry/sdk-trace-node": "^2.0.0", "@types/mocha": "10.0.10", "@types/node": "18.18.14", - "better-sqlite3": "11.0.0", + "better-sqlite3": "^11.10.0", "knex": "3.1.0", "nyc": "17.1.0", "rimraf": "5.0.10", diff --git a/packages/instrumentation-restify/.tav.yml b/packages/instrumentation-restify/.tav.yml index 8d354d0d58..371a7cad3f 100644 --- a/packages/instrumentation-restify/.tav.yml +++ b/packages/instrumentation-restify/.tav.yml @@ -2,11 +2,15 @@ restify: - versions: include: '>=10.0.0 <12' mode: latest-minors - node: ">=18" + node: ">=18 <24" commands: npm run test + env: + - SKIP_TEST_IF_DISABLED=true - versions: include: '>=4.1.0 <10' mode: max-7 node: "<18" commands: npm run test + env: + - SKIP_TEST_IF_DISABLED=true diff --git a/packages/instrumentation-restify/package.json b/packages/instrumentation-restify/package.json index 8e4217de21..8306de4012 100644 --- a/packages/instrumentation-restify/package.json +++ b/packages/instrumentation-restify/package.json @@ -18,7 +18,7 @@ "lint:readme": "node ../../scripts/lint-readme.js", "prepublishOnly": "npm run compile", "tdd": "yarn test -- --watch-extensions ts --watch", - "test": "nyc mocha 'test/**/*.ts'", + "test": "SKIP_TEST_IF_NODE_NEWER_THAN=23 nyc mocha --require '../../scripts/skip-test-if.js' 'test/**/*.ts'", "test-all-versions": "tav", "version:update": "node ../../scripts/version-update.js", "watch": "tsc -w" diff --git a/packages/instrumentation-tedious/.tav.yml b/packages/instrumentation-tedious/.tav.yml index f61f4456f7..688222b3f4 100644 --- a/packages/instrumentation-tedious/.tav.yml +++ b/packages/instrumentation-tedious/.tav.yml @@ -1,6 +1,13 @@ tedious: - versions: - include: ">=1.11.0 <12" + include: ">=1.11.0 <2" + mode: latest-majors + # tedious@1 uses tls.createSecurePair() which was removed in Node.js 24 + # (https://nodejs.org/api/all.html#DEP0064). + node: "<24" + commands: npm run test + - versions: + include: ">=2 <12" # 4.0.0 is broken: https://github.com/tediousjs/tedious/commit/4eceb48 exclude: "4.0.0" mode: latest-majors diff --git a/scripts/skip-test-if.js b/scripts/skip-test-if.js index 96be8c483e..8a0772619a 100644 --- a/scripts/skip-test-if.js +++ b/scripts/skip-test-if.js @@ -16,40 +16,62 @@ /** * This script can be used with `mocha --require ...` to support skipping - * tests if the current version of Node.js is too old. For example, say - * a package's unit tests cannot run with Node.js 14, but the CI unit tests - * run all package test with that version. + * tests if the current version of Node.js is too old or too new. For example, + * say a package's unit tests cannot run with Node.js 14, but the CI unit tests + * run all package tests with that version. * * 1. Change this in "package.json": * "test": "nyc mocha ...", - * to this: - * "test": "SKIP_TEST_IF_NODE_OLDER_THAN=18 nyc mocha --require '../../../scripts/skip-test-if.js' ... ", - * where `SKIP_TEST_IF_NODE_OLDER_THAN` indicates the minimum Node.js major - * version. + * to one of these: + * "test": "SKIP_TEST_IF_NODE_OLDER_THAN=18 nyc mocha --require '../../scripts/skip-test-if.js' ...", + * "test": "SKIP_TEST_IF_NODE_NEWER_THAN=22 nyc mocha --require '../../scripts/skip-test-if.js' ...", + * where `SKIP_TEST_IF_NODE_{OLDER|NEWER}_THAN` indicates a Node.js *major* + * version number. * - * 2. ".tav.yml" blocks should set SKIP_TEST_IF_DISABLE=true to + * 2. ".tav.yml" blocks should set SKIP_TEST_IF_DISABLED=true to * disable the skipping. Via this in each test block: * env: - * - SKIP_TEST_IF_DISABLE=true + * - SKIP_TEST_IF_DISABLED=true */ function skipTestIf() { - if (process.env.SKIP_TEST_IF_DISABLE) { + if (process.env.SKIP_TEST_IF_DISABLED) { return; } - const minNodeMajor = process.env.SKIP_TEST_IF_NODE_OLDER_THAN ?? Number(process.env.SKIP_TEST_IF_NODE_OLDER_THAN); - if (!minNodeMajor || isNaN(minNodeMajor)) { - console.warn('skip-test-if warning: set a minimum Node.js major version via SKIP_TEST_IF_NODE_OLDER_THAN='); + let minNodeMajor; + if (process.env.SKIP_TEST_IF_NODE_OLDER_THAN) { + minNodeMajor = Number(process.env.SKIP_TEST_IF_NODE_OLDER_THAN) + if (isNaN(minNodeMajor) || !Number.isInteger(minNodeMajor)) { + console.warn(`skip-test-if warning: ignoring invalid SKIP_TEST_IF_NODE_OLDER_THAN value: "${process.env.SKIP_TEST_IF_NODE_OLDER_THAN}"`); + minNodeMajor = undefined; + } + } + let maxNodeMajor; + if (process.env.SKIP_TEST_IF_NODE_NEWER_THAN) { + maxNodeMajor = Number(process.env.SKIP_TEST_IF_NODE_NEWER_THAN) + if (isNaN(maxNodeMajor) || !Number.isInteger(maxNodeMajor)) { + console.warn(`skip-test-if warning: ignoring invalid SKIP_TEST_IF_NODE_NEWER_THAN value: "${process.env.SKIP_TEST_IF_NODE_NEWER_THAN}"`); + maxNodeMajor = undefined; + } + } + + if (minNodeMajor === undefined && maxNodeMajor === undefined) { + console.warn('skip-test-if warning: skip-test-if.js was used, but no SKIP_TEST_IF_* envvars were set'); return; } const nodeMajor = Number(process.versions.node.split('.')[0]); - if (nodeMajor < minNodeMajor) { + if (minNodeMajor && nodeMajor < minNodeMajor) { process.stderr.write(`skip-test-if: skipping tests on old Node.js (${nodeMajor} < ${minNodeMajor})\n`); // "Skip" tests by exiting the process. Mocha is all in one process. process.exit(0); } + if (maxNodeMajor && nodeMajor > maxNodeMajor) { + process.stderr.write(`skip-test-if: skipping tests on too-new Node.js (${nodeMajor} > ${maxNodeMajor})\n`); + // "Skip" tests by exiting the process. Mocha is all in one process. + process.exit(0); + } } skipTestIf()