-
Notifications
You must be signed in to change notification settings - Fork 0
Support yarn 4 projects #5
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
base: master
Are you sure you want to change the base?
Changes from all commits
0520b6f
f7016d8
0593c86
7f9243d
f96bbb6
2f0a6cd
7cf2b16
f7be1b0
b58856a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,17 +23,27 @@ jobs: | |
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: ".nvmrc" | ||
| cache: "yarn" | ||
|
|
||
| - name: Enable Corepack | ||
| run: corepack enable | ||
|
|
||
| - name: Get yarn cache directory path | ||
| id: yarn-cache-dir-path | ||
| run: echo "YARN_CACHE_DIR=$(yarn cache dir)" >> $GITHUB_ENV | ||
| run: | | ||
| YARN_MAJOR=$(yarn --version | cut -d. -f1) | ||
| if [ "$YARN_MAJOR" = "1" ]; then | ||
| CACHE_DIR=$(yarn cache dir) | ||
| else | ||
| CACHE_DIR=$(yarn config get cacheFolder) | ||
| fi | ||
| if [ -z "$CACHE_DIR" ]; then CACHE_DIR="$RUNNER_TEMP/yarn-cache"; fi | ||
| echo "ACTIONS_YARN_CACHE_PATH=$CACHE_DIR" >> $GITHUB_ENV | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems some kind of cache is supported out of the box from v2, maybe this pattern was necessary only for v1? (I am not really familiar with this) https://github.com/actions/setup-node?tab=readme-ov-file#caching-global-packages-data
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested that approach explicitly to simplify the workflow, but it fails for Yarn 4 projects before we even reach When So in this case I’m intentionally keeping |
||
|
|
||
| - name: Cache yarn dependencies | ||
| uses: actions/cache@v3 | ||
| uses: actions/cache@v5 | ||
| id: yarn-cache | ||
| with: | ||
| path: ${{ env.YARN_CACHE_DIR }} | ||
| path: ${{ env.ACTIONS_YARN_CACHE_PATH }} | ||
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-yarn- | ||
|
|
||
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 in this PR) Above this line we have apt install gettext. I've seen it's common to run apt update && ... first to make sure the package indexes are up to date.
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.
Yes, that makes sense as a defensive improvement. It wasn’t related to the Yarn 4 issue addressed by this PR, which is why I didn’t include it in the original change, but I agree that
apt update && apt install ...would be more correct. I can include it here if you want, or leave it for a separate small cleanup PR.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.
Both options are ok by me.