chore: Clean up cache usage in workflows (#6444)
* chore: Use same cache as bats tests * chore: Clarify cache miss check * chore: Remove use of setup-go cache * chore: Use separate caches * CR
This commit is contained in:
1 parent
c1eae29f24
commit
9c0ea988f5
9 files changed
+184
-126
No files matched your search
@@ -22,10 +22,8 @@ on:
|
||||
jobs:
|
||||
setup:
|
||||
outputs:
|
||||
cache-go-build: ${{ steps.go-cache-paths.outputs.go-build }}
|
||||
cache-go-mod: ${{ steps.go-cache-paths.outputs.go-mod }}
|
||||
cache-go-bin: ${{ steps.go-cache-paths.outputs.go-bin }}
|
||||
go-cache-key: ${{ steps.go-cache-key.outputs.key }}
|
||||
go-mod-cache-key: ${{ steps.go-mod-cache-key.outputs.key }}
|
||||
runs-on: ${{ fromJSON(vars.RUNNER) }}
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
@@ -36,30 +34,25 @@ jobs:
|
||||
with:
|
||||
go-version: ${{ inputs.go-version }}
|
||||
cache: false
|
||||
- name: Determine go cache key
|
||||
id: go-cache-key
|
||||
run: |
|
||||
echo "key=${{ runner.os }}-go-${{ hashFiles('**/go.sum', './Makefile', './tools/tools.go') }}" >> "$GITHUB_OUTPUT"
|
||||
- name: Determine Go cache paths
|
||||
id: go-cache-paths
|
||||
run: |
|
||||
echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
|
||||
echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
|
||||
echo "go-bin=$(go env GOPATH)/bin" >> "$GITHUB_OUTPUT"
|
||||
- name: Determine Go modules cache key
|
||||
id: go-mod-cache-key
|
||||
run: |
|
||||
echo "key=go-mod-${{ hashFiles('**/go.sum') }}" >> "$GITHUB_OUTPUT"
|
||||
- name: Set up Go modules cache
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
with:
|
||||
path: |
|
||||
${{ steps.go-cache-paths.outputs.go-build }}
|
||||
${{ steps.go-cache-paths.outputs.go-mod }}
|
||||
${{ steps.go-cache-paths.outputs.go-bin }}
|
||||
key: ${{ steps.go-cache-key.outputs.key }}
|
||||
key: ${{ steps.go-mod-cache-key.outputs.key }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go
|
||||
- name: Install Tools
|
||||
go-mod
|
||||
- name: Download Go modules
|
||||
run: |
|
||||
go mod download
|
||||
make tools
|
||||
enos:
|
||||
name: test
|
||||
needs:
|
||||
@@ -114,13 +107,10 @@ jobs:
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
with:
|
||||
path: |
|
||||
${{ needs.setup.outputs.cache-go-build }}
|
||||
${{ needs.setup.outputs.cache-go-mod }}
|
||||
${{ needs.setup.outputs.cache-go-bin }}
|
||||
key: ${{ needs.setup.outputs.go-cache-key }}
|
||||
key: ${{ needs.setup.outputs.go-mod-cache-key }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go
|
||||
fail-on-cache-miss: false
|
||||
go-mod
|
||||
- name: Downloads Go modules if cache miss
|
||||
if: steps.go-mod-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
@@ -179,11 +169,21 @@ jobs:
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
with:
|
||||
path: /tmp/test-deps
|
||||
key: enos-test-deps-password-store-1.7.4-vault-1.12.2
|
||||
key: enos-bats-cli-ui-deps-jq-1.6-password-store-1.7.4-vault-1.12.2
|
||||
- name: Debug dep-cache
|
||||
run: |
|
||||
mkdir -p /tmp/test-deps
|
||||
ls -la /tmp/test-deps
|
||||
- name: Download jq
|
||||
if: steps.dep-cache.outputs.cache-hit != 'true'
|
||||
# NOTE: if you update the jq version make sure to update the dep cache key
|
||||
run: |
|
||||
mkdir -p /tmp/test-deps
|
||||
wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O /tmp/test-deps/jq-bin
|
||||
- name: Install jq
|
||||
run: |
|
||||
chmod +x /tmp/test-deps/jq-bin
|
||||
sudo cp /tmp/test-deps/jq-bin /usr/local/bin/jq
|
||||
- name: Download and unzip pass for Boundary keyring
|
||||
if: steps.dep-cache.outputs.cache-hit != 'true'
|
||||
# NOTE: if you update the password store version make sure to update the dep cache key
|
||||
|
||||
Reference in new issue
Block a user