allow a list of files for repositoryCacheConfig (#117)

---------
Co-authored-by: Karthik Sethuraman <ksethuraman@linkedin.com>
This commit is contained in:
Karthik Sethuraman 2025-12-16 08:02:30 -08:00 committed by GitHub
parent 5528b8082a
commit 905421c656
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 98534 additions and 98923 deletions

View file

@ -230,6 +230,15 @@ Default `false`.
with: with:
repository-cache: examples/gem/WORKSPACE repository-cache: examples/gem/WORKSPACE
``` ```
#### Store a repository cache from a list of custom locations
```yaml
- uses: bazel-contrib/setup-bazel@0.15.0
with:
repository-cache: |
- MODULE.bazel
- requirements_locked.txt
```
</details> </details>
## Migrating from [`bazelbuild/setup-bazelisk`][6] ## Migrating from [`bazelbuild/setup-bazelisk`][6]

View file

@ -6,7 +6,6 @@ const github = require('@actions/github')
const bazeliskVersion = core.getInput('bazelisk-version') const bazeliskVersion = core.getInput('bazelisk-version')
const cacheVersion = core.getInput('cache-version') const cacheVersion = core.getInput('cache-version')
const externalCacheConfig = yaml.parse(core.getInput('external-cache'))
const moduleRoot = core.getInput('module-root') const moduleRoot = core.getInput('module-root')
const homeDir = os.homedir() const homeDir = os.homedir()
@ -59,8 +58,8 @@ if (diskCacheEnabled) {
} }
} }
const repositoryCacheConfig = core.getInput('repository-cache') const repositoryCacheConfig = yaml.parse(core.getInput('repository-cache'))
const repositoryCacheEnabled = repositoryCacheConfig !== 'false' const repositoryCacheEnabled = repositoryCacheConfig !== false
let repositoryCacheFiles = [ let repositoryCacheFiles = [
`${moduleRoot}/MODULE.bazel`, `${moduleRoot}/MODULE.bazel`,
`${moduleRoot}/WORKSPACE.bazel`, `${moduleRoot}/WORKSPACE.bazel`,
@ -69,7 +68,7 @@ let repositoryCacheFiles = [
] ]
if (repositoryCacheEnabled) { if (repositoryCacheEnabled) {
bazelrc.push(`common --repository_cache=${bazelRepository}`) bazelrc.push(`common --repository_cache=${bazelRepository}`)
if (repositoryCacheConfig !== 'true') { if (repositoryCacheConfig !== true) {
repositoryCacheFiles = Array(repositoryCacheConfig).flat() repositoryCacheFiles = Array(repositoryCacheConfig).flat()
} }
} }
@ -84,6 +83,7 @@ if (googleCredentials.length > 0 && !googleCredentialsSaved) {
core.saveState('google-credentials-path', googleCredentialsPath) core.saveState('google-credentials-path', googleCredentialsPath)
} }
const externalCacheConfig = yaml.parse(core.getInput('external-cache'))
const bazelExternal = core.toPosixPath(`${bazelOutputBase}/external`) const bazelExternal = core.toPosixPath(`${bazelOutputBase}/external`)
const externalCache = {} const externalCache = {}
if (externalCacheConfig) { if (externalCacheConfig) {

99114
dist/main/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

97950
dist/post/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long