From 43beb8e53671e5bf064903d42945d97efc45528a Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Tue, 28 Jan 2025 11:04:53 -0500 Subject: [PATCH] Bump all actions/cache to v4 (#54137) --- .github/actions/cache-nextjs/action.yml | 2 +- .github/actions/node-npm-setup/action.yml | 2 +- .github/actions/precompute-pageinfo/action.yml | 5 ++--- .github/actions/setup-elasticsearch/action.yml | 2 +- .github/actions/warmup-remotejson-cache/action.yml | 5 ++--- .github/workflows/link-check-daily.yml | 2 +- src/workflows/tests/actions-workflows.ts | 6 +++++- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/actions/cache-nextjs/action.yml b/.github/actions/cache-nextjs/action.yml index 84146741c8..c0251afbaf 100644 --- a/.github/actions/cache-nextjs/action.yml +++ b/.github/actions/cache-nextjs/action.yml @@ -8,7 +8,7 @@ runs: using: 'composite' steps: - name: Cache .next/cache - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + uses: actions/cache@v4 with: path: ${{ github.workspace }}/.next/cache # Generate a new cache whenever packages or source files change. diff --git a/.github/actions/node-npm-setup/action.yml b/.github/actions/node-npm-setup/action.yml index f1f845d4da..fcc88e3d40 100644 --- a/.github/actions/node-npm-setup/action.yml +++ b/.github/actions/node-npm-setup/action.yml @@ -6,7 +6,7 @@ runs: using: 'composite' steps: - name: Cache node_modules - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + uses: actions/cache@v4 id: cache-node_modules env: # Default is 10 min, per segment, but we can make it much smaller diff --git a/.github/actions/precompute-pageinfo/action.yml b/.github/actions/precompute-pageinfo/action.yml index 1886f93c05..4b9923417a 100644 --- a/.github/actions/precompute-pageinfo/action.yml +++ b/.github/actions/precompute-pageinfo/action.yml @@ -17,8 +17,7 @@ runs: # Optionally, you can have it just do A (and not B and C). - name: Cache .pageinfo-cache.json.br (restore) - # You can't use a SHA on these. Only possible with `actions/cache@SHA...` - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: .pageinfo-cache.json.br key: pageinfo-cache- @@ -40,7 +39,7 @@ runs: - name: Cache .remotejson-cache (save) if: ${{ inputs.restore-only == '' }} - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: .pageinfo-cache.json.br key: pageinfo-cache-${{ github.sha }} diff --git a/.github/actions/setup-elasticsearch/action.yml b/.github/actions/setup-elasticsearch/action.yml index 667e1fe615..60d3fb0721 100644 --- a/.github/actions/setup-elasticsearch/action.yml +++ b/.github/actions/setup-elasticsearch/action.yml @@ -19,7 +19,7 @@ runs: # Cache the elasticsearch image to prevent Docker Hub rate limiting - name: Cache Docker layers id: cache-docker-layers - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /tmp/docker-cache key: ${{ runner.os }}-elasticsearch-${{ inputs.elasticsearch_version }} diff --git a/.github/actions/warmup-remotejson-cache/action.yml b/.github/actions/warmup-remotejson-cache/action.yml index 5686fb2a0c..8d8d9a5e43 100644 --- a/.github/actions/warmup-remotejson-cache/action.yml +++ b/.github/actions/warmup-remotejson-cache/action.yml @@ -14,8 +14,7 @@ runs: # You "wrap" the step that appends to disk and it will possibly retrieve # some from the cache, then save it when it's got more in it. - name: Cache .remotejson-cache (restore) - # You can't use a SHA on these. Only possible with `actions/cache@SHA...` - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: .remotejson-cache key: remotejson-cache- @@ -37,7 +36,7 @@ runs: - name: Cache .remotejson-cache (save) if: ${{ inputs.restore-only == '' }} - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: .remotejson-cache key: remotejson-cache-${{ github.sha }} diff --git a/.github/workflows/link-check-daily.yml b/.github/workflows/link-check-daily.yml index 818cca1cad..25ec2ff6b7 100644 --- a/.github/workflows/link-check-daily.yml +++ b/.github/workflows/link-check-daily.yml @@ -49,7 +49,7 @@ jobs: run: src/early-access/scripts/merge-early-access.sh - name: Restore disk-cache file for external link checking - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + uses: actions/cache@v4 with: path: external-link-checker-db.json key: external-link-checker-${{ hashFiles('src/links/scripts/rendered-content-link-checker.ts') }} diff --git a/src/workflows/tests/actions-workflows.ts b/src/workflows/tests/actions-workflows.ts index df1461e96f..ed30456c6d 100644 --- a/src/workflows/tests/actions-workflows.ts +++ b/src/workflows/tests/actions-workflows.ts @@ -7,6 +7,8 @@ import yaml from 'js-yaml' import { flatten } from 'flat' import { chain, get } from 'lodash-es' +const githubOwnedActionsRegex = + /^(actions\/(cache|checkout|download-artifact|upload-artifact)@v\d+(\.\d+)*)$/ const actionHashRegexp = /^[A-Za-z0-9-/]+@[0-9a-f]{40}$/ const checkoutRegexp = /^[actions/checkout]+@[0-9a-f]{40}$/ const permissionsRegexp = /(read|write)/ @@ -71,7 +73,9 @@ const dailyWorkflows = scheduledWorkflows.filter(({ data }) => describe('GitHub Actions workflows', () => { test.each(allUsedActions)('requires specific hash: %p', (actionName) => { - expect(actionName).toMatch(actionHashRegexp) + const matchesGitHubOwnedActions = githubOwnedActionsRegex.test(actionName) + const matchesActionHash = actionHashRegexp.test(actionName) + expect(matchesGitHubOwnedActions || matchesActionHash).toBe(true) }) test.each(scheduledWorkflows)(