Add documentation for failing builds on unmet thresholds#173
Add documentation for failing builds on unmet thresholds#173charlesdemers wants to merge 1 commit intoember-cli-code-coverage:masterfrom
Conversation
|
Could you share your I've tried running |
|
@cvx The /* eslint-env node */
module.exports = {
useBabelInstrumenter: true
};I think you’re getting an error because you’re using the released version of @kategengler @rwwagner90 I’m guessing you’ll make a release when this is merged? |
|
I'm using the current master of ember-cli-code-coverage (because I wanted to check this feature out): Babel-plugin-istanbul is also in the latest version (4.1.6). Do you know which package specifically were those compatibility changes introduced in? |
|
I don’t know unfortunately... looking at their commit log there’s a bunch of updates for |
|
I thought this PR was all we needed? #169 The description said it was. @charlesdemers what version of ember-cli-code-coverage are you on? |
|
I'm still linking my |
|
@charlesdemers can you try using master and see if you encounter the same issue? |
|
I can reproduce the issue with master. The only difference is the code for the I won’t have much time until next week but I have a project which uses ember-exam, I’ll try and see if I can make it work without |
|
Ah, I see. @adamjmcgrath perhaps you could give some insight? |
I was able to reproduce the issue with a new ember app and your branch $ ember new foo
$ cd foo
$ ember install charlesdemers/ember-cli-code-coverage#6961be288d5666e0c8eae4d1988bbfac3773b433
$ npm install nyc
$ echo "module.exports = { reporters: ['json-summary'] }" > config/coverage.js
$ echo '{"temp-directory":"coverage"}' > .nycrc
$ COVERAGE=true ember t
$ nyc check-coverage
/Users/adam/dev/tmp/foo/node_modules/nyc/node_modules/yargs/yargs.js:1133
else throw err
^
Error: Invalid file coverage object, missing keys, found:lines,statements,functions,branches
at assertValidObject (/Users/adam/dev/tmp/foo/node_modules/nyc/node_modules/istanbul-lib-coverage/lib/file.js:129:15)
at new FileCoverage (/Users/adam/dev/tmp/foo/node_modules/nyc/node_modules/istanbul-lib-coverage/lib/file.js:164:5)
at /Users/adam/dev/tmp/foo/node_modules/nyc/node_modules/istanbul-lib-coverage/lib/coverage-map.js:17:23
at Array.forEach (<anonymous>)
at loadMap (/Users/adam/dev/tmp/foo/node_modules/nyc/node_modules/istanbul-lib-coverage/lib/coverage-map.js:12:25)
at new CoverageMap (/Users/adam/dev/tmp/foo/node_modules/nyc/node_modules/istanbul-lib-coverage/lib/coverage-map.js:34:21)
at CoverageMap.merge (/Users/adam/dev/tmp/foo/node_modules/nyc/node_modules/istanbul-lib-coverage/lib/coverage-map.js:49:17)
at /Users/adam/dev/tmp/foo/node_modules/nyc/index.js:429:9
at Array.forEach (<anonymous>)
at NYC._getCoverageMapFromAllCoverageFiles (/Users/adam/dev/tmp/foo/node_modules/nyc/index.js:428:22)I can only assume that the latest $ npm list nyc
foo@0.0.0 /Users/adam/dev/tmp/foo
└── nyc@11.6.0
$ npm list babel-plugin-istanbul
foo@0.0.0 /Users/adam/dev/tmp/foo
└─┬ ember-cli-code-coverage@1.0.0-beta.3 (github:charlesdemers/ember-cli-code-coverage#6961be288d5666e0c8eae4d1988bbfac3773b433)
└── babel-plugin-istanbul@4.1.6 |
Sorry, that should read "...with the reports generated by |
|
I think there is a newer version of |
It turns out What's in master doesn't work with Not sure what to suggest, you could work around it by suggesting people do: |
$ ember new foo
$ cd foo
$ ember install kategengler/ember-cli-code-coverage#master
$ npm install nyc
$ echo "module.exports = { reporters: ['json'] }" > config/coverage.js
$ echo '{"temp-directory":"coverage", "functions": 100}' > .nycrc
$ COVERAGE=true ember t
$ rm coverage/coverage-summary.json
$ nyc check-coverage
ERROR: Coverage for lines (0%) does not meet threshold (90%) for /Users/adam/dev/tmp/foo/app/app.js
ERROR: Coverage for lines (0%) does not meet threshold (90%) for /Users/adam/dev/tmp/foo/app/router.js
ERROR: Coverage for functions (0%) does not meet threshold (100%) for /Users/adam/dev/tmp/foo/app/router.js
... |
|
@adamjmcgrath do we need that summary? |
|
Sure, would be nice if we could make this compatible with nyc - but I can't see an obvious fix for this issue |
|
@adamjmcgrath what if we added the |
|
Unfortunately not, You'd need to make |
|
@adamjmcgrath ah, I see. What about if we added another folder underneath @kategengler any thoughts on how to handle this? |
|
I need to look into it a bit more, but since |
Would someone want to open an issue to discuss? I can open one, but I don't know much about nyc, so it might be better coming from someone else. |
|
I also don't know anything about `nyc` but I will open the issue if nobody
else wants to do so.
…On Tue, Apr 17, 2018 at 9:47 AM, Robert Wagner ***@***.***> wrote:
this should probably be fixed on the nyc side
Would someone want to open an issue to discuss? I can open one, but I
don't know much about nyc, so it might be better coming from someone else.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#173 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAbHOkKjnLgWAAxp1Ua3ZMtllf_TJvSiks5tpfJ2gaJpZM4TQZRR>
.
|
|
@kategengler I can open it. Will do so now. |
|
Issue filed istanbuljs/nyc#815. If anyone has extra things to add to it, please feel free to. |
|
@adamjmcgrath @charlesdemers does this happen to "just work" yet? I know nyc has released some new versions. |
|
@rwwagner90 I confirm, it works with these versions in my current project at work 🎉 "ember-cli-code-coverage": "1.0.0-beta.6",
"nyc": "13.1.0" |
|
I spoke too quick, the issue is still present 😞 |
|
@charlesdemers any ideas what the issue is or how we could help figure out a fix? |
|
I tried my fork with the latest I really don’t know how to fix this on our end, other than remove the |
|
@charlesdemers what if we run |
| ```json | ||
| "scripts": { | ||
| "test": "COVERAGE=true ember test", | ||
| "check-coverage": "./node_modules/.bin/nyc check-coverage" |
There was a problem hiding this comment.
👋 Istanbul member here - how does ember produce the coverage result?
Does it do the instrumentation? In which case you would want to set instrument: false in your nyc config.
Finally, if it produces a coverage report, I think you would want this command to be nyc report --report-dir ./custom-report-dir, but I don't think you can have it actually fail based on the coverage check/watermarks if nyc is not doing the instrumenting. Correct me if I'm wrong @bcoe @coreyfarrell
There was a problem hiding this comment.
I'm not sure the nyc report sub-command checks watermarks, I think it just generates reports. I do know that nyc checks watermarks, for example one of my projects vinyl-rollup uses instrument: false and coverage check works. If you add unreachable code to index.mjs it'll fail due to insufficient coverage, nyc exits with a non-zero code.
There was a problem hiding this comment.
@JaKXz Thanks for chiming in!
The instrumentation is done using babel-plugin-istanbul at build time.
The reports are generated using istanbul-api (https://github.com/kategengler/ember-cli-code-coverage/blob/master/lib/attach-middleware.js#L35) in a middleware that receives the coverage data from browser-based tests.
It does sound like we'd need the nyc configuration suggested here: https://github.com/istanbuljs/nyc#use-with-babel-plugin-istanbul-for-babel-support
|
@rwwagner90 The |
|
Seeing the same error message: with the following versions: running .nyrc: config/coverage.js: PS: not clear following the above if babel-plugin-istanbul is needed, and if it is, what are the related settings / files to add |
|
The project seems to be under heavy refactoring and I don’t even use nyc anymore since it was not supported so I’m going to close this, feel free to create another issue to support checking thresholds |
|
ok :( anyone who has a better way to add coverage-based PR status checks, please feel free to share. |
As discussed in #23 I added the instructions to setup
nycto fail the build when coverage thresholds are not met.Feel free to make corrections, although I made my best, english is not my native language so… :)