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

feat: add support for yarn installations #560

Merged
merged 28 commits into from
Nov 24, 2018
Merged

feat: add support for yarn installations #560

merged 28 commits into from
Nov 24, 2018

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Apr 15, 2018

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
Copy link
Member Author

SimenB commented Apr 15, 2018

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

@cpojer
Copy link

cpojer commented Apr 15, 2018

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

@MylesBorins
Copy link
Contributor

MylesBorins commented Apr 15, 2018 via email

@gibfahn
Copy link
Member

gibfahn commented Apr 15, 2018

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
Copy link
Member

gibfahn commented Apr 15, 2018

This PR LGTM once it has tests.

@SimenB
Copy link
Member Author

SimenB commented Apr 15, 2018

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
Copy link
Member

gibfahn commented Apr 15, 2018

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
Copy link
Member Author

SimenB commented Apr 15, 2018

To unblock #478

@SimenB
Copy link
Member Author

SimenB commented Apr 19, 2018

@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
Copy link
Member Author

SimenB commented Apr 19, 2018

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
Copy link
Contributor

MylesBorins commented Apr 19, 2018 via email

@SimenB
Copy link
Member Author

SimenB commented Apr 19, 2018

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
Member

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

@SimenB
Copy link
Member Author

SimenB commented Oct 22, 2018

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
Copy link
Member Author

SimenB commented Oct 23, 2018

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.

.travis.yml Outdated Show resolved Hide resolved
@targos
Copy link
Member

targos commented Oct 23, 2018

Is this ready for review?

@SimenB
Copy link
Member Author

SimenB commented Oct 23, 2018

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

@SimenB
Copy link
Member Author

SimenB commented Oct 24, 2018

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" "$@"

lib/package-manager/test.js Outdated Show resolved Hide resolved
test/npm/test-npm-test.js Outdated Show resolved Hide resolved
test/yarn/test-yarn-install.js Outdated Show resolved Hide resolved
test/yarn/test-yarn-test.js Outdated Show resolved Hide resolved
@targos
Copy link
Member

targos commented Oct 24, 2018

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
Copy link
Contributor

MylesBorins commented Oct 24, 2018 via email

@SimenB
Copy link
Member Author

SimenB commented Oct 24, 2018

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

That should work, yeah!

@SimenB
Copy link
Member Author

SimenB commented Nov 21, 2018

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

lib/citgm.js Outdated Show resolved Hide resolved
test('npm-install: setup', function (t) {
t.plan(7);
t.plan(8);
packageManager.getPackageManagers((e, res) => {
Copy link
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.

Copy link
Contributor

@MylesBorins MylesBorins left a comment

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

lib/citgm.js Outdated Show resolved Hide resolved
lib/citgm.js Outdated Show resolved Hide resolved
module.exports = function getExecutable(binaryName, next) {
if (binaryName === 'yarn') {
// Use `npm-which` for yarn to get the locally version
npmWhich(binaryName, next);
Copy link
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
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
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

lib/package-manager/index.js Outdated Show resolved Hide resolved
@SimenB
Copy link
Member Author

SimenB commented Nov 21, 2018

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

@SimenB
Copy link
Member Author

SimenB commented Nov 21, 2018

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
Copy link
Member

targos commented Nov 21, 2018

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

@SimenB
Copy link
Member Author

SimenB commented Nov 22, 2018

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

@rvagg
Copy link
Member

rvagg commented Nov 22, 2018

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
Copy link
Member Author

SimenB commented Nov 22, 2018

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

@targos
Copy link
Member

targos commented Nov 24, 2018

@targos
Copy link
Member

targos commented Nov 24, 2018

Failures seem unrelated. I opened nodejs/build#1601

@targos
Copy link
Member

targos commented Nov 24, 2018

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