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

chore(infra): test Node.js v16 and expand "engines" range to include it #713

Merged
merged 14 commits into from
May 3, 2021

Conversation

abernix
Copy link
Member

@abernix abernix commented Apr 30, 2021

This PR introduces testing for and expands package's engines range for the node engine to support the v16 line, which was recently released and is scheduled to go into it's Long-Term Support contract with the Node.js Foundation in October. This PR targets the npm@7 upgrade PR (#708).

I've made a couple other related changes within this PR, but of notable importance, I've intentionally disabled Renovation of Docker images within CircleCI because I'm pretty sure that right now, by having moved the docker.image property into this file, rather than in the Orb (which I think is the right direction to go), it would just be updating everything to the true numerical latest version (e.g., 16, or even 17), which is not what we want. (e.g., all our tests which intentionally test different versions of Node.js would test the same recent version). I think I know how to fix this, but I don't want to couple it to this PR and don't have time to look into it further at the moment (and would benefit from some local development time with Renovate and this PR actually having landed already).

This also updates the docs repository.

The `engines-strict` setting in the `.npmrc` will enforce that the operators
of this repository are using the right version.  Someone who wishes to
circumvent this can pass `--ignore-engines` when running `npm install`, much
like someone circumventing a library's own `engines` requirements.
The newer images are smaller and suggested to be widely cached.  In
practice, the older images are widely cached because they're still more
prevalent but happy to use the newer images, particularly since the older
images aren't getting as much in the way of updates anymore (e.g., there are
not any Node.js 16 images for it.)
Using this instead of `.nvmrc` since this allows more granular control over
the `npm` version that gets installed.

Ref: https://docs.netlify.com/configure-builds/manage-dependencies/#npm
The constraint on this can be enforced exclusively at the monorepo level
since this package is not published and that constraint need not be conveyed
by any user at runtime.
The "circleci" manager is intentionally disabled as of this commit.

While we do benefit from its updating of "Orb" versions, the CircleCI
manager also attempts to update Docker images using its "Docker" datasource.

This is really handy, in theory, but we have intentionally varying major
Node.js docker image identifiers in our CircleCI configuration to test on
each major Node.js platform!  I suspect that enabling the "circleci" manager
would cause all of these to update to the latest version (e.g., 16) when we
want them to be intentionally different!

I'm going to try to craft an fix for this, but I might do it upstream on
Renovate itself using its Regex manager.  It's also worth noting that there
is other configuration that could be used to _only_ renovate "orbs" on this
file, but I'm taking the short-cut route and not juggling with that right
now.  I can test the repository locally with my own copy of Renovate and
come up with another solution given some free time.
// there is other configuration that could be used to _only_ renovate "orbs"
// on this file, but I'm taking the short-cut route and not juggling with
// that right now. I can test the repository locally with my own copy of
// Renovate and come up with another solution given some free time. -Jesse
Copy link
Member Author

Choose a reason for hiding this comment

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

@abernix abernix requested a review from a team April 30, 2021 15:42
@abernix abernix marked this pull request as ready for review April 30, 2021 15:43
@abernix abernix changed the title Node.js v16 chore(infra): Node.js v16 Apr 30, 2021
@abernix abernix requested review from glasser, martijnwalraven, pcmanus and trevor-scheer and removed request for a team April 30, 2021 17:33
@abernix abernix force-pushed the abernix/node-16 branch 2 times, most recently from 5931d1d to 99f1a3d Compare April 30, 2021 17:37
@abernix abernix force-pushed the abernix/node-16 branch 5 times, most recently from 82be098 to a2696a0 Compare May 1, 2021 11:58
To overcome an error which was occurring during the "Rustup install" step
that was producing a "memory allocation of 16777216 bytes failed" error that
was ALSO NOT causing the _setup_ step to fail, this commit:

- Use the 64-bit installer rather than the 32-bit!  I would have thought
  that this on its own could have been the major root of the problem, but it
  seems like it's also paired best with the next bullet.

- Limits the amount of RAM for the _installation of Rust_ (and nothing else),
  overriding the auto-detection which seems un-reliable in this virtual env.
  rust-lang/rustup#2229 (comment)

- Uses a larger resource size, which actually makes the tests run faster
  anyhow.  This will use more credits but use less minutes.  I'll look at
  the numbers in a month to see what I think, but I'm not worried right now.
  (note to self: 76203c/1900m, right now, jesse)

- Prevent missed failure catch in installation via .exe file, instead opting
  for using LASTEXITCODE which seems to be a recommended way to do this when
  using EXE files.  Having the "echo" there certainly seems like it could
  have been hurting things too (since echo returns 0, but that didn't seem to
  fix it on its own).
@abernix abernix force-pushed the abernix/node-16 branch 2 times, most recently from 136fe89 to e25349b Compare May 1, 2021 12:27
@glasser glasser mentioned this pull request May 1, 2021
netlify.toml Show resolved Hide resolved
// its "Docker" datasource. This is really handy, in theory, but we have
// intentionally varying major Node.js docker image identifiers in our
// CircleCI configuration to test on each major Node.js platform. Enabling
// the "circleci" manager would cause all of these to update to the latest
Copy link
Member

Choose a reason for hiding this comment

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

I'm not trying to verify whether this is true or not (I kinda hope it's actually not hard to tell it not to take major version bumps), happy to move forward with circleci disabled for now even if there's a chance you're being overly conservative.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect it's easy to tell it to not take major version bumps for this file, yes.

Copy link
Contributor

@martijnwalraven martijnwalraven left a comment

Choose a reason for hiding this comment

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

I don't know enough about CircleCI and Renovate to review those changes, but the rest looks good to me!

@abernix
Copy link
Member Author

abernix commented May 3, 2021

Just FYI: I landed e25349b via #729, rather than packaging it within this PR.

Base automatically changed from abernix/npm7 to main May 3, 2021 09:47
@abernix abernix changed the title chore(infra): Node.js v16 chore(infra): add support and testing for Node.js v16 May 3, 2021
@abernix abernix changed the title chore(infra): add support and testing for Node.js v16 chore(infra): test Node.js v16 and expand "engines" range to include it May 3, 2021
@abernix abernix enabled auto-merge (squash) May 3, 2021 10:07
@abernix abernix merged commit a834c19 into main May 3, 2021
@abernix abernix deleted the abernix/node-16 branch May 3, 2021 10:08
glasser added a commit to apollographql/apollo-server that referenced this pull request May 3, 2021
Inspired by apollographql/federation#708 as well
as the Netlify change in
apollographql/federation#713

This also fixes engines declarations in the individual packages which
should have been done in #5137.
glasser added a commit to apollographql/apollo-server that referenced this pull request May 3, 2021
Inspired by apollographql/federation#708 as well
as the Netlify change in
apollographql/federation#713

This also fixes engines declarations in the individual packages which
should have been done in #5137.
glasser added a commit to apollographql/apollo-server that referenced this pull request May 3, 2021
Inspired by apollographql/federation#708 as well
as the Netlify change in
apollographql/federation#713

This also fixes engines declarations in the individual packages which
should have been done in #5137.

Also fix a weird problem related to `@apollo/protobufjs`. For some reason, Node 12 and 14 with npm 7 (but not Node 16!) was running into an issue where the fact that `@apollo/protobufjs` doesn't actually depend on a bunch of packages like `espree` that its CLI needs caused the `apollo-pbjs` calls to fail. I think when we forked, protobuf.js was midway through a refactor to make the CLI into a separate package, but we haven't set that up to work in our fork.  Adding all those big packages as dependencies of `@apollo/protobufjs` didn't seem great because that would make them non-dev dependencies of apollo-server themselves. Splitting the packages (and making the CLI package a devDep of apollo-reporting-protobuf) is the best long-term solution but for now adding the CLI deps as devDependencies of apollo-reporting-protobuf appears to work?
@holm
Copy link

holm commented Dec 16, 2021

I'm trying to update to Node 17 in my project, but I am blocked by yarn, as these packages restrict the use of this engine. It seems very pessimistic to have an upper bound on the node version, as for the vast majority of times, a new Node version will not break these packages. This can also be seen by there being no actually code change in this PR.

@holm
Copy link

holm commented Dec 16, 2021

For reference, for the gateway package, the upper limit was added in this commit: 4ef79ae#diff-e441a2bec2f27de2e89f69427e4837410164f9ad4dd7e9428e4286b024ee5d78R15

But I can't really find anything in the commit message or PR that indicates why this was done.

@trevor-scheer
Copy link
Member

@holm It’s not unreasonable for a library to be pessimistic about supporting various major versions without first validating that things aren’t broken. No upper bound means we're claiming support for ALL future major versions of Node in those releases. We'd rather ship with a clear expectation of what we support than allow our users to break unexpectedly. Yarn supports working around this (buyer beware) via the --ignore-engines flag, which I welcome you to use! I’d also welcome you to open a separate issue or PR to introduce testing and support for Node v17.

@holm
Copy link

holm commented Dec 17, 2021

It may not be unreasonable, but I don't think it's very helpful. NodeJS goes out of their way to be as backwards compatible as possible and from my experience, it is incredibly rare for packages to break in new node versions, unless they rely on internal APIs og uses C code.

--ignore-engines is painful to use. You cannot persist the config, so your CI system, your deployment system, etc has to be updated. In addition all collaborators now have to remember to add the flag every time they run yarn to install new packages, which is a daily occurrence. It also has the big drawback that it will ignore cases where your engine version is too low, which is really what the yarn check is all about, see. f.ex. yarnpkg/rfcs#69 (comment) directly from Saccone.

It's the choice of the maintainers of course, I think it's just an annoyance with a tiny benefit.

trevor-scheer pushed a commit to apollographql/apollo-datasource that referenced this pull request Feb 1, 2022
Inspired by apollographql/federation#708 as well
as the Netlify change in
apollographql/federation#713

This also fixes engines declarations in the individual packages which
should have been done in #5137.

Also fix a weird problem related to `@apollo/protobufjs`. For some reason, Node 12 and 14 with npm 7 (but not Node 16!) was running into an issue where the fact that `@apollo/protobufjs` doesn't actually depend on a bunch of packages like `espree` that its CLI needs caused the `apollo-pbjs` calls to fail. I think when we forked, protobuf.js was midway through a refactor to make the CLI into a separate package, but we haven't set that up to work in our fork.  Adding all those big packages as dependencies of `@apollo/protobufjs` didn't seem great because that would make them non-dev dependencies of apollo-server themselves. Splitting the packages (and making the CLI package a devDep of apollo-reporting-protobuf) is the best long-term solution but for now adding the CLI deps as devDependencies of apollo-reporting-protobuf appears to work?
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.

5 participants