Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing output base path #48

Merged
merged 1 commit into from
Dec 21, 2024
Merged
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
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.