Skip to content

Commit

Permalink
chore: upgrade to actions/cache@v4 (#47282)
Browse files Browse the repository at this point in the history
* chore: add github-actions to dependabot

* chore: upgrade to actions/cache@v4
  • Loading branch information
afc163 committed Feb 1, 2024
1 parent 53b0b24 commit 584593b
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 44 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ updates:
dev-dependencies:
dependency-type: "development"
update-types: ["major"]
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion .github/workflows/mock-project-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
node-version: 18

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~tmpProj/yarn.lock
key: primes-${{ runner.os }}-${{ github.run_id }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: actions/checkout@v4

- name: cache package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}
Expand All @@ -40,7 +40,7 @@ jobs:
cp package-lock.json package-temp-dir
- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand All @@ -58,13 +58,13 @@ jobs:
uses: actions/checkout@v4

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand Down Expand Up @@ -104,13 +104,13 @@ jobs:
uses: actions/checkout@v4

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/site-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v4

- name: cache package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}
Expand All @@ -35,7 +35,7 @@ jobs:
cp package-lock.json package-temp-dir
- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand All @@ -56,13 +56,13 @@ jobs:
node-version: 18

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
node-version: 18

- name: cache package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}
Expand All @@ -40,7 +40,7 @@ jobs:
cp package-lock.json package-temp-dir
- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand All @@ -60,13 +60,13 @@ jobs:
node-version: 18

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand All @@ -75,8 +75,8 @@ jobs:
run: npm run lint

- name: lint:react-16
run: npm run compile && npm run install-react-16 && npm run tsc:old
run: npm run compile && npm run install-react-16 && npm run tsc:old

- name: lint:react-17
run: npm run compile && npm run install-react-17 && npm run tsc:old
needs: setup
Expand All @@ -92,13 +92,13 @@ jobs:
node-version: 18

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand All @@ -117,19 +117,19 @@ jobs:
node-version: 18

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: cache dist
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: dist
key: dist-${{ github.sha }}
Expand Down Expand Up @@ -161,13 +161,13 @@ jobs:
node-version: 18

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand All @@ -186,7 +186,7 @@ jobs:

- name: restore cache from dist
if: ${{ matrix.module == 'dist' || matrix.module == 'dist-min' }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: dist
key: dist-${{ github.sha }}
Expand Down Expand Up @@ -278,25 +278,25 @@ jobs:
node-version: 18

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: cache lib
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: lib
key: lib-${{ github.sha }}

- name: cache es
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: es
key: es-${{ github.sha }}
Expand Down Expand Up @@ -335,23 +335,23 @@ jobs:
- name: restore cache from package-lock.json
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: restore cache from ${{ matrix.module }}
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ matrix.module }}
key: ${{ matrix.module }}-${{ github.sha }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/visual-regression-diff-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@v4

- name: cache package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}
Expand All @@ -42,7 +42,7 @@ jobs:
- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand All @@ -64,13 +64,13 @@ jobs:
node-version: 18

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/visual-regression-persist-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v4

- name: cache package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}
Expand All @@ -37,7 +37,7 @@ jobs:
cp package-lock.json package-temp-dir
- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand All @@ -55,13 +55,13 @@ jobs:
uses: actions/checkout@v4

- name: restore cache from package-lock.json
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/github-actions-workflow.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ To further optimize dependency installation speed, we can add pnpm caching. Afte
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/github-actions-workflow.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ jobs:
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache (设置 pnpm 缓存)
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/mock-project-build.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Pass `--depth=1` to only pull the last commit. Then execute `yarn` to install de
Every time the build is successful, CI will cache the current `yarn.lock` file. In this way, if the next build fails, we can easily pull the two files for comparison to troubleshoot the problem. Although `actions/cache` does not allow cache keys with the same name, it allows `restore-keys` to get the latest cache, which is very convenient:

```yml
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~tmpProj/yarn.lock
key: primes-${{ runner.os }}-${{ github.run_id }}
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/mock-project-build.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ on:
每次构建成功,CI 都会缓存当下的 `yarn.lock` 文件。这样,我们在下次构建如果失败了,就可以很方便的拉取两份文件进行对比去排查问题。`actions/cache` 虽然不允许同名 cache key,但是允许通过 `restore-keys` 来获取最近的 cache,这就非常方便了:

```yml
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~tmpProj/yarn.lock
key: primes-${{ runner.os }}-${{ github.run_id }}
Expand Down

1 comment on commit 584593b

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.