-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize ci core build cache (#14988)
* feat: optimize ci-core build cache * fix: shell script conditionals
- Loading branch information
Showing
7 changed files
with
226 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -75,14 +78,31 @@ runs: | |
restore-keys: | | ||
${{ runner.os }}-gomod-${{ inputs.cache-version }}- | ||
- uses: actions/cache/[email protected] | ||
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/[email protected] | ||
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 }}- |
Oops, something went wrong.