-
Notifications
You must be signed in to change notification settings - Fork 202
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 pnpm and use corepack #4628
Conversation
3bd8050
to
2ce40f2
Compare
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 even though it's a draft because it's great. I love Corepack and happy to see it being used more.
@@ -3,6 +3,7 @@ | |||
"description": "Openverse frontend", | |||
"private": true, | |||
"version": "2.2.1", | |||
"packageManager": "pnpm@9.5.0", |
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.
Please correct me if I'm wrong but I was under the impression that packageManager
is only read from the package.json
in the repo root.
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 necessary for the Playwright Docker setup, not the frontend (I think frontend can use the root package.json). The node corepack docs say "The Corepack proxies will find the closest package.json file in your current directory hierarchy to extract its "packageManager" property."
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.
It'd be great to run Playwright from the repo root context instead, if not for this PR (makes sense, might be a big change), then in a separate issue.
It would be really great if Playwright ran inside ov
so we didn't have to have a separate docker container for it, but that's a separate story.
@@ -3,6 +3,7 @@ | |||
"description": "Openverse frontend", | |||
"private": true, | |||
"version": "2.2.1", | |||
"packageManager": "pnpm@9.5.0", |
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.
It'd be great to run Playwright from the repo root context instead, if not for this PR (makes sense, might be a big change), then in a separate issue.
It would be really great if Playwright ran inside ov
so we didn't have to have a separate docker container for it, but that's a separate story.
.github/actions/setup-env/action.yml
Outdated
uses: pnpm/action-setup@v3 | ||
# Automatically reads `packageManager` field from root `package.json`. | ||
shell: bash | ||
# Corepack automatically reads `packageManager` field from root `package.json`. |
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 kind of comment is sort of just documenting what Corepack is isn't it? Do we need this kind of comment? I'd argue it wasn't necessary for pnpm/action-setup
either.
What's the benefit of using corepack here instead of the action, by the way? Just consistency or is there something else? The action does quite a lot of things, including basic clean up steps that are apparently necessary for GitHub actions (store prune at the end of the job, for example).
Is corepack by itself, without any additional support steps or jobs, sufficient to actually replace what pnpm/action-setup
does? It's not only installing pnpm, after all: https://github.com/pnpm/action-setup/blob/master/src/index.ts#L8-L17
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.
The main reason is consistency and the removal of one extra dependency that needs to be updated.
I've seen many large projects use corepack enable
instead of pnpm/action-setup
. Do you think we really need all of the steps that the action does? Is store pruning important during the CI, if we are discarding the containers at the end anyway?
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.
I have no idea what the purpose of store pruning is at the end of the action, all I know is that pnpm/action-setup
does it, and lots of other actions have similar clean up type steps. I have not read about why that is or what the advice is for this (I've never written of this nature). To clarify, store pruning is on the host, not inside the docker images, so relevant for when we run pnpm install
in the next step after this one.
Based on a quick search, I can't find anything clear or definitive on why clean up steps are necessary, other than suggestions that while runners are intended to be ephemeral, clean up helps prevent any accidental leaks between runners. In our case, the pnpm store shouldn't have an issue in that regard, not that I can think of off the top of my head. We don't download and proprietary packages from private repositories, for example, so it isn't like there is IP that could leak between runners if ephemerality didn't work as expected. It also seems like it might be more relevant for self-hosted runners (perhaps those have different behaviour in this regard).
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
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.
Don't have much to add beyond what others have shared, but I'm glad we can get rid of some of the env vars here! 🙂
Fixes
Fixes #3807 by @dhruvkb
Description
This PR replaces
pnpm/action-setup@v3
withcorepack enable
for setting uppnpm
in the CI and Docker containers.For the Playwright Docker containers, corepack looks into the closest
package.json
file to find the pnpm version, so I added it in thefrontend/package.json
Since we no longer need to provide the pnpm version to the set up script (it's extracted from
package.json
'spackageManager
field), I removed the related env variables.Testing Instructions
The CI should pass.
Checklist
Update index.md
).main
) or a parent feature branch.ov just catalog/generate-docs
for catalogPRs) or the media properties generator (
ov just catalog/generate-docs media-props
for the catalog or
ov just api/generate-docs
for the API) where applicable.Developer Certificate of Origin
Developer Certificate of Origin