Skip to content

feat: add support for yarn installations#560

Merged
targos merged 28 commits into
nodejs:masterfrom
SimenB:yarn
Nov 24, 2018
Merged

feat: add support for yarn installations#560
targos merged 28 commits into
nodejs:masterfrom
SimenB:yarn

Conversation

@SimenB

@SimenB SimenB commented Apr 15, 2018

Copy link
Copy Markdown
Member

I'd really like to add Jest to CITGM, but the hard requirement on npm means that's a no-go (Jest uses yarn workspaces). I think I read somewhere that npm was going to add workspaces support, but seeing as I can't find a reference to it, I might have imagined it.

This is a first go at adding support for Yarn as package manager instead of npm in CITGM.

While doing this I realized that #415 just covers adding it to $PATH, not necessarily using it (and that should probably still be done). I've already done the work here though, so why not open up a PR? 🙂 I've held off on adding tests as there's a chance this is rejected, though.

2 times Jest has had failing tests on Node master, with one of them being caught before node 9 was released, and one making it into the release. See nodejs/node#16322 and nodejs/node#19607.

/cc @cpojer

Checklist

@SimenB

SimenB commented Apr 15, 2018

Copy link
Copy Markdown
Member Author

Yeah, CI fails since yarn is not added to $PATH. Thoughts on the cleanest way of doing that?

@cpojer

cpojer commented Apr 15, 2018

Copy link
Copy Markdown

Wow this is really cool! Hope that this will get accepted. Is there anything I can do to help? :)

@MylesBorins

MylesBorins commented Apr 15, 2018 via email

Copy link
Copy Markdown
Contributor

@gibfahn

gibfahn commented Apr 15, 2018

Copy link
Copy Markdown
Member

We will need to work with @nodejs/build to get yarn into our ci as well

Looking at the yarn installation docs it looks like it's just a case of extracting a tarball and adding to the path.

I'd rather not install yarn globally on every machine if possible, so just adding the two lines to the CI jobs sounds like the way to go for me.

EDIT: Realised I already said this in #415

@gibfahn

gibfahn commented Apr 15, 2018

Copy link
Copy Markdown
Member

This PR LGTM once it has tests.

@SimenB

SimenB commented Apr 15, 2018

Copy link
Copy Markdown
Member Author

Opened up #561 installing yarn on CI (separate as I expect this PR to take a bit of time, while yarn installed on CI is standalone)

@gibfahn

gibfahn commented Apr 15, 2018

Copy link
Copy Markdown
Member

Opened up #561 installing yarn on CI (separate as I expect this PR to take a bit of time, while yarn installed on CI is standalone)

I don't have a huge issue with doing that, but what's the benefit to having that land sooner? Presumably it's not usable before this PR lands.

@SimenB

SimenB commented Apr 15, 2018

Copy link
Copy Markdown
Member Author

To unblock #478

@SimenB

SimenB commented Apr 19, 2018

Copy link
Copy Markdown
Member Author

@MylesBorins no objections beyond missing tests? If so, I'll try to get some written this weekend or early next week 🙂

MylesBorins

This comment was marked as off-topic.

@SimenB

SimenB commented Apr 19, 2018

Copy link
Copy Markdown
Member Author

Thanks for the review! Seeing as Jest uncovered nodejs/node#20157 as well, I'll try to prioritise work on this PR so we can get Jest into CITGM.

@MylesBorins

MylesBorins commented Apr 19, 2018 via email

Copy link
Copy Markdown
Contributor

@SimenB

SimenB commented Apr 19, 2018

Copy link
Copy Markdown
Member Author

Feel free to work on it! I'll be travelling for work this weekend, so I won't have any time until next week anyways 🙂

@BridgeAR

Copy link
Copy Markdown
Member

@SimenB would you be so kind and have another loop at the comments? :-) having yarn support would IMO be really helpful.

@SimenB

SimenB commented Oct 22, 2018

Copy link
Copy Markdown
Member Author

Jest has actually passed Mocha now as the most downloaded test framework from npm, so I'll try to find the time to get this up to speed within the next few days.

@SimenB

SimenB commented Oct 23, 2018

Copy link
Copy Markdown
Member Author

Rebased and pushed changes based on feedback (except for template strings and the bind thing).

I'll open up a separate PR adding Prettier and template strings to avoid the style nits 🙂

@SimenB SimenB mentioned this pull request Oct 23, 2018
1 task
@SimenB

This comment has been minimized.

Comment thread .travis.yml Outdated
@targos

targos commented Oct 23, 2018

Copy link
Copy Markdown
Member

Is this ready for review?

@SimenB

SimenB commented Oct 23, 2018

Copy link
Copy Markdown
Member Author

Yes, except for a missing test this is good to go. I'll add a test today or tomorrow

@SimenB

SimenB commented Oct 24, 2018

Copy link
Copy Markdown
Member Author

I've added tests now. However, I hit a snag.

On mac, of you install yarn through the officially recommended way (brew), the yarn binary is a shell script, not a JS file. I "fixed" this by spawning the binary directly (ede9d29) and not via node. This however means that the test with fake-node fails. Thoughts?

I skipped the failing tests in the last commit.

Brew code: https://github.com/Homebrew/homebrew-core/blob/851bec0243ba6e5e722fedf0de172a53ff1d9299/Formula/yarn.rb#L13-L18

Results in the following /usr/local/bin/yarn:

#!/bin/bash
PREFIX="/usr/local" NPM_CONFIG_PYTHON="/usr/bin/python" exec "/usr/local/Cellar/yarn/1.10.1/libexec/bin/yarn.js" "$@"

Comment thread test/yarn/test-yarn-install.js Outdated
Comment thread lib/package-manager/test.js Outdated
Comment thread test/npm/test-npm-test.js Outdated
Comment thread test/yarn/test-yarn-install.js Outdated
Comment thread test/yarn/test-yarn-test.js Outdated
@targos

targos commented Oct 24, 2018

Copy link
Copy Markdown
Member

This LGTM, but we have to make sure that the CI machines used for CITGM jobs have yarn installed and in the PATH before we merge the PR.

@MylesBorins

MylesBorins commented Oct 24, 2018 via email

Copy link
Copy Markdown
Contributor

@SimenB

SimenB commented Oct 24, 2018

Copy link
Copy Markdown
Member Author

Are we able to include yarn in the package.json and use that version?

That should work, yeah!

@SimenB

SimenB commented Nov 21, 2018

Copy link
Copy Markdown
Member Author

@MylesBorins thanks for the thorough review! I think I've addressed your points now (and rebased)

Comment thread lib/citgm.js Outdated
test('npm-install: setup', function (t) {
t.plan(7);
t.plan(8);
packageManager.getPackageManagers((e, res) => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not super clean, but allows me to reuse the implementation.

@MylesBorins MylesBorins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some small nits in line but nothing I'd block over

Thanks for all the hard work!

edit: this LGTM is dependent on the test suite being green

Comment thread lib/citgm.js Outdated
Comment thread lib/citgm.js Outdated
module.exports = function getExecutable(binaryName, next) {
if (binaryName === 'yarn') {
// Use `npm-which` for yarn to get the locally version
npmWhich(binaryName, next);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a reason we can't use npmWhich for both npm and yarn?. If that's the case and it is pass through could we not remove this script altogether?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

is there a reason we can't use npmWhich for both npm and yarn?

npm-which is just for binaries installed in node_modules. Not sure if it finds globally installed stuff?

Could potentially add npm as a dep as well, then it won't rely on any globals beyond node. Maybe not worth it?

If that's the case and it is pass through could we not remove this script altogether?

IDK about the windows thing below. Would that just work ™️? I don't have access to a windows machine to test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's keep it just how it is for now, this makes sense. I was more confused by the usage above

Comment thread lib/package-manager/index.js Outdated
@SimenB

SimenB commented Nov 21, 2018

Copy link
Copy Markdown
Member Author

Fixed the failing test and addressed the last feedback except for one open question

@SimenB

SimenB commented Nov 21, 2018

Copy link
Copy Markdown
Member Author

BTW, might make sense to activate auto-cancellation of redundant builds: https://travis-ci.com/nodejs/citgm/pull_requests. Currently my last 2 commits are both queued, the second to last could (should) be cancelled

@targos

targos commented Nov 21, 2018

Copy link
Copy Markdown
Member

@SimenB done. I also cancelled the second to last job.

@SimenB

SimenB commented Nov 22, 2018

Copy link
Copy Markdown
Member Author

CI is green and feedback addressed. Is this good to go? 🙂

@rvagg

rvagg commented Nov 22, 2018

Copy link
Copy Markdown
Member

I'm not really following this, sorry, but if this needs yarn on citgm infra then could someone please open an issue on nodejs/build if there isn't one for it?

@SimenB

SimenB commented Nov 22, 2018

Copy link
Copy Markdown
Member Author

I've added yarn as a dependency, so it's installed that way. Shouldn't need to update any CI env

@targos

targos commented Nov 24, 2018

Copy link
Copy Markdown
Member

@targos

targos commented Nov 24, 2018

Copy link
Copy Markdown
Member

Failures seem unrelated. I opened nodejs/build#1601

@targos

targos commented Nov 24, 2018

Copy link
Copy Markdown
Member

I scheduled https://ci.nodejs.org/job/citgm-continuous-integration/144/ to check if it also fails for the same reason on master.

Edit: confirmed

@targos targos merged commit 44249dc into nodejs:master Nov 24, 2018
@SimenB SimenB deleted the yarn branch November 24, 2018 14:33
@SimenB SimenB mentioned this pull request Dec 8, 2018
2 tasks
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.

9 participants