Skip to content

Commit

Permalink
Support passing files to hash in repository-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Mar 5, 2024
1 parent 527d41d commit 5058960
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 23 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,30 @@ Default `""`.

Enable [`repository_cache`][3] and store it on GitHub based on contents of `MODULE.bazel` and `WORKSPACE` files.

You can also pass a file (or list of files) which contents are used to calculate cache key.

Default `false`.

<details>
<summary>Examples</summary>

#### Store a single repository cache

```yaml
- uses: p0deje/[email protected]
with:
repository-cache: true
```

#### Store a repository cache from a custom location

```yaml
- uses: p0deje/[email protected]
with:
repository-cache: examples/gem/WORKSPACE
```
</details>

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

You can simply replace `bazelbuild/setup-bazelisk` action with `p0deje/setup-bazel`.
Expand Down
19 changes: 12 additions & 7 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,19 @@ if (diskCacheEnabled) {
}
}

const repositoryCacheEnabled = core.getBooleanInput('repository-cache')
const repositoryCacheConfig = core.getInput('repository-cache')
const repositoryCacheEnabled = repositoryCacheConfig !== 'false'
let repositoryCacheFiles = [
'MODULE.bazel',
'WORKSPACE.bazel',
'WORKSPACE.bzlmod',
'WORKSPACE'
]
if (repositoryCacheEnabled) {
bazelrc.push(`build --repository_cache=${bazelRepository}`)
if (repositoryCacheConfig !== 'true') {
repositoryCacheFiles = Array(repositoryCacheConfig).flat()
}
}

const googleCredentials = core.getInput('google-credentials')
Expand Down Expand Up @@ -137,12 +147,7 @@ module.exports = {
},
repositoryCache: {
enabled: repositoryCacheEnabled,
files: [
'MODULE.bazel',
'WORKSPACE.bazel',
'WORKSPACE.bzlmod',
'WORKSPACE'
],
files: repositoryCacheFiles,
name: 'repository',
paths: [bazelRepository]
},
Expand Down
19 changes: 12 additions & 7 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,19 @@ if (diskCacheEnabled) {
}
}

const repositoryCacheEnabled = core.getBooleanInput('repository-cache')
const repositoryCacheConfig = core.getInput('repository-cache')
const repositoryCacheEnabled = repositoryCacheConfig !== 'false'
let repositoryCacheFiles = [
'MODULE.bazel',
'WORKSPACE.bazel',
'WORKSPACE.bzlmod',
'WORKSPACE'
]
if (repositoryCacheEnabled) {
bazelrc.push(`build --repository_cache=${bazelRepository}`)
if (repositoryCacheConfig !== 'true') {
repositoryCacheFiles = Array(repositoryCacheConfig).flat()
}
}

const googleCredentials = core.getInput('google-credentials')
Expand Down Expand Up @@ -143,12 +153,7 @@ module.exports = {
},
repositoryCache: {
enabled: repositoryCacheEnabled,
files: [
'MODULE.bazel',
'WORKSPACE.bazel',
'WORKSPACE.bzlmod',
'WORKSPACE'
],
files: repositoryCacheFiles,
name: 'repository',
paths: [bazelRepository]
},
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,19 @@ if (diskCacheEnabled) {
}
}

const repositoryCacheEnabled = core.getBooleanInput('repository-cache')
const repositoryCacheConfig = core.getInput('repository-cache')
const repositoryCacheEnabled = repositoryCacheConfig !== 'false'
let repositoryCacheFiles = [
'MODULE.bazel',
'WORKSPACE.bazel',
'WORKSPACE.bzlmod',
'WORKSPACE'
]
if (repositoryCacheEnabled) {
bazelrc.push(`build --repository_cache=${bazelRepository}`)
if (repositoryCacheConfig !== 'true') {
repositoryCacheFiles = Array(repositoryCacheConfig).flat()
}
}

const googleCredentials = core.getInput('google-credentials')
Expand Down Expand Up @@ -143,12 +153,7 @@ module.exports = {
},
repositoryCache: {
enabled: repositoryCacheEnabled,
files: [
'MODULE.bazel',
'WORKSPACE.bazel',
'WORKSPACE.bzlmod',
'WORKSPACE'
],
files: repositoryCacheFiles,
name: 'repository',
paths: [bazelRepository]
},
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

0 comments on commit 5058960

Please sign in to comment.