-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
🪟🔧 Fix node version on CI #20287
🪟🔧 Fix node version on CI #20287
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving pending build
Do we need gradle for this? Couldn't we just use |
I can investigate that next week. My understanding was that npm ci will only install from package-lock.json but wouldn't fail on those minor inconsistencies. That's why I decided to go with the change detection mechanism, but I will give this another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I pulled and tested locally to confirm:
npm install
failed unless I was using node16.18.1
npm build
does not fail when using other versions (although has build errors with node 18 😄 )npm run start
does not fail when using other versions
@@ -72,7 +72,7 @@ jobs: | |||
|
|||
- uses: actions/setup-node@v3 | |||
with: | |||
node-version: "lts/gallium" | |||
node-version: "lts/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is lts/*
ok here? I'm assuming node is just required here (and in other workflows) for some scripting, which is unrelated to any of the frontend build/test steps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only needed for installing prettier from the build.gradle
file for formatting JSON/YAML files (outside the webapp folder). The version here does not really matter, since it only needs any npm version to install prettier, so I made sure this is running on the latest lts instead of gallium.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, should we add a small section to the readme how to keep your local node version in sync using nvm?
I'll put something about this into our development setup guide. |
What
This aligns our node version handling we use across the product. This is caused by us having had
package-lock.json
changes due to a missmatch innpm
versions run during development.How
lts
shorthands, so we are set to an explicit node version, since thelts
version might change over time while new minor releases are incoming..nvmrc
files, to avoid duplication in where we store this version.engines.node
in thepackage.json
as an explicit version. This will now causenpm install
to fail if someone tries to execute it locally with a version that's not exactly the one we're expecting.setup-node
actions from the workflow files, to not cause confusion there with missmatching versions.package-lock.json
files to actually match the now explicitly set npm version... not sure how many times they had a format change during one major version 😩I tried to use the latest LTS support for this, but unfortunately there are still issues with CRA app, that won't work on the latest LTS release, so we're still stuck on LTS Gallium till they fix this: facebook/create-react-app#11708
You'll see there are some
setup-node
actions left in the workflow files. We use Spotless, which uses prettier in the top levelbuild.gradle
file to format JSON and YAML across the repository (except the webapp). Thus the spotless tasks actually needs a locally installednpm
version, why the workflows that trigger a full build still require thenpm
to be installed locally. The version here isn't that important, since it's just using npm once to install prettier, so I set it to the latest lts release. The webapp is not using that npm version, and always will download it's own version via Gradle!I tried to solve this by downloading that Gradle version for spotless also via the gradle node plugin, but that unfortunately doesn't work, since the spotless plugin required it to be there during Gradle's Configuration phase (while parsing the build.gradle files), but the download task cannot download it before the Execution phase (when tasks are actually executed). So we can't leverage gradle to download npm for Spotless.
Follow up
I want to create a separate PR still that adds a Gradle task that makes the FE build (and e2e test build) fail if the
package-lock.json
file is changed after runningnpm install
. Since this requires adding custom tasks I prefer having that in a separate PR.