-
Notifications
You must be signed in to change notification settings - Fork 38
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(pipeline): cache yarn deps with corepack #2405
Conversation
b909057
to
3375620
Compare
path: | | ||
.yarn/cache | ||
.yarn/unplugged | ||
.pnp.cjs |
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.
what if yarn1 or yarn with node_modules and not pnp ?
...ages/@o3r/pipeline/schematics/ng-add/templates/github/__dot__github/actions/setup/action.yml
Show resolved
Hide resolved
3375620
to
b8e09f7
Compare
07ebae1
to
180663b
Compare
180663b
to
029f331
Compare
- name: Cache dependencies | ||
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
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 not missing the following files:
- .yarn/unplugged
- .pnp.cjs
- .pnp.loader.mjs
?
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.
not sure those are needed. I followed the recommendations from https://github.com/actions/cache/blob/main/examples.md#node---yarn
@@ -41,7 +58,7 @@ function ngAddFn(options: NgAddSchematicsSchema): Rule { | |||
if (!options.npmRegistry) { | |||
return tree; | |||
} | |||
if (packageManager === 'yarn') { | |||
if (yarn2) { | |||
const yarnrcPath = '/.yarnrc.yml'; | |||
if (!tree.exists(yarnrcPath)) { |
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 if
can now be removed
eea1cd3
to
51f858e
Compare
tree.overwrite(yarnrcPath, dump(yarnrcContent, {indent: 2})); | ||
} | ||
} else if (packageManager === 'npm') { | ||
const yarnrcContent = load(tree.readText(yarnrcPath)) as any; |
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.
const yarnrcContent = load(tree.readText(yarnrcPath)) as any; | |
const yarnrcContent = load(tree.readText(yarnrcPath)) as { npmRegistryServer?: string }; |
const yarnrcContent = load(tree.readText(yarnrcPath)) as any; | ||
const yarnPath = yarnrcContent?.yarnPath; |
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.
const yarnrcContent = load(tree.readText(yarnrcPath)) as any; | |
const yarnPath = yarnrcContent?.yarnPath; | |
const { yarnPath } = (load(tree.readText(yarnrcPath)) || {}) as { yarnPath?: string }; |
- name: Get yarn cache directory path | ||
shell: bash | ||
id: yarn-cache-dir-path | ||
run: echo "dir=$(<% if (yarn2) { %>yarn config get cacheFolder<% } else { %>yarn cache dir<% } %>)" >> $GITHUB_OUTPUT |
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.
Shouldn't we update our pipeline as well ?
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.
We could but with a feature request so that the setup action support npm, yarn 1, etc.
Definitely not in a fix on an RC branch.
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.
Can you open the request then please :)
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.
51f858e
to
64c749e
Compare
64c749e
to
8be2a93
Compare
Proposed change
In
node-setup
GitHub action, passingcache: yarn
doesn't work well with corepack (see issues below).The goal is to do the cache manually for yarn and to let
node-setup
do it fornpm
.Related issues
actions/setup-node#531
actions/setup-node#182