Skip to content

Commit

Permalink
fix(ci): Expose linter results in the junit output
Browse files Browse the repository at this point in the history
This change will force linting on CI and expose any errors. It also
changes to using `tap-xunit` with a flattened output when generating
the junit report file. This solves a bug with tests missing when using
tap-mocha-reporter.

Semver: patch
  • Loading branch information
darinspivey committed Dec 16, 2020
1 parent 40c2508 commit c5123aa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
coverage
.nyc_output
.tap-output
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ coverage
.npm
.tap-output
Jenkinsfile
tools
8 changes: 2 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ pipeline {
npm.auth token: "${GITHUB_PACKAGES_TOKEN}"
}

sh """
npm install
"""
sh 'npm install'
}
}

Expand All @@ -73,9 +71,7 @@ pipeline {

post {
always {
sh 'cat .tap-output | ./node_modules/.bin/tap-mocha-reporter xunit > coverage/test.xml'

junit 'coverage/test.xml'
junit checksName: 'Test Results', testResults: 'coverage/*.xml'

publishHTML target: [
allowMissing: false,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"main": "index.js",
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "tap"
"test": "tools/test.sh"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -40,6 +39,7 @@
"eslint-config-logdna": "^2.0.0",
"nock": "^13.0.4",
"tap": "^14.10.8",
"tap-xunit": "^2.4.1",
"winston": "^3.3.3"
},
"eslintConfig": {
Expand Down Expand Up @@ -76,6 +76,6 @@
"files": [
"test/**/*.js"
],
"output-file": ".tap-output"
"output-file": "coverage/.tap-output"
}
}
14 changes: 14 additions & 0 deletions tools/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

export PATH="./node_modules/.bin:$PATH"

mkdir -p coverage

tap && npm run lint -- -f tap -o coverage/.lint-output

code=$?

cat coverage/.tap-output | tap-parser -t -f | tap-xunit > coverage/tap-results.xml
cat coverage/.lint-output | tap-parser -t -f | tap-xunit > coverage/lint-results.xml

exit $code

0 comments on commit c5123aa

Please sign in to comment.