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

Build: update Node to version 8 LTS (carbon) #19317

Merged
merged 10 commits into from
Nov 14, 2017
Merged

Build: update Node to version 8 LTS (carbon) #19317

merged 10 commits into from
Nov 14, 2017

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Oct 31, 2017

This PR updates Calypso to node v8.9.1 which is the latest LTS release. 🎉

Node LTS scehdule

This PR closely follows #16820 to upgrade node to version 8.9.1.

Testing

  • Local Dev
    • Switch to node version 8.9.1 (npm@5.1.1)
      nvm install 8 && nvm use 8
    • npm run distclean
    • npm start
    • No functional changes to Calypso
  • Local Docker Image
    • Follow image instructions at: PCYsg-5XR-p2 or
    • Setup docker locally and add the following host entry:
      127.0.0.1 wpcalypso.wordpress.com
      
    • npm run build-docker
    • npm run docker
  • Desktop
    • Clone the wp-desktop project
    • Follow install instructions
    • In the calypso submodule checkout this branch
    • Desktop behaves normally
  • Calypso as a dependency
    • @DanReyLop may have better information about who this may be.

Blockers

@matticbot
Copy link
Contributor

@sirreal sirreal added [Status] In Progress [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 31, 2017
@sirreal
Copy link
Member Author

sirreal commented Oct 31, 2017

@DanReyLop Do you have familiarity with package-lock.json and how we should modify our processes? It doesn't appear to be generated by our update-deps script.

@sirreal sirreal changed the title Update/node 8 8 1 Build: update Node to 8.8.1 Oct 31, 2017
@sirreal
Copy link
Member Author

sirreal commented Oct 31, 2017

Labeled as blocked awaiting official LTS announcement…

@DanReyLop
Copy link
Contributor

Do you have familiarity with package-lock.json and how we should modify our processes? It doesn't appear to be generated by our update-deps script.

Not familiar, but I'll never stop learning :)

I vaguely recall that we want to have both package-lock and shrinkwrap, they are mostly the same but they're used in different circumstances (installing wp-calypso vs fetching wp-calypso as a dependency). But I'll need to look at this again.

Give me the rest of today, I'll look at this in the afternoon.

@sirreal sirreal added [Status] In Progress and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 31, 2017
@sirreal
Copy link
Member Author

sirreal commented Oct 31, 2017

npm install is failing on this branch.

6719 error Command failed: /usr/local/bin/git checkout 801d65585af6995a223136862944095b48f5c567
6719 error fatal: reference is not a tree: 801d65585af6995a223136862944095b48f5c567

This looks like an indirect dependency installing by sha. I'm not sure where this is happening.

@sirreal
Copy link
Member Author

sirreal commented Oct 31, 2017

This looks like an indirect dependency installing by sha. I'm not sure where this is happening.

O HAI

https://github.com/Automattic/calypso-prettier/blob/14307ba5cc6bcfc00243f5e2d1b25c72d52c28c8/package.json#L39

"typescript-eslint-parser": "git://github.com/eslint/typescript-eslint-parser.git#801d65585af6995a223136862944095b48f5c567"

Bumping calypso-prettier to 1.7 fixes this problem. @jsnajdr Anything holding us back from updating to 1.7 at this point?

@jsnajdr
Copy link
Member

jsnajdr commented Oct 31, 2017

Anything holding us back from updating to 1.7 at this point?

Nothing at all -- the Calypso fork has an up-to-date branch with 1.7.1 I created a few weeks ago. Give me ~24 hours to update to the latest 1.7.4 and create an upgrade PR.

@gziolo
Copy link
Member

gziolo commented Oct 31, 2017

Do you have familiarity with package-lock.json and how we should modify our processes? It doesn't appear to be generated by our update-deps script.

Isn't npm 5 able to reuse existing shrinkwrap file and use it instead of package-lock.json? As far as I understood it listening to podcasts, the idea is to have shrinkwrap to support both npm 5 and earlier versions of npm. Not sure how that works in practice, but it seems like a good approach.

@sirreal
Copy link
Member Author

sirreal commented Oct 31, 2017

Isn't npm 5 able to reuse existing shrinkwrap file and use it instead of package-lock.json?

@gziolo I also get the impression that shrinkwrap has precedence over lock and we may not need to make changes around package-lock:

To prevent this potential issue, npm uses package-lock.json or, if present, npm-shrinkwrap.json. These files are called package locks, or lockfiles.

☝️ from npm-package-locks

@simison
Copy link
Member

simison commented Oct 31, 2017

they are mostly the same but they're used in different circumstances (installing wp-calypso vs fetching wp-calypso as a dependency).

Yep!

My thumb of rule with these files has been:

  • package-lock is for projects (those with private: true at package.json) and should always be committed. package-lock cannot be published to NPM.
  • shrinkwrap is for CLI modules (like calypso-prettier?) and sometimes for required modules (like i18n-calypso), but that's generally discouraged to give project developers more freedom...

If you end up having both, package-lock is ignored.

Considerations:

  • With this many devs poking in the codebase, shrinkwrap might still be easier to handle because it requires manual npm shrinkwrap before that file gets updated (I think? I haven't really used it for a while anymore). package-lock gets updated on each npm install/update.
  • shrinkwrap works also with older NPM versions, if that matters...

My take:
→ Calypso should maybe have only package-lock?
→ Since they indeed are pretty much identical, just replacing everything shrinkwrap'ish with package-lock should work!

Hope this helps to decide!

@simison
Copy link
Member

simison commented Oct 31, 2017

BTW this was lovely, on updating Node v6 to 8:

That’s a pretty decent 23% reduction in render time. Or, more concretely, a 23% reduction in the hardware required to serve the site.
...
I’m going to suggest to my employer that we upgrade to Node 8, reduce our Amazon instances from 25 to 20 and donate the first month’s savings to the Node.js Foundation.

via

;-)

@sirreal
Copy link
Member Author

sirreal commented Oct 31, 2017

The preshrinkwrap script seems to create an infinite loop. I'd speculate that since we're trying to shrinkwrap and prune fiddles with node_modules, the process starts over. I have no evidence to support that, but removal of the preshrinkwrap script allows update-deps to complete.

I've removed it in 0ef64ba, any reasons to keep it?

@blowery
Copy link
Contributor

blowery commented Oct 31, 2017

+1 on moving to package.lock for locking.

@sirreal sirreal removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 13, 2017
@sirreal
Copy link
Member Author

sirreal commented Nov 13, 2017

As far as I can see, there aren't any blockers and testing looks good. I'll plan to merge in the next 24 hours if there aren't any objections.

@gwwar
Copy link
Contributor

gwwar commented Nov 13, 2017

Looks like most of the added lines are from the integrity field. If our first attempt doesn't build properly we may need to check if our cached packages match. https://docs.npmjs.com/files/package-lock.json#integrity

@gwwar
Copy link
Contributor

gwwar commented Nov 13, 2017

Smoke tested a bit on Docker, and things appeared to work well ✨

I do see some issues with wp-desktop, but I think we can proceed with this and fix wp-desktop on that side.

@astralbodies are you okay with this approach? Or should we try fixing some of the issues now?

@sirreal
Copy link
Member Author

sirreal commented Nov 14, 2017

astralbodies are you okay with this approach? Or should we try fixing some of the issues now?

I got an off-GitHub OK from astralbodies. Merge is imminent…

sirreal and others added 10 commits November 14, 2017 14:02
Don't run "npm install" twice, this was workaround for older npm
peculiarities.

Remove the `--dev` flag from `npm shrinkwrap` as it's now the default.
We'll continue to use `npm-shrinkwrap.json` which serves the same
purpose.
Optional dependencies will continue to be installed if supported. This
will generate the same shrinkwrap independent of the operating system
where the shrinkwrap is generated.

This was an annoyance where `fsevents` would be added or removed from
the shrinkwrap frequently.
Change in 01dee67 appears to break
docker builds on osx
It's used by `bin/minify.js`, which is called as part of production
builds after `npm install --production`.

This was breaking local docker builds.
@sirreal sirreal merged commit 04e5fde into master Nov 14, 2017
sirreal added a commit that referenced this pull request Nov 14, 2017
sirreal added a commit that referenced this pull request Nov 14, 2017
* Revert #19317
* Regenerate shrinkwrap with node6/npm3
sirreal added a commit that referenced this pull request Nov 14, 2017
Applies the changes from #19317
@sirreal
Copy link
Member Author

sirreal commented Nov 14, 2017

Build failed: pMz3w-7Pz-p2

Take 2: #19759

sirreal added a commit that referenced this pull request Nov 15, 2017
Upgrade to node 8 and npm 5

Second attempt with the changes from #19317
@sirreal sirreal deleted the update/node-8-8-1 branch November 15, 2017 09:21
rclations pushed a commit to rclations/wp-calypso that referenced this pull request Nov 15, 2017
* Update to node 8.9.1

* Remove preshrinkwrap which was causing infinite loop

* Simplified update-deps script for npm@5

Don't run "npm install" twice, this was workaround for older npm
peculiarities.

Remove the `--dev` flag from `npm shrinkwrap` as it's now the default.

* Disable package-lock.json generation in config

We'll continue to use `npm-shrinkwrap.json` which serves the same
purpose.

* Remove duplicate npm install from Dockerfile

* Move uglify-js to dependencies

It's used by `bin/minify.js`, which is called as part of production
builds after `npm install --production`.

This was breaking local docker builds.
rclations pushed a commit to rclations/wp-calypso that referenced this pull request Nov 15, 2017
rclations pushed a commit to rclations/wp-calypso that referenced this pull request Nov 15, 2017
Upgrade to node 8 and npm 5

Second attempt with the changes from Automattic#19317
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.

10 participants