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
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ node-core-base: &node-core-base
run:
name: Unit tests
command: yarn test:core:ci
- store_test_results:
path: core-test-results
- run:
name: Upload JUnit XML Report
command: yarn junit:upload
- run:
name: Merge coverage report
command: yarn cover:merge
Expand Down
2 changes: 2 additions & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ 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,mocha-multi-reporters,MIT,Copyright 2015 Stanley Ng 2019 Yousaf Nabi
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
6 changes: 6 additions & 0 deletions mocha-reporter-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "./core-test-results/mocha/test-results.xml"
}
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
"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-multi-reporters --reporter-options configFile=mocha-reporter-config.json",
"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": "node ./scripts/junit_report.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -99,6 +100,8 @@
"jszip": "^3.5.0",
"mkdirp": "^0.5.1",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^2.0.0",
"mocha-multi-reporters": "^1.5.1",
"msgpack-lite": "^0.1.26",
"nock": "^11.3.3",
"nyc": "^14.1.1",
Expand Down
29 changes: 29 additions & 0 deletions scripts/junit_report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* 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 global add @datadog/[email protected]', { stdio: 'inherit' })
// we execute the upload command
execSync(
`datadog-ci junit upload \
--tags runtime.version:${process.version} \
--service dd-trace-js-core-tests \
./core-test-results/mocha/test-results.xml`,
{
stdio: 'inherit'
}
)
}

uploadJUnitXMLReport()