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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Danger and a rule showing build size differences #11865

Merged
merged 7 commits into from
Jan 17, 2018

Conversation

orta
Copy link
Contributor

@orta orta commented Dec 15, 2017

Adds Danger

Adds danger-js with a single rule taken from the React Native Dangerfile. I am less familiar with React, the repo, than I am with the process around React Native. So I didn't want to intrude.

Danger runs during your CI process, and gives teams the chance to automate common code review chores.

This provides another logical step in your build, through this Danger can help lint your rote tasks in daily code review.

Which means that you can start writing simple scripts to handle "Add a CHANGELOG" or "No merger commits please" basically. @hramos wrote a bunch in RN, and there is an API reference here. You can test changes locally by running node node_modules/.bin/danger pr https://github.com/facebook/react/pull/[ID].

This PR:

  • Adds Danger as one of the build steps during CI
  • Adds the same API token as React Native ( for @facebook-open-source-bot ) (example)

I'm not 100% certain that I added it into the right section in test_entry_point.sh - happy to change that if you have better ideas.

@gaearon
Copy link
Collaborator

gaearon commented Dec 15, 2017

Wow, thanks for sending a PR! I'm not sure sure we have a use for that particular rule though.

What would've been much more valuable is to output the build size difference. Is that something we could do? The data should be available in results.json file after yarn build which happens on the second Circle node.

@orta
Copy link
Contributor Author

orta commented Dec 16, 2017

Yep, I can look at that

@orta orta force-pushed the add_danger branch 4 times, most recently from f346cfc to 4a08712 Compare December 16, 2017 17:05
@orta
Copy link
Contributor Author

orta commented Dec 16, 2017

@gaearon OK, so this now posts the table. Things worth considering:

  • Should this always show?
  • Should this be hidden behind markdown summary?
  • Can you think of ways to save horizontal space, so it could fit? ( maybe multiple tables?)
  • Are there things in particular that we could highlight? ( green / red / bold color )

@orta orta changed the title Adds Danger and an initial rule for large PRs Adds Danger and an rule outputting build size differences Dec 16, 2017
@orta orta changed the title Adds Danger and an rule outputting build size differences Adds Danger and a rule outputting build size differences Dec 16, 2017
@orta orta changed the title Adds Danger and a rule outputting build size differences Adds Danger and a rule showing build size differences Dec 16, 2017
@gaearon
Copy link
Collaborator

gaearon commented Dec 18, 2017

Should this always show?

It should show if there's non-zero difference in any of the files. It should filter out any bundles that haven't changed.

Should this be hidden behind markdown summary?

Maybe we can separate significant (>300 bytes post gzip to production bundles) changes from insignificant, and hide insignificant ones in a summary by default.

Can you think of ways to save horizontal space, so it could fit?

We can group them by bundle name. Something like

-----
react-reconciler
-----
umd_dev | ... 
umd_prod | ...
cjs_dev | ...
...
-----
react-dom
-----
umd_dev | ... 
umd_prod | ...
cjs_dev | ...
...
-----

Are there things in particular that we could highlight? ( green / red / bold color )

%?

@gaearon
Copy link
Collaborator

gaearon commented Dec 18, 2017

OK, I did a few updates on master that ensure the table printed at CI is accurate against master.

dangerfile.js Outdated
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
Copy link
Collaborator

Choose a reason for hiding this comment

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

MIT license please :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah!

