DEV: Limit re-use of bundler/yarn caches in CI (#24256)

Using restore-keys means we will always use an old cache, and then add more dependencies to it. This leads to the cache growing over time and becoming increasingly slow. Instead, we should rebuild the cache from scratch each time our dependencies change.
This commit is contained in:
David Taylor
2023-11-10 10:03:15 +00:00
committed by GitHub
parent c0c525056f
commit de8c8f1d28

View File

@@ -80,8 +80,7 @@ jobs:
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: vendor/bundle path: vendor/bundle
key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }} key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}-cachev2
restore-keys: ${{ runner.os }}-${{ matrix.ruby }}-gem-
- name: Setup gems - name: Setup gems
run: | run: |
@@ -101,8 +100,7 @@ jobs:
id: yarn-cache id: yarn-cache
with: with:
path: ${{ steps.yarn-cache-dir.outputs.dir }} path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-cachev2
restore-keys: ${{ runner.os }}-yarn-
- name: Yarn install - name: Yarn install
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
@@ -307,8 +305,7 @@ jobs:
id: yarn-cache id: yarn-cache
with: with:
path: ${{ steps.yarn-cache-dir.outputs.dir }} path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-cachev2
restore-keys: ${{ runner.os }}-yarn-
- name: Yarn install - name: Yarn install
working-directory: ./app/assets/javascripts/discourse working-directory: ./app/assets/javascripts/discourse