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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use nyc over istanbul-cli #316

Merged
merged 1 commit into from
Apr 1, 2017

Conversation

JaKXz
Copy link
Contributor

@JaKXz JaKXz commented Feb 10, 2017

馃憢 Hi! istanbuljs member here -

Thought I'd help out a little by simplifying your coverage commands and configuration :)

Otherwise, the main win of bringing you over to the much better supported nyc + babel-plugin-istanbul is that you're now getting more accurate coverage reports and stats!

Please let me know if anything concerns you - very happy to answer any questions you might have. Thanks again for this wonderful library!

also add cross-env + babel-plugin-istanbul for better coverage reports
@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 78.793% when pulling 9deb626 on JaKXz:chore/use-nyc-etc into 3eafa08 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 78.793% when pulling 59822ab on JaKXz:chore/use-nyc-etc into 3eafa08 on airbnb:master.

@ljharb
Copy link
Member

ljharb commented Feb 10, 2017

Can you elaborate more on why we should change our coverage method? What's different about nyc and why should we prefer it over istanbul?

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, please remove yarn.lock. Airbnb does not use yarn, and lockfiles are harmful in non-top-level-apps.

.editorconfig Outdated
@@ -0,0 +1,16 @@
root = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless this file can be kept in sync with CI (ie, changes to it will cause misformatted files to fail) i'd prefer the file not be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have found EditorConfig to be very helpful as a maintainer because it takes care of nuisances with whitespace and line endings and newlines etc. behind the scenes. e.g. the IntelliJ platform comes with support built in and almost all popular editors have a simple installer. It's worth noting that GitHub also has native support.

If you still prefer it not be added, I will remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to have it, but something in CI would need to enforce it (the linter typically does this for us). Do you know of anything that can do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@JaKXz JaKXz Feb 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I don't feel like it's a strong enough win for you, if it must be enforced like this.

I will remove it from this PR since it's not really the main focus. 馃毑 馃彔 painted.

@@ -30,7 +30,7 @@ describe('CalendarDay', () => {
expect(wrapper.text()).to.equal(lastOfMonth.format('D'));
});

it('contains arbitrary content if renderDay is provided', () => {
it.skip('contains arbitrary content if renderDay is provided', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noting this line will need reverting before merging

@@ -0,0 +1,5 @@
--compilers js:babel-register,jsx:babel-register
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good change regardless; i'd be stoked to merge it in a separate PR :-)

test/mocha.opts Outdated
--require airbnb-js-shims
--require ./test/_helpers/ignoreSVGStrings.jsx
--recursive
test/**/*_spec.js test/**/*_spec.jsx test/_helpers/restoreSinonStubs.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however, the glob part of this configuration should remain in package.json, not in the mocha opts.

@JaKXz
Copy link
Contributor Author

JaKXz commented Feb 10, 2017

What's different about nyc and why should we prefer it over istanbul?

nyc is the successor to the istanbul cli. nyc uses istanbul's APIs under the hood and there have been some features & fixes since istanbul@1.x-alpha was published.

It's preferred over the istanbul cli because

  • the istanbul cli is no longer really maintained, or, better stated: future development is happening in nyc.
  • babel-plugin-istanbul + nyc provides more accurate coverage of ES2015+ code [hence coverage numbers dropping, relatively signficantly].

package.json Outdated
"pretest": "npm run --silent lint",
"tests-only": "npm run mocha --silent test",
"tests-only": "mocha --silent",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the file path needs to be restored here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a typo on my part - the --recursive flag handles the globs for us.

@JaKXz
Copy link
Contributor Author

JaKXz commented Feb 10, 2017

@ljharb mind elaborating on

lockfiles are harmful in non-top-level-apps.

If you publish with a files array in package.json you're not adding any weight to the package as a dependency. I notice this package uses .npmignore and I missed adding it there, so that was my bad. Is there something I'm missing?

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 78.793% when pulling 5ac50bb on JaKXz:chore/use-nyc-etc into 3eafa08 on airbnb:master.

@ljharb
Copy link
Member

ljharb commented Feb 10, 2017

files arrays are incredibly dangerous, for one, but npmignore is fine.

If I publish a shrinkwrap file, yarn ignores it. If I publish a yarn lock file, yarn and npm ignore it. In no case am I ensuring my users get a deterministic dep tree. However, I am ensuring that if an in-range update is published that breaks me, my own tests will merrily pass but my users will merrily break.

Only an app is in the position to truly know that dependencies should be frozen.

@JaKXz
Copy link
Contributor Author

JaKXz commented Feb 10, 2017

Curiouser and curiouser

files arrays are incredibly dangerous, for one

Mind elaborating on that? edit: or do you have a slack channel I can bug you on so I can stop digressing here? 馃槃

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 78.793% when pulling 5ac50bb on JaKXz:chore/use-nyc-etc into 3eafa08 on airbnb:master.

@ljharb
Copy link
Member

ljharb commented Feb 10, 2017

@JaKXz i'm on a number of common slacks and on freenode IRC, but here's fine too.

Basically, the absolute worst case of forgetting to include a new file in npmignore is that "your package is a tiny bit too large". The worst case of forgetting to include a new file in "files" is that "your package is subtly broken, in a way that's almost impossible for you, the author, (or your CI tests) to determine". Overarching package size just isn't a big problem anyways, and the worst case is so much worse with an "inclusion list" approach, that the only safe approach is an "exclusion list".

@JaKXz
Copy link
Contributor Author

JaKXz commented Feb 10, 2017

I see. That's a reasonable approach to safety.

Anyway, are there any other changes you want to see in this PR?

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 78.793% when pulling cbb57e5 on JaKXz:chore/use-nyc-etc into cfc7b16 on airbnb:master.

@majapw
Copy link
Collaborator

majapw commented Feb 13, 2017

@ljharb what do we need to do to get this merged in?

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.0%) to 78.689% when pulling 99b5dd4 on JaKXz:chore/use-nyc-etc into 536563b on airbnb:master.

test/mocha.opts Outdated
@@ -0,0 +1,4 @@
--compilers js:babel-register,jsx:babel-register
--require airbnb-js-shims
--require ./test/_helpers/ignoreSVGStrings.jsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails to include the file that restores sinon stubs; please revert this part and restore npm run mocha, and have that pass the file there. mocha doesn't work with global before/after handlers if they're --required in.

@ljharb
Copy link
Member

ljharb commented Mar 31, 2017

@JaKXz i've rebased this branch; but it seems like your previous command (nyc mocha) is a bit wonky; it doesn't seem to take the same path arguments as mocha does; and we prefer to use npm run mocha as our central source of truth for the mocha command. Separately, adding the path args to mocha.opts doesn't seem to work either.

Is this not something nyc supports?

@JaKXz
Copy link
Contributor Author

JaKXz commented Mar 31, 2017

@ljharb sorry for the long turnaround on this! I think I've addressed your concerns now. :)

I'm not sure why Travis isn't firing but I can confirm the tests pass locally.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

Just three more comments/questions, and assuming tests pass, I think this is good to go!

I appreciate your persistence with the back-and-forth and the many comments; I've switched to using nyc on another project and it's both a smooth and pleasant upgrade from istanbul-cli.

package.json Outdated
"lint": "eslint --ext .js,.jsx src test",
"mocha": "mocha --compilers js:babel-register,jsx:babel-register --require airbnb-js-shims --recursive ./test/_helpers",
"mocha": "mocha ./test/_helpers test/**/*_spec.js*",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the _spec.js part needed? Every JS file inside test should be considered a test, and double-running the helpers shouldn't be a problem :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

package.json Outdated
"pretest": "npm run --silent lint",
"tests-only": "npm run mocha --silent test",
"tests-only": "npm run mocha -- --silent",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the --silent was intended for npm, not mocha - this change passes it to mocha instead. Can this line be reverted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

.nycrc Outdated
],
"all": true,
"check-coverage": true,
"statements": 89,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one final re-confirmation - are these numbers exactly in line with our current coverage? If not, can we bump them to be? :-)

@JaKXz
Copy link
Contributor Author

JaKXz commented Apr 1, 2017

@ljharb here are the original watermarks, and I've dropped the numbers in .nycrc to reflect the current coverage.

screen shot 2017-03-31 at 8 58 35 pm

Also addressed your other two comments. Thanks for your patience as well!

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.3%) to 80.176% when pulling a2957c8 on JaKXz:chore/use-nyc-etc into 5385116 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.3%) to 80.176% when pulling fcd7d8d on JaKXz:chore/use-nyc-etc into 5385116 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.3%) to 80.176% when pulling 29f774c on JaKXz:chore/use-nyc-etc into 5385116 on airbnb:master.

@majapw
Copy link
Collaborator

majapw commented Apr 1, 2017

Party! Why did coveralls coverage go down so significantly though?

@JaKXz
Copy link
Contributor Author

JaKXz commented Apr 1, 2017

Because the instrumentation is much more accurate now, and we are measuring against all JS and jsx files :) which I don't think was happening before.

@majapw
Copy link
Collaborator

majapw commented Apr 1, 2017

Exciting! Also, I think I need to write more tests. :P @ljharb is this good? Can we merge it in? I'll lower the coveralls check for now and admin priv merge it, if that's the case.

Thanks for all the hard work @JaKXz! We super appreciate it. :D

@ljharb
Copy link
Member

ljharb commented Apr 1, 2017

I've just re-rebased and pushed up; if travis-ci passes (even if coveralls drops) then this is good to merge 馃帀

@coveralls
Copy link

coveralls commented Apr 1, 2017

Coverage Status

Coverage decreased (-7.3%) to 80.176% when pulling 5bdcdc4 on JaKXz:chore/use-nyc-etc into 00c95c7 on airbnb:master.

@ljharb
Copy link
Member

ljharb commented Apr 1, 2017

Coveralls passed which probably means the thresholds aren't high enough; but I'm going to merge this now!

@ljharb
Copy link
Member

ljharb commented Apr 1, 2017

(I filed #417 to combine coverage across all test runs, instead of just on node 4.6)

@ljharb ljharb merged commit 5bdcdc4 into react-dates:master Apr 1, 2017
@ljharb
Copy link
Member

ljharb commented Apr 1, 2017

Thanks @JaKXz! 馃帀

@majapw
Copy link
Collaborator

majapw commented Apr 1, 2017 via email

@JaKXz JaKXz deleted the chore/use-nyc-etc branch April 13, 2017 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants