Skip to content

Commit

Permalink
Allow changing output base path
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Dec 21, 2024
1 parent 89b8ef0 commit 0f9296f
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 14 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
output-base: C:/_bazel
```
</details>

### `repository-cache`

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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`))
Expand Down
15 changes: 11 additions & 4 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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`))
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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`))
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

0 comments on commit 0f9296f

Please sign in to comment.