Skip to content

Commit 99467b8

Browse files
committed
fix(github-actions): fix --repository_cachein Windows WSL
`C:/` should be replaced with `/mnt/c`. This is because Bazel is executed in WSL in Windows.
1 parent 007a768 commit 99467b8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

github-actions/bazel/setup/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ runs:
1818
path: |
1919
~/.cache/bazelisk
2020
~/AppData/Local/bazelisk
21-
key: bazel-version-${{ hashFiles('**/.bazelversion') }}
21+
key: bazel-version-v2-${{ hashFiles('**/.bazelversion') }}
2222

2323
- name: Setup CI bazelrc config
2424
run: node $GITHUB_ACTION_PATH/setup-ci-bazelrc.mjs
@@ -32,6 +32,6 @@ runs:
3232
# Note: Bazel repository cache is located in system locations and cannot use
3333
# a shared cache between different runner operating systems.
3434
path: '~/.cache/bazel_repo_cache'
35-
key: bazel-cache-${{ runner.os }}-${{ hashFiles('**/WORKSPACE') }}-${{ hashFiles('**/MODULE.bazel') }}
35+
key: bazel-cache-${{ runner.os }}-v2-${{ hashFiles('**/WORKSPACE') }}-${{ hashFiles('**/MODULE.bazel') }}
3636
restore-keys: |
37-
bazel-cache-${{ runner.os }}-
37+
bazel-cache-${{ runner.os }}-v2-

github-actions/bazel/setup/setup-ci-bazelrc.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import fs from 'fs';
77
// in the bazelrc file need to be escaled as otherwise those would escape
88
// followed characters that weren't supposed to be escaped.
99
const cachePath = path.join(os.homedir(), '.cache/bazel_repo_cache');
10-
const escapedCachePath = cachePath.replace(/\\/g, '\\\\');
10+
const escapedCachePath = cachePath.replace(/\\/g, '/');
1111

1212
const bazelRcContent = `
1313
# Print all the options that apply to the build.
@@ -16,7 +16,8 @@ const bazelRcContent = `
1616
build --announce_rc
1717
1818
# Avoids re-downloading NodeJS/browsers all the time.
19-
build --repository_cache=${escapedCachePath}
19+
# Replace path to make it compatable with WSL
20+
build --repository_cache=${escapedCachePath.replace(/c:\//i, '/mnt/c/')}
2021
2122
# More details on failures
2223
build --verbose_failures=true

0 commit comments

Comments
 (0)