Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,32 @@ Default `false`.
```
</details>

### `repo-contents-cache`

Bazel 8+ keeps a [repo contents cache][11] (the *extracted* external repository
directories) under `${repository_cache}/contents`. Persisting it can save
re-extraction and repo-rule evaluation across runs, so it is included in the
saved repository cache by default, but its primary benefit (sharing extracted
repos across workspaces on one machine) doesn't apply to a CI runner.

Set this to `false` to exclude that directory from the saved cache.
Has no effect unless`repository-cache` is enabled.

Default `true`.

<details>
<summary>Examples</summary>

#### Exclude the repo contents cache from the saved cache

```yaml
- uses: bazel-contrib/setup-bazel@0.19.0
with:
repository-cache: true
repo-contents-cache: false
```
</details>

## Migrating from [`bazelbuild/setup-bazelisk`][6]

You can simply replace `bazelbuild/setup-bazelisk` action with `bazel-contrib/setup-bazel`.
Expand Down Expand Up @@ -295,3 +321,4 @@ Use [Release][10] workflow to cut a new release.
[8]: https://github.com/actions/runner-images/pull/490
[9]: https://bazel.build/reference/command-line-reference#flag--google_credentials
[10]: https://github.com/bazel-contrib/setup-bazel/actions/workflows/release.yml
[11]: https://bazel.build/reference/command-line-reference#flag--repo_contents_cache
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ inputs:
description: Cache repositories based on MODULE.bazel/WORKSPACE
required: false
default: "false"
repo-contents-cache:
description: Persist the Bazel repo contents cache. Has no effect unless repository-cache is enabled.
required: false
default: "true"
cache-restore-timeout:
description: Timeout in milliseconds for each cache restore operation (download + extraction). Set to 0 to disable.
required: false
Expand Down
7 changes: 6 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ if (diskCacheEnabled) {

const repositoryCacheConfig = yaml.parse(core.getInput('repository-cache'))
const repositoryCacheEnabled = repositoryCacheConfig !== false
const repoContentsCacheEnabled = core.getBooleanInput('repo-contents-cache')
let repositoryCacheFiles = [
`${moduleRoot}/MODULE.bazel`,
`${moduleRoot}/WORKSPACE.bazel`,
Expand All @@ -77,6 +78,10 @@ if (repositoryCacheEnabled) {
}
}

let repositoryCachePaths = repoContentsCacheEnabled
? [bazelRepository]
: [`${bazelRepository}/content_addressable`]

const googleCredentials = core.getInput('google-credentials')
const googleCredentialsSaved = (core.getState('google-credentials-path').length > 0)
if (googleCredentials.length > 0 && !googleCredentialsSaved) {
Expand Down Expand Up @@ -174,6 +179,6 @@ export default {
enabled: repositoryCacheEnabled,
files: repositoryCacheFiles,
name: 'repository',
paths: [bazelRepository]
paths: repositoryCachePaths
},
}
Loading
Loading