Skip to content

Commit 49bbd29

Browse files
committed
CI: Run spec files in datadog-instrumentations sub-dirs
Ensure that `*.spec.js` files inside of sub-directories of the `packages/datadog-instrumentations/test` folder are also run in CI. Today, there's a `helpers` directory, which currently contains a single spec file. Since this spec file isn't run during CI, it's been silently broken since 2022. Therefore, this commit also updates the spec file to work, by: - Fixing references to missing variables - Changing it from tap to mocha, as this is the style of the other spec files in the package
1 parent 598409d commit 49bbd29

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

.github/workflows/instrumentations.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,31 @@ concurrency:
1717

1818

1919
jobs:
20+
instrumentations-misc:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
- uses: ./.github/actions/testagent/start
25+
- uses: ./.github/actions/node/oldest-maintenance-lts
26+
- uses: ./.github/actions/install
27+
- run: yarn test:instrumentations:misc:ci
28+
shell: bash
29+
- uses: ./.github/actions/node/newest-maintenance-lts
30+
- run: yarn test:instrumentations:misc:ci
31+
shell: bash
32+
- uses: ./.github/actions/node/active-lts
33+
- run: yarn test:instrumentations:misc:ci
34+
shell: bash
35+
- uses: ./.github/actions/node/latest
36+
- run: yarn test:instrumentations:misc:ci
37+
shell: bash
38+
- uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1
39+
- if: always()
40+
uses: ./.github/actions/testagent/logs
41+
with:
42+
suffix: test-${{ github.job }}
2043

21-
# These ones don't have a plugin directory, but exist in the
44+
# These ones don't have a plugin directory, but exist in the root
2245
# instrumentations directory, so they need to be run somewhere. This seems to
2346
# be a reasonable place to run them for now.
2447

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"test:trace:core:ci": "npm run test:trace:core -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/**/*.js\"",
2929
"test:instrumentations": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/**/*.spec.js'",
3030
"test:instrumentations:ci": "nyc --no-clean --include 'packages/datadog-instrumentations/src/**/*.js' -- npm run test:instrumentations",
31+
"test:instrumentations:misc": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/*/**/*.spec.js'",
32+
"test:instrumentations:misc:ci": "nyc --no-clean --include 'packages/datadog-instrumentations/src/**/*.js' -- npm run test:instrumentations:misc",
3133
"test:core": "tap \"packages/datadog-core/test/**/*.spec.js\"",
3234
"test:core:ci": "npm run test:core -- --coverage --nyc-arg=--include=\"packages/datadog-core/src/**/*.js\"",
3335
"test:lambda": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/lambda/**/*.spec.js\"",

packages/datadog-instrumentations/test/helpers/instrument.spec.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
'use strict'
22

3-
require('../../../dd-trace/test/setup/tap')
4-
53
const { executionAsyncId } = require('async_hooks')
6-
const { expect } = require('chai')
74
const { storage } = require('../../../datadog-core')
85
const { AsyncResource } = require('../../src/helpers/instrument')
96

@@ -26,8 +23,8 @@ describe('helpers/instrument', () => {
2623

2724
const tested = AsyncResource.bind(function (a, b, c) {
2825
expect(this).to.equal(self)
29-
expect(test.asyncResource.asyncId()).to.equal(executionAsyncId())
30-
expect(test).to.have.length(3)
26+
expect(tested.asyncResource.asyncId()).to.equal(executionAsyncId())
27+
expect(tested).to.have.length(3)
3128
}, 'test', self)
3229

3330
tested()
@@ -40,8 +37,8 @@ describe('helpers/instrument', () => {
4037
storage('legacy').run('test2', () => {
4138
const tested = asyncResource.bind((a, b, c) => {
4239
expect(storage('legacy').getStore()).to.equal('test1')
43-
expect(test.asyncResource).to.equal(asyncResource)
44-
expect(test).to.have.length(3)
40+
expect(tested.asyncResource).to.equal(asyncResource)
41+
expect(tested).to.have.length(3)
4542
})
4643

4744
tested()

0 commit comments

Comments
 (0)