Skip to content

Commit

Permalink
Add cache-version input to bazel-build-test action.
Browse files Browse the repository at this point in the history
This allows for manually invalidating prior cache results when there are incompatible changes that Bazel doesn't handle. For example, changing the C++ compiler version.

See bazelbuild/bazel#4558
  • Loading branch information
SanjayVas committed Mar 11, 2021
1 parent f3883ad commit 5ce494b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bazel-build-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ inputs:
description: Path of Bazel workspace
required: true
default: .
cache-version:
description: Version of the GitHub Actions cache key.
required: false
default: 0
build-options:
# TODO(actions/toolkit#184): Use list type rather than newline-delimited
# string once it's available.
Expand Down
3 changes: 2 additions & 1 deletion bazel-build-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ async function run() {
const treeHash = await execBash(['git rev-parse HEAD:']);
const outputBase = await execBash(['bazelisk info output_base'])

const cacheKey = `bazel-${execRootHash}-${treeHash}`;
const cacheVersion = core.getInput('cache-version');
const cacheKey = `bazel-${cacheVersion}-${execRootHash}-${treeHash}`;
const cachePaths = [outputBase];
if (getInputBool('restore-cache')) {
const restoreKeys = [`bazel-${execRootHash}-`];
Expand Down

0 comments on commit 5ce494b

Please sign in to comment.