githubnext / blocks-template

A template for creating custom Blocks.
MIT License
112 stars 11 forks source link

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

Closed jongwooo closed 1 year ago

jongwooo commented 1 year ago

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

Details

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

AS-IS

- name: Checkout code
  uses: actions/checkout@v3

- name: Install dependencies
  run: yarn install

TO-BE

- name: Checkout code
  uses: actions/checkout@v3

- name: Set up Node.js
  uses: actions/setup-node@v3
  with:
    node-version: 18.x
    cache: yarn

- name: Install dependencies
  run: yarn install --immutable

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

References

jaked commented 1 year ago

thanks for the PR!

This doesn't break anything, but caching doesn't seem to have worked in my test, I'm not sure why. See the runs here, I would have expected the second one to use the cache.

jongwooo commented 1 year ago
Run actions/setup-node@v3
Found in cache @ /opt/hostedtoolcache/node/18.12.1/x64
Environment details
/usr/local/bin/yarn --version
1.22.19
/usr/local/bin/yarn cache dir
/home/runner/.cache/yarn/v6
yarn cache is not found

I would have expected the second one to use the cache.

@jaked That's the correct answer. You can check the cache at the following link.

jaked commented 1 year ago

ok thanks, I guess I don't understand how this is supposed to work but you seem to understand it :)