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

Update Calypso to Node 20 #83585

Merged
merged 10 commits into from
Nov 13, 2023
Merged

Update Calypso to Node 20 #83585

merged 10 commits into from
Nov 13, 2023

Conversation

noahtallen
Copy link
Contributor

@noahtallen noahtallen commented Oct 27, 2023

This supersedes #81798. We had to revert that PR due to a unit test failure which appeared on trunk. We didn't catch it in our branch due to an oversight with our unit test setup. (The specific change in this branch compared to the original PR is c5c1d64)

The only reason we had to revert was tschaub/mock-fs#380, which is that certain Node FS methods don't get mocked properly with the mock-fs package under node 20. A small manual mock seems to fix the issue.

The specific reason that the unit tests build is because of our base image setup. This base image is rebuilt twice per day, and includes all the binaries and tools for building and testing Calypso. As a result, this contains the Node image. Therefore, the branch unit test build points at the current "latest" base image, which does not include Node 20. Once we merged the PR, and run the "base image" build, then the latest base image includes "node 20." After that, every build started using the new Node version, including unit tests. While we tested a few builds (such as calypso.live) using a test base image which included Node 20, we didn't do that for the unit tests.

There is definitely room for improvement with how we test these PRs, but here's what we can do now:

  • Use our existing test base image (with the tag test-node-20)
  • Manually run a unit test build pointing to this tag and branch
image

@noahtallen noahtallen added the [Type] Tooling Related to tools, scripts, automation, DevX, etc. label Oct 27, 2023
@noahtallen noahtallen self-assigned this Oct 27, 2023
@noahtallen noahtallen requested review from worldomonation and a team as code owners October 27, 2023 11:25
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 27, 2023
@github-actions
Copy link

github-actions bot commented Oct 27, 2023

@noahtallen noahtallen requested review from flootr and a team October 27, 2023 11:26
@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@noahtallen
Copy link
Contributor Author

noahtallen commented Oct 30, 2023

The new test failure is a regression in NodeJS from what I can tell. Try this code in the Node repl (e.g. just execute node by itself):

console.log(new Intl.NumberFormat('en-ZA', { style: 'currency', currency: 'ZAR' }).format(12.34));
  • Node version 18: R 12,34
  • Node version 20: R 12.34
  • Browser (Firefox): R 12,34

From what I understand, the comma is the correct variant. I reported this to Node as it doesn't seem like an issue on our side: nodejs/node#50477.

Now, as far as I know we never render currencies using Node (in SSR), so the browser would be executing the formatter function meaning this wouldn't impact customers. Should we skip this test until they fix it, or patch our formatter to replace decimals with commas if ZAR is the currency? Curious for your thoughts @sirbrillig

@flootr
Copy link
Contributor

flootr commented Oct 30, 2023

nodejs/node#50477 (comment) links to https://unicode-org.atlassian.net/browse/CLDR-14707 which indicates this change happened on purpose so we might want to adapt our tests accordingly? cc @sirbrillig

@sirbrillig
Copy link
Member

Should we skip this test until they fix it, or patch our formatter to replace decimals with commas if ZAR is the currency?

Interesting! For reference, on my sandbox with PHP, I see we use a comma for ZAR in en-ZA, but I'm not certain which version of CLDR that's using. On my local computer with PHP, we use a period, so it appears that this is being updated across all systems that implement CLDR formatting.

I've encountered a similar issue before on the backend and the way I resolved it was to make the currency unit tests accept multiple formats (in this case, either a comma or a period) for the specific currency which is transitioning.

client/my-sites/store/app/store-stats/test/utils.js is not a test suite I'm familiar with, so we should probably check with its maintainers but I'd say that it might be best to make the test support either both separators or whatever the current version of JS says is the separator, which can be derived from Intl.NumberFormat.

@flootr
Copy link
Contributor

flootr commented Oct 31, 2023

I'd say that it might be best to make the test support (…) both separators

👍🏻 Added via f61e50e

The tests seem to be quite old (#16035) and I'm not exactly sure what implementation they were testing back then. To me it looks like today we're defaulting to Intl.NumberFormat (via @automattic/format-currency). The tests can probably be improved by either mocking away the formatCurrency dependency or spying on it to see whether it get's called when it should be with the right params but I feel like that's out of scope for this PR.

@anomiex anomiex mentioned this pull request Nov 9, 2023
3 tasks
@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • happy-blocks

To test WordPress.com changes, run install-plugin.sh $pluginSlug update-node-20 on your sandbox.

@noahtallen
Copy link
Contributor Author

noahtallen commented Nov 10, 2023

@noahtallen noahtallen merged commit 4153391 into trunk Nov 13, 2023
@noahtallen noahtallen deleted the update-node-20 branch November 13, 2023 14:19
@github-actions github-actions bot 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, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Tooling Related to tools, scripts, automation, DevX, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants