Allow changing output base path

This commit is contained in:
Alex Rodionov 2024-10-31 07:12:35 -07:00
parent 89b8ef0f1d
commit 0f9296f333
7 changed files with 61 additions and 14 deletions

View file

@ -173,6 +173,28 @@ Default `""`.
```
</details>
### `output-base`
Change Bazel output base directory.
You might want to change it when running on self-hosted runners with a custom directory layout.
Default is one of the following:
- `$HOME/.bazel` on Linux and macOS
- `D:/_bazel` on Windows
<details>
<summary>Examples</summary>
#### Use `C` drive letter
```yaml
- uses: bazel-contrib/setup-bazel@0.9.1
with:
output-base: C:/_bazel
```
</details>
### `repository-cache`

View file

@ -29,6 +29,10 @@ inputs:
description: Google Cloud account key for remote cache
required: false
default: ""
output-base:
description: Bazel output base directory. Default is $HOME/.cache/bazel (POSIX) or D:/_bazel (Windows)
required: false
default: ""
repository-cache:
description: Cache repositories based on MODULE.bazel/WORKSPACE
required: false

View file

@ -12,9 +12,17 @@ const homeDir = os.homedir()
const arch = os.arch()
const platform = os.platform()
let bazelOutputBase = core.getInput('output-base')
if (!bazelOutputBase) {
if (platform === 'win32') {
bazelOutputBase = 'D:/_bazel'
} else {
bazelOutputBase = `${homeDir}/.bazel`
}
}
let bazelDisk = core.toPosixPath(`${homeDir}/.cache/bazel-disk`)
let bazelRepository = core.toPosixPath(`${homeDir}/.cache/bazel-repo`)
let bazelOutputBase = `${homeDir}/.bazel`
let bazelrcPaths = [core.toPosixPath(`${homeDir}/.bazelrc`)]
let userCacheDir = `${homeDir}/.cache`
@ -23,9 +31,8 @@ switch (platform) {
userCacheDir = `${homeDir}/Library/Caches`
break
case 'win32':
bazelDisk = 'D:/_bazel-disk'
bazelRepository = 'D:/_bazel-repo'
bazelOutputBase = 'D:/_bazel'
bazelDisk = `${bazelOutputBase}-disk`
bazelRepository = `${bazelOutputBase}-repo`
userCacheDir = `${homeDir}/AppData/Local`
if (process.env.HOME) {
bazelrcPaths.push(core.toPosixPath(`${process.env.HOME}/.bazelrc`))

15
dist/main/index.js vendored
View file

@ -18,9 +18,17 @@ const homeDir = os.homedir()
const arch = os.arch()
const platform = os.platform()
let bazelOutputBase = core.getInput('output-base')
if (!bazelOutputBase) {
if (platform === 'win32') {
bazelOutputBase = 'D:/_bazel'
} else {
bazelOutputBase = `${homeDir}/.bazel`
}
}
let bazelDisk = core.toPosixPath(`${homeDir}/.cache/bazel-disk`)
let bazelRepository = core.toPosixPath(`${homeDir}/.cache/bazel-repo`)
let bazelOutputBase = `${homeDir}/.bazel`
let bazelrcPaths = [core.toPosixPath(`${homeDir}/.bazelrc`)]
let userCacheDir = `${homeDir}/.cache`
@ -29,9 +37,8 @@ switch (platform) {
userCacheDir = `${homeDir}/Library/Caches`
break
case 'win32':
bazelDisk = 'D:/_bazel-disk'
bazelRepository = 'D:/_bazel-repo'
bazelOutputBase = 'D:/_bazel'
bazelDisk = `${bazelOutputBase}-disk`
bazelRepository = `${bazelOutputBase}-repo`
userCacheDir = `${homeDir}/AppData/Local`
if (process.env.HOME) {
bazelrcPaths.push(core.toPosixPath(`${process.env.HOME}/.bazelrc`))

File diff suppressed because one or more lines are too long

15
dist/post/index.js vendored
View file

@ -18,9 +18,17 @@ const homeDir = os.homedir()
const arch = os.arch()
const platform = os.platform()
let bazelOutputBase = core.getInput('output-base')
if (!bazelOutputBase) {
if (platform === 'win32') {
bazelOutputBase = 'D:/_bazel'
} else {
bazelOutputBase = `${homeDir}/.bazel`
}
}
let bazelDisk = core.toPosixPath(`${homeDir}/.cache/bazel-disk`)
let bazelRepository = core.toPosixPath(`${homeDir}/.cache/bazel-repo`)
let bazelOutputBase = `${homeDir}/.bazel`
let bazelrcPaths = [core.toPosixPath(`${homeDir}/.bazelrc`)]
let userCacheDir = `${homeDir}/.cache`
@ -29,9 +37,8 @@ switch (platform) {
userCacheDir = `${homeDir}/Library/Caches`
break
case 'win32':
bazelDisk = 'D:/_bazel-disk'
bazelRepository = 'D:/_bazel-repo'
bazelOutputBase = 'D:/_bazel'
bazelDisk = `${bazelOutputBase}-disk`
bazelRepository = `${bazelOutputBase}-repo`
userCacheDir = `${homeDir}/AppData/Local`
if (process.env.HOME) {
bazelrcPaths.push(core.toPosixPath(`${process.env.HOME}/.bazelrc`))

File diff suppressed because one or more lines are too long