Skip to content

Commit

Permalink
Bug fixes and improvements (vivlabs#1)
Browse files Browse the repository at this point in the history
parse coverage:

- return 100 when file is empty/completely skipped (was returning 1)
- 100% coverage for parse-coverage.js
- fix relative path calculation in github-comment.js
- compute common root
- format coverage:

new emojis in some cases
- fix path calculation for links to files in folders
- render main coverage link outside of pre tag
- don't show unchanged folders in overview
- add folder coverage under details
- 100% coverage for format-coverage.js
- fix links when common root has no coverage
- render markdown instead of html where possible
  • Loading branch information
marcello3d authored Dec 26, 2017
1 parent eb986e6 commit 4424d1d
Show file tree
Hide file tree
Showing 30 changed files with 1,489 additions and 319 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
path: coverage
destination: coverage
- run:
name: Post artifact comment to GitHub
name: Post Coverage Comment to GitHub
command: |
node src/cli.js
- deploy:
name: npm publish (pushed tags only)
name: npm publish (if applicable)
command: .circleci/deploy.sh

deployment:
Expand Down
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coverage/
node_modules/
lib/
test-report.xml
.idea
/coverage/
/node_modules/
/lib/
/test-report.xml
/.idea
18 changes: 18 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.1.0] - UNRELEASED

### Changes
- New comment format
- Use markdown in comment where possible
- Added link to project in comments
- New Emojis to cover more scenarios

### Fixes
- No longer return 1 when file is empty/skipped
- Fix file artifact links
- Fix non-workflow build artifact discovery
- Fix computation of artifact links with multiple folders

### Misc
- More code coverage/tests


## [1.0.0] - 2017-12-19

- Initial release
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coverage-github-reporter",
"version": "1.0.0",
"version": "1.1.0-alpha1",
"description": "Report Jest/Istanbul coverage statistics from CircleCI to GitHub",
"main": "index.js",
"repository": "https://github.com/vivlabs/coverage-github-reporter",
Expand All @@ -13,18 +13,27 @@
"lint": "standard",
"test": "cross-env NODE_ENV=test jest",
"test-dev": "cross-env NODE_ENV=test jest --watch --onlyChanged",
"test-ci": "cross-env NODE_ENV=test TEST_REPORT_PATH=coverage jest --coverage --ci --silent"
"test-ci": "cross-env NODE_ENV=test TEST_REPORT_PATH=coverage jest --coverage --ci --silent",
"precommit": "lint-staged"
},
"lint-staged": {
"*.js": [
"standard"
]
},
"dependencies": {
"args": "^3.0.8",
"circle-github-bot": "^0.4.0",
"cross-env": "^5.1.1",
"istanbul-lib-coverage": "^1.1.1",
"istanbul-lib-report": "^1.1.2",
"pad": "^2.0.3"
},
"devDependencies": {
"husky": "^0.14.3",
"jest": "^22.0.0",
"jest-junit-reporter": "^1.1.0",
"lint-staged": "^6.0.0",
"standard": "^10.0.3"
},
"jest": {
Expand Down
51 changes: 0 additions & 51 deletions src/__tests__/__snapshots__/format-coverage.js.snap

This file was deleted.

56 changes: 56 additions & 0 deletions src/__tests__/__snapshots__/github-comment.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`formatComment formats with changes 1`] = `
"
**[Code Coverage](http://example.com/artifacts/index.html): 30.00% 💔 +11.43% 😀**
<pre>
<a href=\\"http://example.com/artifacts/index.html\\">src/ </a> 10.00% 💔 -8.57% 😭
<a href=\\"http://example.com/artifacts/bot.js.html\\"> bot.js </a> 100.00% +100.00% 🎉
<a href=\\"http://example.com/artifacts/cli.js.html\\"> cli.js </a> 60.00% 💛 +60.00% 😍
<a href=\\"http://example.com/artifacts/format-coverage.js.html\\"> format-coverage.js</a> 35.00% 💔 -1.13% 😥
<a href=\\"http://example.com/artifacts/github-comment.js.html\\"> github-comment.js </a> 10.00% 💔 +10.00% 🙂
<a href=\\"http://example.com/artifacts/parse-coverage.js.html\\"> parse-coverage.js </a> 0.00% -13.64% 😱
<a href=\\"http://example.com/artifacts/new-file.js.html\\"> new-file.js </a> 0.00%
</pre>
<details>
<summary><strong>🗂 Folder Coverage</strong></summary>
<pre>
<a href=\\"http://example.com/artifacts/index.html\\">src/</a> 10.00% 💔
</pre>
</details>
<p>
From **Circle CI [build 2](http://example.com/build/2)** compared to [build 1](http://example.com/build/1) (from \`master\` branch) 🤖[coverage-github-reporter](https://github.com/vivlabs/coverage-github-reporter)"
`;
exports[`formatComment formats with no changes 1`] = `
"
**[Code Coverage](http://example.com/artifacts/index.html): 58.66% 💛**
<details>
<summary><strong>🗂 Folder Coverage</strong></summary>
<pre>
<a href=\\"http://example.com/artifacts/index.html\\">src/ </a> 0.00%
<a href=\\"http://example.com/artifacts/coverage/index.html\\">src/coverage/</a> 100.00%
</pre>
</details>
<p>
From **Circle CI [build 2](http://example.com/build/2)** compared to [build 1](http://example.com/build/1) (from \`master\` branch) 🤖[coverage-github-reporter](https://github.com/vivlabs/coverage-github-reporter)"
`;
exports[`formatComment formats with no prior build 1`] = `
"
**[Code Coverage](http://example.com/artifacts/index.html): 58.66% 💛**
<details>
<summary><strong>🗂 Folder Coverage</strong></summary>
<pre>
<a href=\\"http://example.com/artifacts/index.html\\">src/ </a> 0.00%
<a href=\\"http://example.com/artifacts/coverage/index.html\\">src/coverage/</a> 100.00%
</pre>
</details>
<p>
From **Circle CI [build 2](http://example.com/build/2)** 🤖[coverage-github-reporter](https://github.com/vivlabs/coverage-github-reporter)"
`;
57 changes: 0 additions & 57 deletions src/__tests__/__snapshots__/parse-coverage.js.snap

This file was deleted.

67 changes: 67 additions & 0 deletions src/__tests__/github-comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* eslint-env jest */

const { formatComment } = require('../github-comment')

describe('formatComment', () => {
it('formats with no prior build', () => {
expect(formatComment({
formatted: {
'changed': '',
'folders': `<pre>
<a href="http://example.com/artifacts/index.html">src/ </a> 0.00% ❌
<a href="http://example.com/artifacts/coverage/index.html">src/coverage/</a> 100.00% ✅
</pre>`,
'status': '58.66% 💛'
},
baseArtifactUrl: 'http://example.com/artifacts',
buildNum: 2,
buildUrl: 'http://example.com/build/2',
branch: 'master'
})).toMatchSnapshot()
})

it('formats with no changes', () => {
expect(formatComment({
formatted: {
'changed': '',
'folders': `<pre>
<a href="http://example.com/artifacts/index.html">src/ </a> 0.00% ❌
<a href="http://example.com/artifacts/coverage/index.html">src/coverage/</a> 100.00% ✅
</pre>`,
'status': '58.66% 💛'
},
baseArtifactUrl: 'http://example.com/artifacts',
buildNum: 2,
buildUrl: 'http://example.com/build/2',
priorBuildNum: 1,
priorBuildUrl: 'http://example.com/build/1',
branch: 'master'
})).toMatchSnapshot()
})

it('formats with changes', () => {
expect(formatComment({
formatted: {
'changed': `<pre>
<a href="http://example.com/artifacts/index.html">src/ </a> 10.00% 💔 -8.57% 😭
<a href="http://example.com/artifacts/bot.js.html"> bot.js </a> 100.00% ✅ +100.00% 🎉
<a href="http://example.com/artifacts/cli.js.html"> cli.js </a> 60.00% 💛 +60.00% 😍
<a href="http://example.com/artifacts/format-coverage.js.html"> format-coverage.js</a> 35.00% 💔 -1.13% 😥
<a href="http://example.com/artifacts/github-comment.js.html"> github-comment.js </a> 10.00% 💔 +10.00% 🙂
<a href="http://example.com/artifacts/parse-coverage.js.html"> parse-coverage.js </a> 0.00% ❌ -13.64% 😱
<a href="http://example.com/artifacts/new-file.js.html"> new-file.js </a> 0.00% ❌
</pre>`,
'folders': `<pre>
<a href="http://example.com/artifacts/index.html">src/</a> 10.00% 💔
</pre>`,
'status': '30.00% 💔 +11.43% 😀'
},
baseArtifactUrl: 'http://example.com/artifacts',
buildNum: 2,
buildUrl: 'http://example.com/build/2',
priorBuildNum: 1,
priorBuildUrl: 'http://example.com/build/1',
branch: 'master'
})).toMatchSnapshot()
})
})
14 changes: 0 additions & 14 deletions src/__tests__/parse-coverage.js

This file was deleted.

Loading

0 comments on commit 4424d1d

Please sign in to comment.