Dan Van Brunt
03/25/2022, 8:10 PMyarn/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.
- 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
Frank
yarn.lock
and **/node_modules
, after u restore, yarn install
finishes instantly.Frank
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.Dan Van Brunt
03/28/2022, 1:56 PM