Sure, (I've been hacking on this slowly over the last two days) I am a bit surprised by the build failures but I think this is pretty much good to go once those are figured

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

@gaearon
Copy link
Collaborator

gaearon commented Jan 2, 2018

What’s missing here?

@orta
Copy link
Contributor Author

orta commented Jan 2, 2018

Ah, nothing now it's green. 👍

The markdown will now only show the tables for modules if any of the values are not nil. It should be easy to shuffle that data around (in terms of what the table row order etc) but this is basically 💯

@gaearon
Copy link
Collaborator

gaearon commented Jan 2, 2018

Do I understand correctly that updating this PR will update the table in the comment above?

I think there are three changes I’d like to see before merging:

  • omit rows with 0 changes
  • hide table in a details tag
  • provide a one-line summary for React + ReactDOM UMD_PROD combined changes above the fold.

@orta
Copy link
Contributor Author

orta commented Jan 2, 2018

Yep, as new commits happen the PR will be updated with the new table. If it reverts back to no difference in build size, then the message will be deleted.

The rest sound good to me 👍

@gaearon
Copy link
Collaborator

gaearon commented Jan 2, 2018

If it reverts back to no difference in build size, then the message will be deleted.

Why does it have the difference though? Is it because the PR runs against master rather than merge base? I guess that’s a bigger issue than I initially though then.

The rest sound good to me

Want to do it?

@orta
Copy link
Contributor Author

orta commented Jan 2, 2018

Nah, I mean on every CI run, the message will be updated with the latest commit in the PR vs the diff against results.json from http://react.zpao.com/builds/master/latest/results.json.

I'll take a shot, I'm free for the next 45m

@gaearon
Copy link
Collaborator

gaearon commented Jan 10, 2018

Did you figure out why it uses wrong commit as a base?

@orta
Copy link
Contributor Author

orta commented Jan 10, 2018

I did, but I'm still not sure why on the results aren't "no changes"

In the previous examples danger was using the head of master on facebook/react (danger.pr.head.sha) but now Danger uses the commits in the PR to find the parent for the earliest commit (danger.git.commits[0].parents[0]) which should mean it will only tell you the relative changes for your specific PR commit range.

Sorry it's dragging, I'm on the (hopefully) last day of shipping an app we've been working on for 6 months so my time management has been pretty strained

@orta
Copy link
Contributor Author

orta commented Jan 14, 2018

OK, so I did some debugging, I did

git checkout a442d9bc082878ccf66872b1eeed3465927801b6
node ./scripts/rollup/build.js

And there were no differences on the results, I went back to this PR:

git checkout add_danger
node ./scripts/rollup/build.js

and git status shows no changes, when I run node ./scripts/rollup/build.js --extract-errors however, I get results.json differences. Which is what I think we're seeing a difference in the results.

I've just shipped a commit that removes the --extract-errors - hoping that means this run means no difference.

@gaearon
Copy link
Collaborator

gaearon commented Jan 15, 2018

--extract-errors should run on the Circle build.

To clarify:

  • It is expected that --extract-errors size won't match the results.json stored in the repository for the given commit.
  • However, it should match the size of results.json from zpao's server for that commit since we upload results.json precisely after --extract-errors build.

If either of those is wrong then there's a bug in either uploading or downloading results.json to/from zpao's server. But --extract-errors is there intentionally.

@orta
Copy link
Contributor Author

orta commented Jan 17, 2018

Found it, the lookup for bundle results weren't taking different bundleTypes (e.g NODE_DEV) into account so it would give differing results when the JSON was the same. Code: 1535536

We should see the Danger message disappear, because there is nothing to say as the build sizes are unchanged in this PR.

@gaearon
Copy link
Collaborator

gaearon commented Jan 17, 2018

Seems like it's gone and this is good to go? 👍

@orta
Copy link
Contributor Author

orta commented Jan 17, 2018

Yep, rebasing right now then that should be happy ~1 month anniversary PR.

@gaearon
Copy link
Collaborator

gaearon commented Jan 17, 2018

(Needs a rebase or merge)

@orta
Copy link
Contributor Author

orta commented Jan 17, 2018

👍 it's ready

@gaearon
Copy link
Collaborator

gaearon commented Jan 17, 2018

Let's give this a try! Can always temporarily revert if something breaks.

@gaearon gaearon merged commit d8d7976 into facebook:master Jan 17, 2018
@esbena
Copy link
Contributor

esbena commented Jan 18, 2018

I believe this PR contains a copy/paste error:

https://github.com/facebook/react/blob/master/dangerfile.js#L109

        r => r.prevGzipSizeChange !== 0 || r.prevGzipSizeChange !== 0

should be

        r => r.prevFileSizeChange !== 0 || r.prevGzipSizeChange !== 0

@gaearon
Copy link
Collaborator

gaearon commented Jan 18, 2018

Mind fixing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants