Skip to content

Commit

Permalink
feat: optimize ci core build cache (#14988)
Browse files Browse the repository at this point in the history
* feat: optimize ci-core build cache

* fix: shell script conditionals
  • Loading branch information
erikburt authored Oct 31, 2024
1 parent 82f44ab commit 3aa8e2c
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 97 deletions.
26 changes: 23 additions & 3 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
cache-version:
description: Set this to cache bust
default: "1"
build-cache-version:
description: For scoping build caches to certain matrix jobs, takes precedence over cache-version
default: ""
go-version-file:
description: Set where the go version file is located at
default: "go.mod"
Expand Down Expand Up @@ -75,14 +78,31 @@ runs:
restore-keys: |
${{ runner.os }}-gomod-${{ inputs.cache-version }}-
- uses: actions/cache/restore@v4.1.1
name: Cache Go Build Outputs (restore)
# For certain events, we don't necessarily want to create a build cache, but we will benefit from restoring from one.
if: ${{ inputs.only-modules == 'false' && github.event == 'merge_queue' }}
with:
path: |
${{ steps.go-cache-dir.outputs.gobuildcache }}
key: ${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-${{ steps.branch-name.outputs.current_branch }}
restore-keys: |
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-develop
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-
${{ runner.os }}-gobuild-${{ inputs.cache-version }}-
- uses: actions/cache@v4.1.1
if: ${{ inputs.only-modules == 'false' }}
# don't save cache on merge queue events, only restore
if: ${{ inputs.only-modules == 'false' && github.event != 'merge_queue' }}
name: Cache Go Build Outputs
with:
path: |
${{ steps.go-cache-dir.outputs.gobuildcache }}
# The lifetime of go build outputs is pretty short, so we make our primary cache key be the branch name
key: ${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-path.output.path) }}-${{ steps.branch-name.outputs.current_branch }}
key: ${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-${{ steps.branch-name.outputs.current_branch }}
restore-keys: |
${{ runner.os }}-gobuild-${{ inputs.cache-version }}-${{ hashFiles(steps.go-module-path.output.path) }}-
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-develop
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-${{ hashFiles(steps.go-module-path.outputs.path) }}-
${{ runner.os }}-gobuild-${{ inputs.build-cache-version || inputs.cache-version }}-
${{ runner.os }}-gobuild-${{ inputs.cache-version }}-
Loading

0 comments on commit 3aa8e2c

Please sign in to comment.