Skip to content

Commit

Permalink
Change GH workflow tools cache key (spiffe#3871)
Browse files Browse the repository at this point in the history
Current cache key causes each job to upload to the cache with the commit
sha based key. This causes two problems:
1. Cache entries is large (one per PR) for no benefit
2. Toolchain changes are not considered when reusing the cache

This change updates the cache key for the tools cache to essentially be
keyed off of the Go version and the Makefile (which contains the versions of
tools in use)

Signed-off-by: Andrew Harding <[email protected]>
  • Loading branch information
azdagron authored Feb 16, 2023
1 parent fbaf5eb commit 4c266cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
28 changes: 7 additions & 21 deletions .github/workflows/pr_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Lint
run: make lint
- name: Tidy check
Expand Down Expand Up @@ -138,9 +136,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Build artifacts
run: ./.github/workflows/scripts/build_artifacts.sh
- name: Archive artifacts
Expand Down Expand Up @@ -173,9 +169,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Set up QEMU
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # ratchet:docker/[email protected]
- name: Set up Docker Buildx
Expand Down Expand Up @@ -255,9 +249,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Download archived images
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/[email protected]
with:
Expand Down Expand Up @@ -302,9 +294,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Install msys2
uses: msys2/setup-msys2@d40200dc2db4c351366b048a9565ad82919e1c24 # ratchet:msys2/setup-msys2@v2
with:
Expand Down Expand Up @@ -373,9 +363,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Install msys2
uses: msys2/setup-msys2@d40200dc2db4c351366b048a9565ad82919e1c24 # ratchet:msys2/setup-msys2@v2
with:
Expand Down Expand Up @@ -450,9 +438,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Install msys2
uses: msys2/setup-msys2@d40200dc2db4c351366b048a9565ad82919e1c24 # ratchet:msys2/setup-msys2@v2
with:
Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/release_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Lint
run: make lint
- name: Tidy check
Expand Down Expand Up @@ -136,9 +134,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Build artifacts
run: ./.github/workflows/scripts/build_artifacts.sh
- name: Archive artifacts
Expand Down Expand Up @@ -171,9 +167,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Build images
run: make images
- name: Export images
Expand Down Expand Up @@ -258,9 +252,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Download archived images
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/[email protected]
with:
Expand Down Expand Up @@ -307,9 +299,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Install msys2
uses: msys2/setup-msys2@d40200dc2db4c351366b048a9565ad82919e1c24 # ratchet:msys2/setup-msys2@v2
with:
Expand Down Expand Up @@ -378,9 +368,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Install msys2
uses: msys2/setup-msys2@d40200dc2db4c351366b048a9565ad82919e1c24 # ratchet:msys2/setup-msys2@v2
with:
Expand Down Expand Up @@ -455,9 +443,7 @@ jobs:
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # ratchet:actions/[email protected]
with:
path: .build
key: ${{ runner.os }}-tools-${{ github.sha }}
restore-keys: |
${{ runner.os }}-tools-
key: ${{ runner.os }}-tools-${{ hashFiles('.go-version','Makefile') }}
- name: Install msys2
uses: msys2/setup-msys2@d40200dc2db4c351366b048a9565ad82919e1c24 # ratchet:msys2/setup-msys2@v2
with:
Expand Down

0 comments on commit 4c266cc

Please sign in to comment.