Skip to content

test: do not depend on a global npm binary - #23326

Merged
clydin merged 1 commit into
angular:mainfrom
jbedard:npm-packaged
Jun 24, 2022
Merged

test: do not depend on a global npm binary#23326
clydin merged 1 commit into
angular:mainfrom
jbedard:npm-packaged

Conversation

@jbedard

@jbedard jbedard commented Jun 9, 2022

Copy link
Copy Markdown
Contributor

When sandboxed in bazel there is no accessible npm and it must be installed manually some way or another. The npm shipped with node is also not accessible (see bazel-contrib/rules_nodejs#3467).

This yarn npm is for the test-runner to install the packages being tested, not for the tests themselves which use a custom cli/npm/yarn within the test process.

Best attempt at using yarn: 975f92a

@jbedard
jbedard marked this pull request as ready for review June 9, 2022 01:26
@jbedard
jbedard requested review from alan-agius4 and clydin June 9, 2022 01:26
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Jun 10, 2022
Comment thread package.json
"minimatch": "5.1.0",
"ng-packagr": "14.0.0",
"node-fetch": "^2.2.0",
"npm": "^8.11.0",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be possible to use the in-repo version of yarn instead? This would avoid adding another dependency. yarn is also the package manager used for other development related tasks and configured for use by Bazel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think we can do that.

This is just what is used to install the packages being tested so I don't think npm/yarn or the version really matters. Those packages being tested are the cli + yarn + npm and those are the versions which matter (yes, we are discussing the npm/yarn that installs cli+npm+yarn 😨).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@clydin that seems to cause issues with some of the tests which use npm, and now npm and yarn are sharing the same directory which contains the globals? So they have the same globals directory but different global DBs I think?

  Error: Running "npm install --global @angular/cli --registry=http://localhost:34837" returned error. 1...
  STDOUT:
  STDERR:
  npm ERR! code EEXIST
  npm ERR! path /mnt/ramdisk/e2e-main/npm-global/bin/ng
  npm ERR! EEXIST: file already exists
  npm ERR! File exists: /mnt/ramdisk/e2e-main/npm-global/bin/ng
  npm ERR! Remove the existing file and try again, or run npm
  npm ERR! with --force to overwrite files recklessly.

Fixing that will probably require more changes that I'd rather not do right now. Are we ok sticking with the my original commit (46a029c)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok this actually had an easy and obvious fix... the global npm and yarn directories/databases just need to be separate. See diff

@jbedard jbedard Jun 14, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using yarn also requires using yarn for all (un)installations of the packages being tested (cli, yarn, npm): diff1, diff2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now yarn seems to be having other issues. I've seen an issue publishing saying there's a version conflict (the tested cli package depends on something that doesn't exist?), that might be related to this other one:

  npm ERR! code E404
  npm ERR! 404 Not Found - GET http://localhost:62353/pend - no such package available
  npm ERR! 404 
  npm ERR! 404  'pend@~1.2.0' is not in this registry.
  npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
  npm ERR! 404 
  npm ERR! 404 Note that you can also install from a
  npm ERR! 404 tarball, folder, http url, or git url.

?

Are we ok going back to my original change keeping things as-is using npm? It just means installing the extra npm package...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's the commit trying to switch to yarn: 975f92a

I'm going to switch this PR back to npm and we can maybe try yarn again in the future.

@jbedard
jbedard force-pushed the npm-packaged branch 2 times, most recently from 46a029c to 9d506c9 Compare June 10, 2022 23:00
@alan-agius4 alan-agius4 removed the action: merge The PR is ready for merge by the caretaker label Jun 12, 2022
@jbedard
jbedard requested review from alan-agius4 and clydin June 14, 2022 17:07
@jbedard
jbedard force-pushed the npm-packaged branch 8 times, most recently from 2a938ee to 975f92a Compare June 14, 2022 22:38
@alan-agius4
alan-agius4 removed their request for review June 16, 2022 15:46
@alan-agius4 alan-agius4 added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jun 16, 2022
@alan-agius4

Copy link
Copy Markdown
Collaborator

@jbedard, can you please rebase?

@jbedard

jbedard commented Jun 16, 2022

Copy link
Copy Markdown
Contributor Author

Rebased

@jbedard
jbedard requested a review from alan-agius4 June 24, 2022 01:36
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jun 24, 2022
@clydin
clydin merged commit 7dd8228 into angular:main Jun 24, 2022
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jul 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants