meta: Fix yarn caching in github actions (#3526)

* Fix yarn caching in github actions

* improve cache take 2

from https://github.com/actions/cache/blob/main/examples.md#node---yarn-2

* fix yarn -> corepack yarn

* fix order of corepack install

* add --immutable to all
This commit is contained in:
Mikael Finstad 2022-03-03 14:26:39 +08:00 committed by GitHub
parent 6559bea96f
commit 32ea099a93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 109 additions and 47 deletions

View file

@ -17,12 +17,23 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Corepack if needed
run: corepack -v || npm install -g corepack
- 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@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 Node.js
uses: actions/setup-node@v2
with:
node-version: ${{matrix.node-version}}
- name: Install Corepack if needed
run: corepack -v || npm install -g corepack
- name: Install dependencies
run: corepack yarn install --immutable
- name: Run tests
@ -34,12 +45,17 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Cache npm dependencies
id: cache-npm-libraries
uses: actions/cache@v2
- 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@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: .yarn/cache/*
key: ${{ runner.os }}
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node.js
uses: actions/setup-node@v2
with:
@ -55,12 +71,17 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Cache npm dependencies
id: cache-npm-libraries
uses: actions/cache@v2
- 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@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: .yarn/cache/*
key: ${{ runner.os }}
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node.js
uses: actions/setup-node@v2
with:
@ -76,6 +97,17 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
- 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@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 Node.js
uses: actions/setup-node@v2
with: