-
Notifications
You must be signed in to change notification settings - Fork 150
Codecov report generation using ava-nyc #148
Conversation
hey @suphalb, thanks! can you set this for CI as well? This way the coverage is uploaded to codecov.io (e.g.https://github.com/segmentio/analytics-android/blob/master/.circleci/config.yml#L23) |
Codecov Report
@@ Coverage Diff @@
## master #148 +/- ##
=======================================
Coverage ? 100%
=======================================
Files ? 1
Lines ? 96
Branches ? 0
=======================================
Hits ? 96
Misses ? 0
Partials ? 0 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation could've been way simpler: https://github.com/sindresorhus/got/blob/master/package.json#L28-L29. There's also no need for coverage-related text to be in the readme.
circle.yml
Outdated
@@ -18,3 +18,6 @@ test: | |||
- nvm use 4; npm rebuild &> /dev/null; npm run testci | |||
- nvm use 6; npm rebuild &> /dev/null; npm run testci | |||
- nvm use 8; npm rebuild &> /dev/null; npm run testci | |||
post: | |||
- npm test | |||
- ./node_modules/.bin/nyc report --reporter=lcov > coverage.lcov && bash <(curl -s https://codecov.io/bash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this just be npm run report-coverage
(from https://github.com/segmentio/analytics-node/pull/148/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R30)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@f2prateek . IN fact yes. On my local it's working almost in similar way. But over CircleCI it was not working so had to directlt run that cmd via yml to test if the report is actually generating and uploading. So far it's fulfilling the purpose . But Yes i will make it standard and will find out why it's not running as standard way.
package.json
Outdated
@@ -23,10 +23,11 @@ | |||
], | |||
"scripts": { | |||
"size": "size-limit", | |||
"test": "standard && ava", | |||
"test": "nyc ava tap test.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should still be running standard
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i am little confused here . So far i followed #148 (review) and made it minified / simplified. So will you let me know what should i follow here? I meant should i minify it as per @vadimdemedes request OR it will be same like my previous commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is we should still be running the standard
command as part of the test.
I believe @vadimdemedes pointed to https://github.com/sindresorhus/got/blob/master/package.json#L28-L29. From there xo
= standard
(both are code formatting tools).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok got it clearly @f2prateek . I am taking care of it quickly and coming back with correct commit.
readme.md
Outdated
@@ -28,7 +28,18 @@ client.track({ | |||
|
|||
Documentation is available at [https://segment.com/libraries/node](https://segment.com/libraries/node). | |||
|
|||
## Generate Codecoverage Report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add this information to the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, Already removed and while i will push my next commit it would be rectified.
circle.yml
Outdated
@@ -18,3 +18,6 @@ test: | |||
- nvm use 4; npm rebuild &> /dev/null; npm run testci | |||
- nvm use 6; npm rebuild &> /dev/null; npm run testci | |||
- nvm use 8; npm rebuild &> /dev/null; npm run testci | |||
post: | |||
- npm test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to run npm test
here? Lines 18-20 are already running a test command as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes in fact. But again the same problem i experienced . It works on my local but it seems over circle ci it doesn't generate any report. Ideally any JS inside of package.json should be executed via npm test automatically by circleCi. So to test it out i had to run that cmd individually just to ensure if reports are generating. Now i will make it standard .
circle.yml
Outdated
@@ -8,7 +8,7 @@ dependencies: | |||
- nvm install 4 | |||
- nvm install 6 | |||
- nvm install 8 | |||
- rm -rf node_modules | |||
- rm -rf 'node_modules coverage .nyc_output coverage.lcov' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is wrapped in quotes, the rm
program will try to delete a file called "node_modules coverage .nyc_output coverage.lcov". I suspect this is not what you had intended.
package.json
Outdated
"testci": "standard && ava && npm run size", | ||
"prepublish": "npm run check-deps", | ||
"check-deps": "nsp check" | ||
"test": "standard && nyc ava tap test.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the word "tap" doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for TAP format report output as console feedback from cmd?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
however it's not mandatory but just used for report formation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to specify it differently if you want AVA to output TAP: https://github.com/avajs/ava#tap-reporter
readme.md
Outdated
@@ -22,13 +22,10 @@ client.track({ | |||
userId: 'user id' | |||
}); | |||
``` | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We ought to keep a newline between these sections of the README.
circle.yml
Outdated
@@ -8,7 +8,8 @@ dependencies: | |||
- nvm install 4 | |||
- nvm install 6 | |||
- nvm install 8 | |||
- rm -rf 'node_modules coverage .nyc_output coverage.lcov' | |||
- rm -rf node_modules ; rm -rf coverage ; rm -rf .nyc_output ; rm -f coverage.lcov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to separate these with semicolons. The single command will work fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephenmathieson So removed those semicolons and surprisingly this time CircleCI accepted these traditional unix like cmd. Just bit clueless why it didn't get execute with same thing on my previous build before i added those semicolons and inverted commas .
As your suggestion reverted back the readme with it's original state removing all codecov related text etc.
regarding ava tap i followed the reference from here actually - https://github.com/istanbuljs/nyc.
In fact they referred to use it in same way like i did and i have been directed there by codecov nyc example . So as reference they say -
update the scripts in your package.json to include these bins:
{
"scripts": {
"test": "nyc tap ./test/*.js",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
}
}
Many testing frameworks (Mocha, Tape, Tap, etc.) can produce TAP output. tap-nyc is a TAP formatter designed to look nice with nyc.
I ran without tap param too however it generates the same output but without a nice serial output formation.
If you think we don't need it here certainly i can omit as it's not mandatory. Please suggest
So in fact it seems things are looking bit different for me over Circle
CI. So i tried usual unix style cmd in .yml config such as you mentioned
without semicolons . But strange that it even doesn't execute next
arguement after the first one as it does on traditional nix/unix shell. I
tried it couple of times but on CircleCI console output it doesn't show any
effect. Thus CircleCI simply omitted . So i tried with semicolons as well
as with inv commas.
Second things is same package.json file is being executed without any error
on my local stack but yes as it goes through circleCI it throws some error
and the build fails .
So here i would have to checkout if i am really missing something OR for
Circle CI if i need to use some different parameter/method in config file.
…On Wed, Jan 17, 2018 at 3:22 AM, Stephen Mathieson ***@***.*** > wrote:
***@***.**** commented on this pull request.
------------------------------
In circle.yml
<#148 (comment)>
:
> @@ -8,7 +8,8 @@ dependencies:
- nvm install 4
- nvm install 6
- nvm install 8
- - rm -rf 'node_modules coverage .nyc_output coverage.lcov'
+ - rm -rf node_modules ; rm -rf coverage ; rm -rf .nyc_output ; rm -f coverage.lcov
No need to separate these with semicolons. The single command will work
fine.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#148 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB8nY9KWMTFU51YaAXAKkXrKhI10ptMDks5tLRoYgaJpZM4RdJPk>
.
|
@vadimdemedes so i simplified & minified as you requested as per the
reference , seems that on local it runs without any problem but on CircleCI
the build fails as it seems other additional scripts are necessary for CI.
In fact for codecov line no 2 & last line is suffice but while it's on CI
all other params in scripts section are necessary. I tried 2 builds over CI
through more slimmer version like your given reference. However on my local
it worked flawless but while it's on CI the build failed. So i got back
them again without further refactoring. I would see if there would be any
space to refactor it.
…On Tue, Jan 16, 2018 at 6:10 PM, Vadim Demedes ***@***.***> wrote:
***@***.**** requested changes on this pull request.
The implementation could've been way simpler: https://github.com/
sindresorhus/got/blob/master/package.json#L28-L29. There's also no need
for coverage-related text to be in the readme.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#148 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB8nY2_dCAf9eCzkVyLvYSqHoo6DsORYks5tLJjBgaJpZM4RdJPk>
.
|
@suphalb I believe the issue you are seeing is that locally you are running In your PR you only updated the command for If you change the |
package.json
Outdated
@@ -22,11 +22,11 @@ | |||
} | |||
], | |||
"scripts": { | |||
"size": "size-limit", | |||
"test": "standard && ava", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@suphalb this was accidentally removed, can you put this back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@f2prateek - can you please consider this latest commit ? b0b7874
Seems this time the CI build was successful with the small tweaks you suggested.
package.json
Outdated
"testci": "standard && ava && npm run size", | ||
"prepublish": "npm run check-deps", | ||
"check-deps": "nsp check" | ||
"size": "size-limit", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is off by 1 here, which makes the diff harder to read. Can you leave it at the old indentation level?
@suphalb when you were using an example config I linked to, what was the error on Circle? If it works in other projects, it should as well just work here. |
@vadimdemedes - So here it is . Please refer Build test 185 to 188 as following - https://circleci.com/gh/segmentio/analytics-node/185. It seems if we consider only codecov and report uploading in fact you are correct that it should work and it was working on my Docker. But it seems for CircleCI there have been additional scripts + test run and those were failing if i remove those additional lines and simplify it only for codecov as your exacmple config. So far all other lines were there from earlier and i didn't refactor it completely. All i just added codecov integration with those previous definition. So going through @f2prateek's tweak suggestion i corrected and minified a bit and put everything inside of testCI run. Please let me know if i am missing anything here? |
readme.md
Outdated
@@ -32,3 +32,4 @@ Documentation is available at [https://segment.com/libraries/node](https://segme | |||
## License | |||
|
|||
Copyright © 2017 Segment Inc. \<friends@segment.com\> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove it.
package.json
Outdated
"prepublish": "npm run check-deps", | ||
"check-deps": "nsp check" | ||
"check-deps": "nsp check", | ||
"report-coverage": "nyc report --reporter=lcov > coverage.lcov && codecov" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> nyc report --reporter=text-lcov | coveralls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok here i am bit confused. I have been informed that we should be using codecov. So am just trying to know will it be codecov integration or coveralls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, ignore this comment.
package.json
Outdated
@@ -23,10 +23,10 @@ | |||
], | |||
"scripts": { | |||
"size": "size-limit", | |||
"test": "standard && ava", | |||
"testci": "standard && ava && npm run size", | |||
"testci": "standard && nyc ava tap test.js && npm run size", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove tap
and test.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok as i followed codecov i did it based on their reference here what i replied to @stephenmathieson . #148 (comment)
So now i am bit confused about what we are implementing here. Codecov OR Coveralls?
Just let me get back to @f2prateek here about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, we're talking about codecov. However, it's still unrelated to this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well then i will give it a shot again in same way you suggested. Fact is i tried it for couple of times on my Docker stack but it didn't work so i had to get those back on my local. Once it started to work i replicated same over Cir-CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just ava tap test.js
is not a valid command, so I'm not sure how it could work for you.
circle.yml
Outdated
@@ -8,7 +8,8 @@ dependencies: | |||
- nvm install 4 | |||
- nvm install 6 | |||
- nvm install 8 | |||
- rm -rf node_modules | |||
- rm -rf node_modules coverage .nyc_output coverage.lcov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to remove these new files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm am just wondering in anycase if those folder contain some older reports from different commits/codes etc and then we should not remove those before new testbed "PRE" build step so it can fetch/upload only new & updated reports for the new expected commits/changes/codes etc?
In anycase report-coverage": "nyc report --reporter=lcov > coverage.lcov && codecov
this will always create and rebuild those dir/files before producing reports & upload them over codecov.
So i am trying to understand here , those dir/files with old reports & meta data should be still there even with the fresh build for new changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these files will be overwritten in each build anyway, that's why it makes no sense to remove them beforehand.
coverage | ||
.nyc_output | ||
coverage.lcov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to ignore coverage.lcov
, if you're piping output from nyc
to coveralls
, like I mentioned in the comment below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so you mean i should push all of those dir/files with all my local reports & meta data i used for my local test bed? Should not they be ignored like npm rebuild
as they will be created always while codecov report generation and uploading via nyc process will be running? Please suggest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was talking only about coverage.lcov
. But since I was thinking about coveralls and piping output before, it can stay there.
@@ -23,10 +23,10 @@ | |||
], | |||
"scripts": { | |||
"size": "size-limit", | |||
"test": "standard && ava", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remove the test
command (this is still used locally).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rectified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
circle.yml
Outdated
@@ -9,6 +9,7 @@ dependencies: | |||
- nvm install 6 | |||
- nvm install 8 | |||
- rm -rf node_modules | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this line added for a reason? Seems unnecessary and inconsistent with the style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One extra line was added in circle.yml
.
@vadimdemedes all looks good from me and stephen, wanna give your approval too if this looks ok to you? |
"test": "standard && ava", | ||
"testci": "standard && ava && npm run size", | ||
"test": "standard && nyc ava --tap", | ||
"testci": "standard && nyc ava --tap && npm run size", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's --tap
for? It doesn't affect coverage or reporting.
LGTM from me after #148 (comment) is resolved. |
This PR will help to generate Codecov Report & Upload it on codecov.io