From 5ce494be6aa807b7f01ce802f9d45c1532ee1f4c Mon Sep 17 00:00:00 2001 From: "sanjayvas@google.com" Date: Thu, 11 Mar 2021 12:33:06 -0800 Subject: [PATCH] Add cache-version input to bazel-build-test action. 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 https://github.com/bazelbuild/bazel/issues/4558 --- bazel-build-test/action.yml | 4 ++++ bazel-build-test/index.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bazel-build-test/action.yml b/bazel-build-test/action.yml index b102a04..9223d56 100644 --- a/bazel-build-test/action.yml +++ b/bazel-build-test/action.yml @@ -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. diff --git a/bazel-build-test/index.js b/bazel-build-test/index.js index 2df0f51..b50275d 100644 --- a/bazel-build-test/index.js +++ b/bazel-build-test/index.js @@ -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}-`];