8000 Add module-root option for changing module location within the reposi… · bazel-contrib/setup-bazel@e0e802d · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit e0e802d

Browse files
Add module-root option for changing module location within the repository (#69)
1 parent 9824807 commit e0e802d

File tree

7 files changed

+82
-5809
lines changed

7 files changed

+82
-5809
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ Default `""`.
173173
```
174174
</details>
175175

176+
### `module-root`
177+
178+
Bazel module root directory, where `MODULE.bazel` and `WORKSPACE` is found.
179+
180+
Change this value to the module root if it's not the repository root.
181+
182+
Default `"."`.
183+
176184
### `output-base`
177185

178186
Change Bazel output base directory.

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ inputs:
2929
description: Google Cloud account key for remote cache
3030
required: false
3131
default: ""
32+
module-root:
33+
description: Bazel module root directory. Default is `.`
34+
required: false
35+
default: "."
3236
output-base:
3337
description: Bazel output base directory. Default is $HOME/.cache/bazel (POSIX) or D:/_bazel (Windows)
3438
required: false

config.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const github = require('@actions/github')
77
const bazeliskVersion = core.getInput('bazelisk-version')
88
const cacheVersion = core.getInput('cache-version')
99
const externalCacheConfig = yaml.parse(core.getInput('external-cache'))
10+
const moduleRoot = core.getInput('module-root')
1011

1112
const homeDir = os.homedir()
1213
const arch = os.arch()
@@ -56,10 +57,10 @@ if (diskCacheEnabled) {
5657
const repositoryCacheConfig = core.getInput('repository-cache')
5758
const repositoryCacheEnabled = repositoryCacheConfig !== 'false'
5859
let repositoryCacheFiles = [
59-
'MODULE.bazel',
60-
'WORKSPACE.bazel',
61-
'WORKSPACE.bzlmod',
62-
'WORKSPACE'
60+
`${moduleRoot}/MODULE.bazel`,
61+
`${moduleRoot}/WORKSPACE.bazel`,
62+
`${moduleRoot}/WORKSPACE.bzlmod`,
63+
`${moduleRoot}/WORKSPACE`
6364
]
6465
if (repositoryCacheEnabled) {
6566
bazelrc.push(`common --repository_cache=${bazelRepository}`)
@@ -90,21 +91,21 @@ if (externalCacheConfig) {
9091
externalCache.baseCacheKey = `${baseCacheKey}-external-`
9192
externalCache.manifest = {
9293
files: [
93-
'MODULE.bazel',
94-
'WORKSPACE.bazel',
95-
'WORKSPACE.bzlmod',
96-
'WORKSPACE'
94+
`${moduleRoot}/MODULE.bazel`,
95+
`${moduleRoot}/WORKSPACE.bazel`,
96+
`${moduleRoot}/WORKSPACE.bzlmod`,
97+
`${moduleRoot}/WORKSPACE`
9798
],
9899
name: `external-${manifestName}-manifest`,
99100
path: `${os.tmpdir()}/external-cache-manifest.txt`
100101
}
101102
externalCache.default = {
102103
enabled: true,
103104
files: [
104-
'MODULE.bazel',
105-
'WORKSPACE.bazel',
106-
'WORKSPACE.bzlmod',
107-
'WORKSPACE'
105+
`${moduleRoot}/MODULE.bazel`,
106+
`${moduleRoot}/WORKSPACE.bazel`,
107+
`${moduleRoot}/WORKSPACE.bzlmod`,
108+
`${moduleRoot}/WORKSPACE`
108109
],
109110
name: (name) => { return `external-${name}` },
110111
paths: (name) => {
@@ -130,7 +131,7 @@ module.exports = {
130131
baseCacheKey,
131132
bazeliskCache: {
132133
enabled: core.getBooleanInput('bazelisk-cache'),
133-
files: ['.bazelversion'],
134+
files: [`${moduleRoot}/.bazelversion`],
134135
name: 'bazelisk',
135136
paths: [core.toPosixPath(`${userCacheDir}/bazelisk`)]
136137
},
@@ -140,8 +141,8 @@ module.exports = {
140141
enabled: diskCacheEnabled,
141142
files: [
142143
...repositoryCacheFiles,
143-
'**/BUILD.bazel',
144-
'**/BUILD'
144+
`${moduleRoot}/**/BUILD.bazel`,
145+
`${moduleRoot}/**/BUILD`
145146
],
146147
name: diskCacheName,
147148
paths: [bazelDisk]

0 commit comments

Comments
 (0)
0