Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci-app] Add JUnit XML Report Upload #1367

Merged
merged 16 commits into from
May 28, 2021
Merged
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ node-core-base: &node-core-base
run:
name: Unit tests
command: yarn test:core:ci
- run:
name: Upload JUnit XML Report
command: yarn junit:upload:ci
- run:
name: Merge coverage report
command: yarn cover:merge
Expand Down
1 change: 1 addition & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dev,eslint-plugin-import,MIT,Copyright 2015 Ben Mosher
dev,eslint-plugin-node,MIT,Copyright 2015 Toru Nagashima
dev,eslint-plugin-promise,ISC,jden and other contributors
dev,eslint-plugin-standard,MIT,Copyright 2015 Jamund Ferguson
dev,mocha-junit-reporter,MIT,Copyright 2015 Michael Allen
dev,express,MIT,Copyright 2009-2014 TJ Holowaychuk 2013-2014 Roman Shtylman 2014-2015 Douglas Christopher Wilson
dev,get-port,MIT,Copyright Sindre Sorhus
dev,glob,ISC,Copyright Isaac Z. Schlueter and Contributors
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
"tdd": "node scripts/tdd.js",
"test": "SERVICES=* yarn services && mocha --exit --expose-gc 'packages/dd-trace/test/setup/node.js' 'packages/*/test/**/*.spec.js'",
"test:core": "mocha --exit --expose-gc --file packages/dd-trace/test/setup/core.js \"packages/dd-trace/test/**/*.spec.js\"",
"test:core:ci": "nyc --include \"packages/dd-trace/src/**/*.js\" -- npm run test:core",
"test:core:ci": "nyc --include \"packages/dd-trace/src/**/*.js\" -- npm run test:core -- --reporter=mocha-junit-reporter",
"test:plugins": "mocha --exit --file \"packages/dd-trace/test/setup/core.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/*.spec.js\"",
"test:plugins:ci": "yarn services && nyc --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins",
"test:integration": "mocha --timeout 30000 \"integration-tests/**/*.spec.js\"",
"leak:core": "node ./scripts/install_plugin_modules && (cd packages/memwatch && yarn) && NODE_PATH=./packages/memwatch/node_modules node --no-warnings ./node_modules/.bin/tape 'packages/dd-trace/test/leak/**/*.js'",
"leak:plugins": "yarn services && (cd packages/memwatch && yarn) && NODE_PATH=./packages/memwatch/node_modules node --no-warnings ./node_modules/.bin/tape \"packages/datadog-plugin-@($(echo $PLUGINS))/test/leak.js\"",
"cover:merge": "nyc merge ./.nyc_output ./.nyc_merge/$CIRCLE_JOB.json",
"cover:report": "nyc report -t ./.nyc_merge -n 'packages/**/*.js'",
"codecov": "codecov"
"codecov": "codecov",
"junit:upload:ci": "node ./scripts/junit_report.js",
"junit:upload": "datadog-ci junit upload --tags runtime.version:$CI_NODE_VERSION --service dd-trace-js-core-tests ./test-results.xml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does datadog-ci come from when running this if it's not in the dependencies?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what's the benefit of ever running this locally? Is there a way to differentiate between local and CI runs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I'll just remove this and run it on the junit_report script file

},
"repository": {
"type": "git",
Expand Down Expand Up @@ -99,6 +101,7 @@
"jszip": "^3.5.0",
"mkdirp": "^0.5.1",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^2.0.0",
"msgpack-lite": "^0.1.26",
"nock": "^11.3.3",
"nyc": "^14.1.1",
Expand Down
26 changes: 26 additions & 0 deletions scripts/junit_report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable no-console */

const semver = require('semver')
const { execSync } = require('child_process')

function uploadJUnitXMLReport () {
if (semver.lt(process.version, '10.24.1')) {
console.log('Node version incompatible with @datadog/datadog-ci. Skipping step.')
return
}
if (process.env.CIRCLE_PR_NUMBER) {
console.log('Running in a fork. Skipping step.')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return
}
// we install @datadog/datadog-ci
execSync('yarn add --dev @datadog/[email protected]', { stdio: 'inherit' })
// we execute the upload command
execSync('yarn junit:upload',
{
stdio: 'inherit',
env: { ...process.env, CI_NODE_VERSION: process.version }
}
)
}

uploadJUnitXMLReport()