[release-4.22] CONSOLE-5011: migrate to yarn berry#15986
[release-4.22] CONSOLE-5011: migrate to yarn berry#15986openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
Conversation
5d42266 to
906d4b4
Compare
9ffb88d to
2f6636b
Compare
|
@logonoff: This pull request references CONSOLE-5011 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
9f3f11c to
89b3ba2
Compare
📝 WalkthroughWalkthroughThis pull request upgrades the project from Yarn v1 (Classic) to Yarn v4 (Berry) and introduces Corepack as the package manager version manager. Changes include: updating configuration files to use 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
@logonoff: This pull request references CONSOLE-5011 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target only the "4.22.0" version, but multiple target versions were set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@frontend/package.json`:
- Line 60: The "generate" npm script currently runs "yarn generate-graphql &
yarn build-plugin-sdk" which launches both tasks in the background and returns
immediately, causing a race with the webpack build; change the "generate" script
to run the tasks sequentially so generation finishes before build (for example
replace the command with "yarn generate-graphql && yarn build-plugin-sdk") so
that the "generate" script (and downstream "build" that depends on it) always
sees completed generated types/SDK artifacts.
In `@frontend/packages/console-dynamic-plugin-sdk/package.json`:
- Around line 10-14: The scripts currently background multiple processes (using
&), causing the parent script to exit before children finish; update the
"compile" script to run the three tsc commands in background and then block
until they finish (e.g., append a wait after "yarn compile-core & yarn
compile-internal & yarn compile-webpack") and update the "generate" script to
run "yarn generate-schema && yarn generate-doc & yarn generate-pkg-assets" but
ensure the backgrounded generate-doc is followed by a wait so "generate" only
returns after generate-doc completes; refer to the "compile", "compile-core",
"compile-internal", "compile-webpack", "generate", "generate-doc", and
"generate-pkg-assets" script entries when making the changes.
🧹 Nitpick comments (1)
README.md (1)
421-423: Add language specifier to the fenced code block.Static analysis flagged this code block as missing a language identifier. Adding
shorbashimproves syntax highlighting and linter compliance.📝 Proposed fix
-``` +```sh yarn dedupe --strategy highest</details> </blockquote></details> </blockquote></details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
| "prettier-all": "prettier --write '**/*.{js,jsx,ts,tsx,json}'", | ||
| "ts-node": "ts-node -O '{\"module\":\"commonjs\"}'", | ||
| "generate": "yarn generate-graphql && yarn build-plugin-sdk", | ||
| "generate": "yarn generate-graphql & yarn build-plugin-sdk", |
There was a problem hiding this comment.
Parallel generate script lacks wait - may cause race with webpack build.
Same issue as the SDK package: yarn generate-graphql & yarn build-plugin-sdk forks both jobs and returns immediately. Since build (line 19) chains yarn generate && ... webpack, webpack may start before codegen/SDK generation completes, leading to missing generated types or stale SDK artifacts.
🐛 Proposed fix
- "generate": "yarn generate-graphql & yarn build-plugin-sdk",
+ "generate": "yarn generate-graphql & yarn build-plugin-sdk & wait",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "generate": "yarn generate-graphql & yarn build-plugin-sdk", | |
| "generate": "yarn generate-graphql & yarn build-plugin-sdk & wait", |
🤖 Prompt for AI Agents
In `@frontend/package.json` at line 60, The "generate" npm script currently runs
"yarn generate-graphql & yarn build-plugin-sdk" which launches both tasks in the
background and returns immediately, causing a race with the webpack build;
change the "generate" script to run the tasks sequentially so generation
finishes before build (for example replace the command with "yarn
generate-graphql && yarn build-plugin-sdk") so that the "generate" script (and
downstream "build" that depends on it) always sees completed generated types/SDK
artifacts.
There was a problem hiding this comment.
No race because yarn will wait for the reporting of the commands in the && where this is called. But adding wait here also makes the output more consistent:
no wait:
"task1": "timeout 5s node -e \"console.log('Running task 1');\"",
"task2": "timeout 5s node -e \"console.log('Running task 2');\"",
"task3": "timeout 5s node -e \"console.log('Running task 3');\"",
"task4": "timeout 5s node -e \"console.log('Running task 4');\"",
"taska": "yarn task1 & yarn task2 ^",
"taskb": "yarn task3 & yarn task4 ^",
"task": "yarn taska && yarn taskb",
$ yarn task
[1] Running task 1
Running task 2
Job [1], 'yarn task1' has ended
[1] Running task 3
Running task 4
Job [1], 'yarn task3' has ended
wait:
"task1": "timeout 5s node -e \"console.log('Running task 1');\"",
"task2": "timeout 5s node -e \"console.log('Running task 2');\"",
"task3": "timeout 5s node -e \"console.log('Running task 3');\"",
"task4": "timeout 5s node -e \"console.log('Running task 4');\"",
"taska": "yarn task1 & yarn task2 ^ & wait",
"taskb": "yarn task3 & yarn task4 ^ & wait",
$ yarn task
[1] Running task 1
[2] Running task 2
Job [1], 'yarn task1' has ended
Job [2], 'yarn task2 ^' has ended
[2] Running task 4
[1] Running task 3
Job [2], 'yarn task4 ^' has ended
Job [1], 'yarn task3' has ended
There was a problem hiding this comment.
@logonoff, thank you for the detailed clarification and examples! You're absolutely right — since the build script uses && (line 19), Yarn will indeed wait for yarn generate to complete before proceeding to webpack. My concern about a race condition was based on an incomplete understanding of the calling context.
I appreciate the thorough explanation with the output examples showing how wait improves consistency by ensuring all background jobs report completion before the script exits. If you decide to add wait for that benefit, it would be a nice touch for clearer logging, but I understand now that it's not required for correctness.
Thanks for setting this straight! 🙏
|
@logonoff: This pull request references CONSOLE-5011 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target only the "4.22.0" version, but multiple target versions were set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
added /verified by CI |
|
@logonoff: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
AI is wrong, can't use /verified by CI |
|
@logonoff: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
changes are critical to meet impending deadline /label acknowledge-critical-fixes-only |
|
Let's get some additional verification /verified cancel |
|
@logonoff: The DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/verified remove |
|
@logonoff: This PR has been marked to be verified later by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/verified later @yapei |
|
@logonoff: The DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@logonoff: This PR has been marked to be verified later by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
| "build": "yarn clean && NODE_ENV=production yarn ts-node node_modules/.bin/webpack", | ||
| "build-dev": "yarn clean && yarn ts-node node_modules/.bin/webpack", | ||
| "build-plugin-sdk": "yarn --cwd ../frontend build-plugin-sdk && yarn install-plugin-sdk", | ||
| "install-plugin-sdk": "rm -rf node_modules/@openshift-console && yarn install --check-files", |
There was a problem hiding this comment.
Does Yarn Berry yarn install fill the missing node_modules/@openshift-console/* packages while other node_modules/* packages are still in place?
There was a problem hiding this comment.
Yes
console/dynamic-demo-plugin$ rm -rf node_modules/@openshift-console && yarn
➤ YN0000: · Yarn 4.12.0
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0s 603ms
➤ YN0000: ┌ Post-resolution validation
➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details.
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 2s 85ms
➤ YN0000: ┌ Link step
➤ YN0072: │ The application uses portals and that's why --preserve-symlinks Node option is required for launching it
➤ YN0000: └ Completed in 2s 159ms
➤ YN0000: · Done with warnings in 5s 69ms
console/dynamic-demo-plugin$ ls node_modules/@openshift-console/
dynamic-plugin-sdk dynamic-plugin-sdk-webpack
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logonoff, rhamilto, vojtechszocs The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@logonoff: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
This PR (and its "backports" all the way to 4.12) aim to perform the mandatory migration from yarn classic to yarn berry (of the v4 variety).
Changes
See #15995 for some preparatory work that was done from 4.12 to 4.18.
Note: the list of changes are descriptive for all backport PRs. Some of these changes may not apply to every backport.
main branch only (tracking
release-4.22as of merge)yarn dedupestuff with the yarn berry-provided version4.22 to 4.12
Dockerfiles to install corepack instead of yarn v1dynamic-demo-plugin, symlink.yarnrc.ymland the.yarn/releasesfolder to reduce config duplicationpackage.jsonscripts to have syntax compatible with yarn berrycheck-patternfly-modulesscript to use new yarn berry parsing packageportalinstead offilenowupdate-patternfly.shbecause PatternFly no longer consistently has all libraries to the same version.yarn/releasesto point to yarn v4. Note that this is for installations (e.g.,tectonic-console-builder:v29) which already have yarn classic installed globally. They will read this updated binary and automatically run yarn berry. We can remove this when our builder image switches fully over to corepack4.21 to 4.12
yarn dedupecheck (in 4.21 this is done in a follow-up [release-4.21] OCPBUGS-77430: run and enforceyarn dedupe#16075)4.20 to 4.12
yarn generatefrom postinstall script (backport of NO-JIRA: Remove yarn-generate from post-install script #15373)4.19 only
tectonic-console-builderfrom v28 to v29How to set up your computer to use berry
Note that you may want to remove yarn classic when setting up your computer to use yarn berry. Here's how to update your system to use it:
dnf remove yarnpkg,npm uninstall -g yarn,brew uninstall yarnnpm i -g corepack(node ships with an older version)corepack enable(note that corepack also works with our repo pre-yarn berry adoption, it will run yarn classic as needed)Possible test cases
package.jsonnow works the same as beforeDockerfile.buildercan build console,Dockerfilebuilds console frontend/backend,Dockerfile.plugins.demobuilds demo plugin.Dockerfile.product.nodejsdoes not but that is due to an outdated node version. Let's delete it in a follow up.gitfolder infrontendis created everbuild.sh, etc.) work fine on an initial repo state, switching branches, etc.Backports