From 5ec2c0f8c59effc03fb71bed684f2b36a6f1a688 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 29 Aug 2024 09:30:52 -0400 Subject: [PATCH 01/16] add script to verify plugin yaml --- package.json | 3 +- scripts/verify-ci-config.js | 161 ++++++++++++++++++++++++++++++++++++ yarn.lock | 5 ++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 scripts/verify-ci-config.js diff --git a/package.json b/package.json index 008fd1f17d3..04d5c78e320 100644 --- a/package.json +++ b/package.json @@ -155,6 +155,7 @@ "sinon": "^16.1.3", "sinon-chai": "^3.7.0", "tap": "^16.3.7", - "tiktoken": "^1.0.15" + "tiktoken": "^1.0.15", + "yaml": "^2.5.0" } } diff --git a/scripts/verify-ci-config.js b/scripts/verify-ci-config.js new file mode 100644 index 00000000000..677b1833c04 --- /dev/null +++ b/scripts/verify-ci-config.js @@ -0,0 +1,161 @@ +'use strict' +/* eslint-disable no-console */ + +const fs = require('fs') +const path = require('path') +const util = require('util') +const proxyquire = require('proxyquire') +const yaml = require('yaml') +const semver = require('semver') +const { execSync } = require('child_process') +const Module = require('module') +if (!Module.isBuiltin) { + Module.isBuiltin = mod => Module.builtinModules.includes(mod) +} + +const nodeMajor = Number(process.versions.node.split('.')[0]) + +const names = fs.readdirSync(path.join(__dirname, '..', 'packages', 'datadog-instrumentations', 'src')) + .filter(file => file.endsWith('.js')) + .map(file => file.slice(0, -3)) + +const instrumentations = names.reduce((acc, key) => { + let instrumentations = [] + const name = key + + try { + loadInstFile(`${name}/server.js`, instrumentations) + loadInstFile(`${name}/client.js`, instrumentations) + } catch (e) { + loadInstFile(`${name}.js`, instrumentations) + } + + instrumentations = instrumentations.filter(i => i.versions) + if (instrumentations.length) { + acc[key] = instrumentations + } + + return acc +}, {}) + +const versions = {} + +function checkYaml (yamlPath) { + const yamlContent = yaml.parse(fs.readFileSync(yamlPath, 'utf8')) + + const rangesPerPluginFromYaml = {} + const rangesPerPluginFromInst = {} + for (const jobName in yamlContent.jobs) { + const job = yamlContent.jobs[jobName] + if (!job.env || !job.env.PLUGINS) continue + + const pluginName = job.env.PLUGINS + if (Module.isBuiltin(pluginName)) continue + const rangesFromYaml = getRangesFromYaml(job) + if (rangesFromYaml) { + if (!rangesPerPluginFromYaml[pluginName]) { + rangesPerPluginFromYaml[pluginName] = new Set() + } + rangesFromYaml.forEach(range => rangesPerPluginFromYaml[pluginName].add(range)) + const plugin = instrumentations[pluginName] + const allRangesForPlugin = new Set(plugin.map(x => x.versions).flat()) + rangesPerPluginFromInst[pluginName] = allRangesForPlugin + } + } + for (const pluginName in rangesPerPluginFromYaml) { + const yamlRanges = Array.from(rangesPerPluginFromYaml[pluginName]) + const instRanges = Array.from(rangesPerPluginFromInst[pluginName]) + const yamlVersions = getMatchingVersions(pluginName, yamlRanges) + const instVersions = getMatchingVersions(pluginName, instRanges) + if (!util.isDeepStrictEqual(yamlVersions, instVersions)) { + const opts = { colors: true } + const colors = x => util.inspect(x, opts) + errorMsg(pluginName, 'Mismatch', ` +Valid version ranges from YAML: ${colors(yamlRanges)} +Valid version ranges from INST: ${colors(instRanges)} +${mismatching(yamlVersions, instVersions)} +Note that versions may be dependent on Node.js version. This is Node.js v${colors(nodeMajor)} + +> These don't match the same sets of versions in npm. +> +> Please check ${yamlPath} and the instrumentations +> for ${pluginName} to see that the version ranges match.`.trim()) + } + } +} + +function loadInstFile (file, instrumentations) { + const instrument = { + addHook (instrumentation) { + instrumentations.push(instrumentation) + } + } + + const instPath = path.join(__dirname, `../packages/datadog-instrumentations/src/${file}`) + + proxyquire.noPreserveCache()(instPath, { + './helpers/instrument': instrument, + '../helpers/instrument': instrument + }) +} + +function getRangesFromYaml (job) { + // eslint-disable-next-line no-template-curly-in-string + if (job.env && job.env.PACKAGE_VERSION_RANGE && job.env.PACKAGE_VERSION_RANGE !== '${{ matrix.range }}') { + errorMsg(job.env.PLUGINS, 'ERROR in YAML', 'You must use matrix.range instead of env.PACKAGE_VERSION_RANGE') + process.exitCode = 1 + } + if (job.strategy && job.strategy.matrix && job.strategy.matrix['node-version']) { + const possibilities = [job.strategy.matrix] + if (job.strategy.matrix.include) { + possibilities.push(...job.strategy.matrix.include) + } + for (const possibility of possibilities) { + let nodeVersion = possibility['node-version'] + if (!Array.isArray(nodeVersion)) { + nodeVersion = [nodeVersion] + } + nodeVersion = nodeVersion.map(v => Number(v)) + if (nodeVersion.includes(nodeMajor)) { + return [possibility.range].flat() + } + } + } else if (job.strategy && job.strategy.matrix && job.strategy.matrix.range) { + return job.strategy.matrix.range + } + + return null +} + +function getMatchingVersions (name, ranges) { + if (!versions[name]) { + versions[name] = JSON.parse(execSync('npm show ' + name + ' versions --json').toString()) + } + return versions[name].filter(version => ranges.some(range => semver.satisfies(version, range))) +} + +checkYaml(path.join(__dirname, '..', '.github', 'workflows', 'plugins.yml')) +checkYaml(path.join(__dirname, '..', '.github', 'workflows', 'appsec.yml')) + +function mismatching (yamlVersions, instVersions) { + const yamlSet = new Set(yamlVersions) + const instSet = new Set(instVersions) + + const onlyInYaml = yamlVersions.filter(v => !instSet.has(v)) + const onlyInInst = instVersions.filter(v => !yamlSet.has(v)) + + const opts = { colors: true } + return [ + `Versions only in YAML: ${util.inspect(onlyInYaml, opts)}`, + `Versions only in INST: ${util.inspect(onlyInInst, opts)}` + ].join('\n') +} + +function errorMsg (pluginName, title, message) { + console.log('===========================================') + console.log(title + ' for ' + pluginName) + console.log('-------------------------------------------') + console.log(message) + console.log('\n') + process.exitCode = 1 +} diff --git a/yarn.lock b/yarn.lock index 54222f765ba..107dfd70f1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5252,6 +5252,11 @@ yaml@^1.10.2: resolved "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== +yaml@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.5.0.tgz#c6165a721cf8000e91c36490a41d7be25176cf5d" + integrity sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw== + yargs-parser@20.2.4: version "20.2.4" resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz" From 7df17846465814fc04c780757108314762d03878 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 29 Aug 2024 09:32:30 -0400 Subject: [PATCH 02/16] add github actions job to verify yaml --- .github/workflows/project.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index f7839ac941e..5a6c1bbf148 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -162,3 +162,15 @@ jobs: - run: yarn type:test - run: yarn type:doc + verify-yaml: + strategy: + matrix: + node-version: [16, 18, 20, 22] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/install + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: node scripts/verify-yaml.js From 8fff56838f426cd53772b271b381d0b038a7e672 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 29 Aug 2024 11:46:27 -0400 Subject: [PATCH 03/16] fix instrumentations --- .github/workflows/plugins.yml | 6 +++++- .../datadog-instrumentations/src/aerospike.js | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index d25535e2aab..ec5636c8739 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -16,6 +16,10 @@ concurrency: jobs: aerospike-node-16: + strategy: + matrix: + node-version: [16] + range: ['>=4.0.0 <5.2.0'] runs-on: ubuntu-latest services: aerospike: @@ -25,7 +29,7 @@ jobs: env: PLUGINS: aerospike SERVICES: aerospike - PACKAGE_VERSION_RANGE: '>=4.0.0 <5.2.0' + PACKAGE_VERSION_RANGE: '${{ matrix.range }}' steps: - uses: actions/checkout@v4 - uses: ./.github/actions/testagent/start diff --git a/packages/datadog-instrumentations/src/aerospike.js b/packages/datadog-instrumentations/src/aerospike.js index 724c518e050..99c9d768b59 100644 --- a/packages/datadog-instrumentations/src/aerospike.js +++ b/packages/datadog-instrumentations/src/aerospike.js @@ -37,10 +37,23 @@ function wrapProcess (process) { } } +const versions = (() => { + switch (process.versions.node.split('.')[0]) { + case '16': + return ['>=4 <5.2.0'] + case '18': + return ['5.2.0 - 5.7.0'] + case '20': + return ['>=5.8.0'] + default: + return [] + } +})() + addHook({ name: 'aerospike', file: 'lib/commands/command.js', - versions: ['^3.16.2', '4', '5'] + versions }, commandFactory => { return shimmer.wrapFunction(commandFactory, f => wrapCreateCommand(f)) From 8fbf0284cf47fea25d3216331715218a4f887a2f Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 29 Aug 2024 16:09:38 -0400 Subject: [PATCH 04/16] fix up aerospike --- .github/workflows/plugins.yml | 62 +++---------------- .../datadog-instrumentations/src/aerospike.js | 9 +-- 2 files changed, 13 insertions(+), 58 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index ec5636c8739..8dc5103b860 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -15,58 +15,23 @@ concurrency: jobs: - aerospike-node-16: + aerospike: strategy: matrix: node-version: [16] range: ['>=4.0.0 <5.2.0'] - runs-on: ubuntu-latest - services: - aerospike: - image: aerospike:ce-5.7.0.15 - ports: - - "127.0.0.1:3000-3002:3000-3002" - env: - PLUGINS: aerospike - SERVICES: aerospike - PACKAGE_VERSION_RANGE: '${{ matrix.range }}' - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/testagent/start - - uses: ./.github/actions/node/setup - - id: pkg - run: | - content=`cat ./package.json | tr '\n' ' '` - echo "json=$content" >> $GITHUB_OUTPUT - - id: extract - run: | - version="${{fromJson(steps.pkg.outputs.json).version}}" - majorVersion=$(echo "$version" | cut -d '.' -f 1) - echo "Major Version: $majorVersion" - echo "MAJOR_VERSION=$majorVersion" >> $GITHUB_ENV - - uses: ./.github/actions/node/oldest - - name: Install dependencies - if: env.MAJOR_VERSION == '4' - uses: ./.github/actions/install - - name: Run tests - if: env.MAJOR_VERSION == '4' - run: yarn test:plugins:ci - - if: always() - uses: ./.github/actions/testagent/logs - - uses: codecov/codecov-action@v3 - - aerospike-node-18-20: - strategy: - matrix: - node-version: [18] - range: ['5.2.0 - 5.7.0'] + aerospike-image: [ce-5.7.0.15] include: + - node-version: 18 + range: '5.2.0 - 5.7.0' + aerospike-image: ce-6.4.0.3 - node-version: 20 range: '>=5.8.0' + aerospike-image: ce-6.4.0.3 runs-on: ubuntu-latest services: aerospike: - image: aerospike:ce-6.4.0.3 + image: aerospike:${{ matrix.aerospike-image }} ports: - "127.0.0.1:3000-3002:3000-3002" env: @@ -77,24 +42,13 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/testagent/start - uses: ./.github/actions/node/setup - - id: pkg - run: | - content=`cat ./package.json | tr '\n' ' '` - echo "json=$content" >> $GITHUB_OUTPUT - - id: extract - run: | - version="${{fromJson(steps.pkg.outputs.json).version}}" - majorVersion=$(echo "$version" | cut -d '.' -f 1) - echo "Major Version: $majorVersion" - echo "MAJOR_VERSION=$majorVersion" >> $GITHUB_ENV - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - run: yarn config set ignore-engines true - name: Install dependencies - if: env.MAJOR_VERSION == '5' uses: ./.github/actions/install - name: Run tests - if: env.MAJOR_VERSION == '5' run: yarn test:plugins:ci - if: always() uses: ./.github/actions/testagent/logs diff --git a/packages/datadog-instrumentations/src/aerospike.js b/packages/datadog-instrumentations/src/aerospike.js index 99c9d768b59..7f4e9c34df2 100644 --- a/packages/datadog-instrumentations/src/aerospike.js +++ b/packages/datadog-instrumentations/src/aerospike.js @@ -4,6 +4,7 @@ const { addHook } = require('./helpers/instrument') const shimmer = require('../../datadog-shimmer') +const { NODE_MAJOR } = require('../../../version') const tracingChannel = require('dc-polyfill').tracingChannel const ch = tracingChannel('apm:aerospike:command') @@ -38,12 +39,12 @@ function wrapProcess (process) { } const versions = (() => { - switch (process.versions.node.split('.')[0]) { - case '16': + switch (NODE_MAJOR) { + case 16: return ['>=4 <5.2.0'] - case '18': + case 18: return ['5.2.0 - 5.7.0'] - case '20': + case 20: return ['>=5.8.0'] default: return [] From 3dfa42346ffb5dbee08285013f2380c5f6599f52 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 29 Aug 2024 16:35:11 -0400 Subject: [PATCH 05/16] better version ranges for aerospike --- .github/workflows/plugins.yml | 3 +++ packages/datadog-instrumentations/src/aerospike.js | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 8dc5103b860..908c73e7887 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -28,6 +28,9 @@ jobs: - node-version: 20 range: '>=5.8.0' aerospike-image: ce-6.4.0.3 + - node-version: latest + range: '>=5.8.0' + aerospike-image: ce-6.4.0.3 runs-on: ubuntu-latest services: aerospike: diff --git a/packages/datadog-instrumentations/src/aerospike.js b/packages/datadog-instrumentations/src/aerospike.js index 7f4e9c34df2..c33e3ea4adb 100644 --- a/packages/datadog-instrumentations/src/aerospike.js +++ b/packages/datadog-instrumentations/src/aerospike.js @@ -39,15 +39,17 @@ function wrapProcess (process) { } const versions = (() => { + switch (NODE_MAJOR) { case 16: + case 17: return ['>=4 <5.2.0'] case 18: + case 19: return ['5.2.0 - 5.7.0'] case 20: - return ['>=5.8.0'] default: - return [] + return ['>=5.8.0'] } })() From 8a8628049d912e0c38207472abac1d206e67278d Mon Sep 17 00:00:00 2001 From: Bryan English Date: Fri, 30 Aug 2024 14:34:28 -0400 Subject: [PATCH 06/16] fix ci script --- .github/workflows/project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 5a6c1bbf148..7f7dc914826 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -173,4 +173,4 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - run: node scripts/verify-yaml.js + - run: node scripts/verify-ci-config.js From 0010953572234118c31a724846c9d0e03c1981bc Mon Sep 17 00:00:00 2001 From: Bryan English Date: Fri, 30 Aug 2024 14:59:59 -0400 Subject: [PATCH 07/16] make it pass hopefully --- .github/workflows/plugins.yml | 8 ++++---- packages/datadog-instrumentations/src/aerospike.js | 11 +++++------ scripts/verify-ci-config.js | 4 +++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 908c73e7887..ad2e677e9cb 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -23,13 +23,13 @@ jobs: aerospike-image: [ce-5.7.0.15] include: - node-version: 18 - range: '5.2.0 - 5.7.0' + range: '>=5.2.0' aerospike-image: ce-6.4.0.3 - node-version: 20 - range: '>=5.8.0' + range: '>=5.5.0' aerospike-image: ce-6.4.0.3 - - node-version: latest - range: '>=5.8.0' + - node-version: 22 + range: '>=5.12.1' aerospike-image: ce-6.4.0.3 runs-on: ubuntu-latest services: diff --git a/packages/datadog-instrumentations/src/aerospike.js b/packages/datadog-instrumentations/src/aerospike.js index c33e3ea4adb..83a7e9c9c67 100644 --- a/packages/datadog-instrumentations/src/aerospike.js +++ b/packages/datadog-instrumentations/src/aerospike.js @@ -39,17 +39,16 @@ function wrapProcess (process) { } const versions = (() => { - switch (NODE_MAJOR) { case 16: - case 17: - return ['>=4 <5.2.0'] + return ['>=4.0.0 <5.2.0'] case 18: - case 19: - return ['5.2.0 - 5.7.0'] + return ['>=5.2.0'] case 20: + return ['>=5.5.0'] + case 22: + return ['>=5.12.1'] default: - return ['>=5.8.0'] } })() diff --git a/scripts/verify-ci-config.js b/scripts/verify-ci-config.js index 677b1833c04..8084fe072fe 100644 --- a/scripts/verify-ci-config.js +++ b/scripts/verify-ci-config.js @@ -117,7 +117,9 @@ function getRangesFromYaml (job) { } nodeVersion = nodeVersion.map(v => Number(v)) if (nodeVersion.includes(nodeMajor)) { - return [possibility.range].flat() + if (possibility.range) { + return [possibility.range].flat() + } } } } else if (job.strategy && job.strategy.matrix && job.strategy.matrix.range) { From 4db06d65c720fc4850863f59d89a2e09a9277427 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Fri, 30 Aug 2024 15:11:33 -0400 Subject: [PATCH 08/16] update license 3rdparty --- LICENSE-3rdparty.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 23c1fcda420..4ba4775b73c 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -72,6 +72,7 @@ dev,sinon,BSD-3-Clause,Copyright 2010-2017 Christian Johansen dev,sinon-chai,WTFPL and BSD-2-Clause,Copyright 2004 Sam Hocevar 2012–2017 Domenic Denicola dev,tap,ISC,Copyright 2011-2022 Isaac Z. Schlueter and Contributors dev,tiktoken,MIT,Copyright (c) 2022 OpenAI, Shantanu Jain +dev,yaml,ISC,Copyright Eemeli Aro file,aws-lambda-nodejs-runtime-interface-client,Apache 2.0,Copyright 2019 Amazon.com Inc. or its affiliates. All Rights Reserved. file,profile.proto,Apache license 2.0,Copyright 2016 Google Inc. file,is-git-url,MIT,Copyright (c) 2017 Jon Schlinkert. From 0cd676f3a79472d417d7281f97ff04fb09aa8d9c Mon Sep 17 00:00:00 2001 From: Bryan English Date: Wed, 11 Sep 2024 16:33:49 -0400 Subject: [PATCH 09/16] fix it no longer assuming nodejs versions --- .github/workflows/plugins.yml | 2 +- .../datadog-instrumentations/src/aerospike.js | 17 +-------------- scripts/verify-ci-config.js | 21 +++++++------------ 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index ad2e677e9cb..506ee418fc6 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: node-version: [16] - range: ['>=4.0.0 <5.2.0'] + range: ['>=3.16.2 <5.2.0'] aerospike-image: [ce-5.7.0.15] include: - node-version: 18 diff --git a/packages/datadog-instrumentations/src/aerospike.js b/packages/datadog-instrumentations/src/aerospike.js index 83a7e9c9c67..724c518e050 100644 --- a/packages/datadog-instrumentations/src/aerospike.js +++ b/packages/datadog-instrumentations/src/aerospike.js @@ -4,7 +4,6 @@ const { addHook } = require('./helpers/instrument') const shimmer = require('../../datadog-shimmer') -const { NODE_MAJOR } = require('../../../version') const tracingChannel = require('dc-polyfill').tracingChannel const ch = tracingChannel('apm:aerospike:command') @@ -38,24 +37,10 @@ function wrapProcess (process) { } } -const versions = (() => { - switch (NODE_MAJOR) { - case 16: - return ['>=4.0.0 <5.2.0'] - case 18: - return ['>=5.2.0'] - case 20: - return ['>=5.5.0'] - case 22: - return ['>=5.12.1'] - default: - } -})() - addHook({ name: 'aerospike', file: 'lib/commands/command.js', - versions + versions: ['^3.16.2', '4', '5'] }, commandFactory => { return shimmer.wrapFunction(commandFactory, f => wrapCreateCommand(f)) diff --git a/scripts/verify-ci-config.js b/scripts/verify-ci-config.js index 8084fe072fe..7a917132688 100644 --- a/scripts/verify-ci-config.js +++ b/scripts/verify-ci-config.js @@ -105,25 +105,18 @@ function getRangesFromYaml (job) { errorMsg(job.env.PLUGINS, 'ERROR in YAML', 'You must use matrix.range instead of env.PACKAGE_VERSION_RANGE') process.exitCode = 1 } - if (job.strategy && job.strategy.matrix && job.strategy.matrix['node-version']) { + if (job.strategy && job.strategy.matrix && job.strategy.matrix.range) { const possibilities = [job.strategy.matrix] if (job.strategy.matrix.include) { possibilities.push(...job.strategy.matrix.include) } - for (const possibility of possibilities) { - let nodeVersion = possibility['node-version'] - if (!Array.isArray(nodeVersion)) { - nodeVersion = [nodeVersion] + return possibilities.map(possibility => { + if (possibility.range) { + return [possibility.range].flat() + } else { + return undefined } - nodeVersion = nodeVersion.map(v => Number(v)) - if (nodeVersion.includes(nodeMajor)) { - if (possibility.range) { - return [possibility.range].flat() - } - } - } - } else if (job.strategy && job.strategy.matrix && job.strategy.matrix.range) { - return job.strategy.matrix.range + }).flat() } return null From a6e20ca3acfac348f016d89dcef5f95fd047c67b Mon Sep 17 00:00:00 2001 From: Bryan English Date: Wed, 11 Sep 2024 16:39:14 -0400 Subject: [PATCH 10/16] fix aerospike --- .github/workflows/plugins.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 506ee418fc6..628b91b5bd0 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -19,19 +19,27 @@ jobs: strategy: matrix: node-version: [16] - range: ['>=3.16.2 <5.2.0'] + range: ['>=4.0.0 <5.2.0'] aerospike-image: [ce-5.7.0.15] + test-image: [ubuntu-latest] include: + - node-version: 14 # yes, out of range, but the only way to test the oldest version + range: '^3.16.2' + aerospike-image: ce-5.7.0.15 + test-image: ubuntu-20.04 - node-version: 18 range: '>=5.2.0' aerospike-image: ce-6.4.0.3 + test-image: ubuntu-latest - node-version: 20 range: '>=5.5.0' aerospike-image: ce-6.4.0.3 + test-image: ubuntu-latest - node-version: 22 range: '>=5.12.1' aerospike-image: ce-6.4.0.3 - runs-on: ubuntu-latest + test-image: ubuntu-latest + runs-on: ${{ matrix.test-image }} services: aerospike: image: aerospike:${{ matrix.aerospike-image }} From 7b29bd86d7753704ce9ccfb006c35eca229ad0fc Mon Sep 17 00:00:00 2001 From: Bryan English Date: Wed, 11 Sep 2024 23:04:38 -0400 Subject: [PATCH 11/16] since node version is now ignored, run on only one version of node --- .github/workflows/project.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 7f7dc914826..3dd8475811e 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -163,14 +163,9 @@ jobs: - run: yarn type:doc verify-yaml: - strategy: - matrix: - node-version: [16, 18, 20, 22] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/node/setup - uses: ./.github/actions/install - - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - run: node scripts/verify-ci-config.js From b406d239152190de9fcddc1d8eee624feaaabab5 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 12 Dec 2024 16:37:25 -0500 Subject: [PATCH 12/16] fix next --- .github/workflows/appsec.yml | 2 +- .github/workflows/plugins.yml | 2 +- packages/datadog-instrumentations/src/next.js | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/appsec.yml b/.github/workflows/appsec.yml index 45edbde6ebc..17fc1bc971a 100644 --- a/.github/workflows/appsec.yml +++ b/.github/workflows/appsec.yml @@ -210,7 +210,7 @@ jobs: version: - 18 - latest - range: ['9.5.0', '11.1.4', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] + range: ['>=10.2.0 <11', '>=11.0.0 <12', '11.1.4', '>=12.0.0 <13', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] runs-on: ubuntu-latest env: PLUGINS: next diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 628b91b5bd0..fd02a3826b5 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -728,7 +728,7 @@ jobs: version: - 18 - latest - range: ['9.5.0', '11.1.4', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] + range: ['>=10.2.0 <11', '>=11.0.0 <12', '11.1.4', '>=12.0.0 <13', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] runs-on: ubuntu-latest env: PLUGINS: next diff --git a/packages/datadog-instrumentations/src/next.js b/packages/datadog-instrumentations/src/next.js index 56ce695fe76..c803ab9136a 100644 --- a/packages/datadog-instrumentations/src/next.js +++ b/packages/datadog-instrumentations/src/next.js @@ -2,7 +2,6 @@ const { channel, addHook } = require('./helpers/instrument') const shimmer = require('../../datadog-shimmer') -const { DD_MAJOR } = require('../../../version') const startChannel = channel('apm:next:request:start') const finishChannel = channel('apm:next:request:finish') @@ -221,7 +220,7 @@ addHook({ addHook({ name: 'next', - versions: DD_MAJOR >= 4 ? ['>=10.2 <11.1'] : ['>=9.5 <11.1'], + versions: ['>=10.2 <11.1'], file: 'dist/next-server/server/serve-static.js' }, serveStatic => shimmer.wrap(serveStatic, 'serveStatic', wrapServeStatic)) @@ -256,7 +255,7 @@ addHook({ name: 'next', versions: ['>=11.1 <13.2'], file: 'dist/server/next-serv addHook({ name: 'next', - versions: DD_MAJOR >= 4 ? ['>=10.2 <11.1'] : ['>=9.5 <11.1'], + versions: ['>=10.2 <11.1'], file: 'dist/next-server/server/next-server.js' }, nextServer => { const Server = nextServer.default From ebcf4efc42fcbbde468f7b6da7e9a06b2f42f036 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 12 Dec 2024 17:11:04 -0500 Subject: [PATCH 13/16] remove 12.0.0 to 12.1.x from next version range --- .github/workflows/appsec.yml | 2 +- .github/workflows/plugins.yml | 2 +- packages/datadog-instrumentations/src/next.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/appsec.yml b/.github/workflows/appsec.yml index 17fc1bc971a..fb6d1a8e5d3 100644 --- a/.github/workflows/appsec.yml +++ b/.github/workflows/appsec.yml @@ -210,7 +210,7 @@ jobs: version: - 18 - latest - range: ['>=10.2.0 <11', '>=11.0.0 <12', '11.1.4', '>=12.0.0 <13', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] + range: ['>=10.2.0 <11', '>=11.0.0 <12', '11.1.4', '>=12.2.0 <13', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] runs-on: ubuntu-latest env: PLUGINS: next diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index fd02a3826b5..b3555a6ed4b 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -728,7 +728,7 @@ jobs: version: - 18 - latest - range: ['>=10.2.0 <11', '>=11.0.0 <12', '11.1.4', '>=12.0.0 <13', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] + range: ['>=10.2.0 <11', '>=11.0.0 <12', '11.1.4', '>=12.2.0 <13', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] runs-on: ubuntu-latest env: PLUGINS: next diff --git a/packages/datadog-instrumentations/src/next.js b/packages/datadog-instrumentations/src/next.js index c803ab9136a..82bc2c657a9 100644 --- a/packages/datadog-instrumentations/src/next.js +++ b/packages/datadog-instrumentations/src/next.js @@ -214,7 +214,7 @@ addHook({ addHook({ name: 'next', - versions: ['>=11.1'], + versions: ['>=11.1 <12.0.0', '>=12.2.0'], file: 'dist/server/serve-static.js' }, serveStatic => shimmer.wrap(serveStatic, 'serveStatic', wrapServeStatic)) @@ -224,7 +224,7 @@ addHook({ file: 'dist/next-server/server/serve-static.js' }, serveStatic => shimmer.wrap(serveStatic, 'serveStatic', wrapServeStatic)) -addHook({ name: 'next', versions: ['>=11.1'], file: 'dist/server/next-server.js' }, nextServer => { +addHook({ name: 'next', versions: ['>=11.1 <12.0.0', '>=12.2.0'], file: 'dist/server/next-server.js' }, nextServer => { const Server = nextServer.default shimmer.wrap(Server.prototype, 'handleRequest', wrapHandleRequest) @@ -247,7 +247,7 @@ addHook({ name: 'next', versions: ['>=13.2'], file: 'dist/server/next-server.js' return nextServer }) -addHook({ name: 'next', versions: ['>=11.1 <13.2'], file: 'dist/server/next-server.js' }, nextServer => { +addHook({ name: 'next', versions: ['>=11.1 <12.0.0', '>=12.2.0 <13.2'], file: 'dist/server/next-server.js' }, nextServer => { const Server = nextServer.default shimmer.wrap(Server.prototype, 'handleApiRequest', wrapHandleApiRequest) return nextServer From 2fcd4267640dcd844ea6765529c5a3ba447289da Mon Sep 17 00:00:00 2001 From: Bryan English Date: Fri, 13 Dec 2024 12:32:36 -0500 Subject: [PATCH 14/16] lint --- packages/datadog-instrumentations/src/next.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/datadog-instrumentations/src/next.js b/packages/datadog-instrumentations/src/next.js index 82bc2c657a9..14fb81188f8 100644 --- a/packages/datadog-instrumentations/src/next.js +++ b/packages/datadog-instrumentations/src/next.js @@ -247,7 +247,14 @@ addHook({ name: 'next', versions: ['>=13.2'], file: 'dist/server/next-server.js' return nextServer }) -addHook({ name: 'next', versions: ['>=11.1 <12.0.0', '>=12.2.0 <13.2'], file: 'dist/server/next-server.js' }, nextServer => { +addHook({ + name: 'next', + versions: [ + '>=11.1 <12.0.0', + '>=12.2.0 <13.2' + ], + file: 'dist/server/next-server.js' +}, nextServer => { const Server = nextServer.default shimmer.wrap(Server.prototype, 'handleApiRequest', wrapHandleApiRequest) return nextServer From b5c8eb2ea3180c50d5994e03e0ce36651e2822c5 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Fri, 13 Dec 2024 16:03:00 -0500 Subject: [PATCH 15/16] remove explit 12.0 and 12.1 tests for next.js --- .github/workflows/appsec.yml | 2 +- .github/workflows/plugins.yml | 2 +- packages/datadog-instrumentations/src/next.js | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/appsec.yml b/.github/workflows/appsec.yml index fb6d1a8e5d3..17a4e66f15c 100644 --- a/.github/workflows/appsec.yml +++ b/.github/workflows/appsec.yml @@ -210,7 +210,7 @@ jobs: version: - 18 - latest - range: ['>=10.2.0 <11', '>=11.0.0 <12', '11.1.4', '>=12.2.0 <13', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] + range: ['>=10.2.0 <11', '>=11.0.0 <13', '11.1.4', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] runs-on: ubuntu-latest env: PLUGINS: next diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index b3555a6ed4b..0d726987248 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -728,7 +728,7 @@ jobs: version: - 18 - latest - range: ['>=10.2.0 <11', '>=11.0.0 <12', '11.1.4', '>=12.2.0 <13', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] + range: ['>=10.2.0 <11', '>=11.0.0 <13', '11.1.4', '>=13.0.0 <14', '13.2.0', '>=14.0.0 <=14.2.6', '>=14.2.7 <15', '>=15.0.0'] runs-on: ubuntu-latest env: PLUGINS: next diff --git a/packages/datadog-instrumentations/src/next.js b/packages/datadog-instrumentations/src/next.js index 14fb81188f8..770d340d567 100644 --- a/packages/datadog-instrumentations/src/next.js +++ b/packages/datadog-instrumentations/src/next.js @@ -214,7 +214,7 @@ addHook({ addHook({ name: 'next', - versions: ['>=11.1 <12.0.0', '>=12.2.0'], + versions: ['>=11.1'], file: 'dist/server/serve-static.js' }, serveStatic => shimmer.wrap(serveStatic, 'serveStatic', wrapServeStatic)) @@ -224,7 +224,7 @@ addHook({ file: 'dist/next-server/server/serve-static.js' }, serveStatic => shimmer.wrap(serveStatic, 'serveStatic', wrapServeStatic)) -addHook({ name: 'next', versions: ['>=11.1 <12.0.0', '>=12.2.0'], file: 'dist/server/next-server.js' }, nextServer => { +addHook({ name: 'next', versions: ['>=11.1'], file: 'dist/server/next-server.js' }, nextServer => { const Server = nextServer.default shimmer.wrap(Server.prototype, 'handleRequest', wrapHandleRequest) @@ -249,10 +249,7 @@ addHook({ name: 'next', versions: ['>=13.2'], file: 'dist/server/next-server.js' addHook({ name: 'next', - versions: [ - '>=11.1 <12.0.0', - '>=12.2.0 <13.2' - ], + versions: ['>=11.1 <13.2'], file: 'dist/server/next-server.js' }, nextServer => { const Server = nextServer.default From 72bf1cc746477f0c48ed2af8cde510bd673bae04 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Fri, 13 Dec 2024 16:07:49 -0500 Subject: [PATCH 16/16] remove version of aerospike that we don't actually support --- .github/workflows/plugins.yml | 4 ---- packages/datadog-instrumentations/src/aerospike.js | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 0d726987248..2a76db58145 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -23,10 +23,6 @@ jobs: aerospike-image: [ce-5.7.0.15] test-image: [ubuntu-latest] include: - - node-version: 14 # yes, out of range, but the only way to test the oldest version - range: '^3.16.2' - aerospike-image: ce-5.7.0.15 - test-image: ubuntu-20.04 - node-version: 18 range: '>=5.2.0' aerospike-image: ce-6.4.0.3 diff --git a/packages/datadog-instrumentations/src/aerospike.js b/packages/datadog-instrumentations/src/aerospike.js index 724c518e050..497a64aaf80 100644 --- a/packages/datadog-instrumentations/src/aerospike.js +++ b/packages/datadog-instrumentations/src/aerospike.js @@ -40,7 +40,7 @@ function wrapProcess (process) { addHook({ name: 'aerospike', file: 'lib/commands/command.js', - versions: ['^3.16.2', '4', '5'] + versions: ['4', '5'] }, commandFactory => { return shimmer.wrapFunction(commandFactory, f => wrapCreateCommand(f))