From 3f6bfb33d05293b70338ba4602f34ca54734dcb2 Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Tue, 18 Feb 2025 16:26:58 -0800 Subject: [PATCH] Add disk-cache-files input to support multiple modules Fixes #67 Add support for overriding disk cache files for multiple modules in the repository. * Add a new input `disk-cache-files` in `action.yml` to specify custom disk cache files. * Update `config.js` to handle the new `disk-cache-files` input and override the `diskCache.files` array if provided. * Update the documentation in `README.md` to include the new `disk-cache-files` input and provide examples of its usage. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/bazel-contrib/setup-bazel/issues/67?shareId=XXXX-XXXX-XXXX-XXXX). --- README.md | 21 +++++++++++++++++++++ action.yml | 4 ++++ config.js | 12 ++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b8a21d2..d8f0bfa 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,27 @@ Default `false`. ``` +### `disk-cache-files` + +Specify custom disk cache files. + +Default `""`. + +
+ Examples + + #### Override disk cache files + + ```yaml + - uses: bazel-contrib/setup-bazel@0.13.0 + with: + disk-cache-files: | + **/BUILD.bazel + **/BUILD + custom/path/BUILD + ``` +
+ ### `external-cache` Cache `external/` repositories based on contents of `MODULE.bazel` and `WORKSPACE` files. diff --git a/action.yml b/action.yml index 0f33e5e..4ab7a5d 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,10 @@ inputs: description: Cache actions outputs based on BUILD required: false default: "false" + disk-cache-files: + description: Custom disk cache files + required: false + default: "" external-cache: description: Cache external 10MB+ repositories based on MODULE.bazel/WORKSPACE required: false diff --git a/config.js b/config.js index 2a180b5..4af4193 100644 --- a/config.js +++ b/config.js @@ -53,6 +53,15 @@ if (diskCacheEnabled) { } } +const diskCacheFilesConfig = core.getMultilineInput('disk-cache-files') +let diskCacheFiles = [ + '**/BUILD.bazel', + '**/BUILD' +] +if (diskCacheFilesConfig.length > 0) { + diskCacheFiles = diskCacheFilesConfig +} + const repositoryCacheConfig = core.getInput('repository-cache') const repositoryCacheEnabled = repositoryCacheConfig !== 'false' let repositoryCacheFiles = [ @@ -140,8 +149,7 @@ module.exports = { enabled: diskCacheEnabled, files: [ ...repositoryCacheFiles, - '**/BUILD.bazel', - '**/BUILD' + ...diskCacheFiles ], name: diskCacheName, paths: [bazelDisk]