Slightly unrelated…. but does anyone have a “worki...
# help
d
Slightly unrelated…. but does anyone have a “working” solution for caching
yarn/node_modules
in
github actions
? I read this SO and this in the cache action docs as well as this article and no one seems to agree on the best approach. We want things to run as fast as possible and currently with just the following…. it seems to reinstall everything every time… which is LOOOOONG.
Copy code
- name: Get yarn cache directory path
  id: yarn-cache-dir-path
  run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
  id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  with:
    path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
    key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
    restore-keys: |
      ${{ runner.os }}-yarn-

- name: Install Dependencies
  run: yarn install --frozen-lockfile
f
in my experience, if you cahced
yarn.lock
and
**/node_modules
, after u restore,
yarn install
finishes instantly.
Caching the
yarn cache dir
is the “best practice”, but that often just speeds up the “downloading packages” step. `yarn install`still have to figure out and build the whole
node_modules
structure.
d
ya… thats what we’re doing now… just caching node_modules and using the lock file to bust.