Skip to content
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

chore: Use setup-node action to cache dependencies #230

Closed
wants to merge 1 commit into from
Closed

chore: Use setup-node action to cache dependencies #230

wants to merge 1 commit into from

Conversation

jongwooo
Copy link
Contributor

Signed-off-by: jongwooo jongwooo.han@gmail.com

Description

Updated workflows to cache dependencies using actions/setup-node. setup-node@v3 or newer has caching built-in.

AS-IS

- uses: actions/setup-node@v3
  with:
    node-version: lts/*

- name: Get yarn cache directory path
  id: yarn-cache-dir-path
  run: echo "::set-output name=dir::$(corepack yarn config get cacheFolder)"

- uses: actions/cache@v3
  with:
    path: ${{steps.yarn-cache-dir-path.outputs.dir}}
    key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
    restore-keys: |
      ${{runner.os}}-yarn-

TO-BE

- uses: actions/setup-node@v3
  with:
    node-version: lts/*
    cache: yarn

It’s literally a one line change to pass the cache: yarn input parameter.

References

Signed-off-by: jongwooo <jongwooo.han@gmail.com>
@merceyz
Copy link
Member

merceyz commented Jan 11, 2023

The caching done by actions/setup-node doesn't have any restore-keys set so this will cause worse performance when there isn't an exact match (actions/setup-node#325).

actions/setup-node also doesn't prefix its Yarn commands with corepack so the CI would need to run corepack enable before actions/setup-node runs.

@jongwooo
Copy link
Contributor Author

actions/setup-node also doesn't prefix its Yarn commands with corepack so the CI would need to run corepack enable before actions/setup-node runs.

@merceyz I didn't know about this part. Thank you for informing me! Is it okay for me to close this pull request if I may?

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@merceyz
Copy link
Member

merceyz commented Jan 12, 2023

That was an issue with Yarn classic, haven't seen the same issue in modern versions.

Is it okay for me to close this pull request if I may? - #230 (comment)

Of course, you can close PRs for any reason.

@jongwooo jongwooo closed this Jan 12, 2023
@jongwooo jongwooo deleted the chore/use-setup-node-action-to-cache-dependencies branch January 12, 2023 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants