Skip to content

Commit a8a189a

Browse files
committed
ci: refactor self-hosted bazel setup into composite action
Refactors the repeated setup-bazel steps in ci.yml into a local composite action (.github/actions/setup-bazel-self-hosted). This ensures a consistent configuration across all CI jobs, including: - Disabling GitHub-backed caching to avoid redundancy and conflicts. - Setting a unique output base per runner (${{ runner.workspace }}/.bazel) to avoid server trashing. - Configuring local persistent cache paths in the runner's home directory. Future updates to the self-hosted Bazel configuration can now be managed in a single place. Signed-off-by: Miguel Osorio <miguelosorio@google.com>
1 parent a327e2a commit a8a189a

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Licensed under the Apache-2.0 license
2+
3+
name: 'Setup Bazel (Self-Hosted)'
4+
description: 'Configure Bazel for self-hosted runners with local persistent caching'
5+
runs:
6+
using: "composite"
7+
steps:
8+
- name: Setup Bazel
9+
uses: bazel-contrib/setup-bazel@0.19.0
10+
with:
11+
bazelisk-cache: false
12+
disk-cache: false
13+
repository-cache: false
14+
output-base: ${{ runner.workspace }}/.bazel
15+
bazelrc: |
16+
build --disk_cache=/home/github-runner/.cache/bazel-disk
17+
common --repository_cache=/home/github-runner/.cache/bazel-repo

.github/workflows/ci.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ jobs:
2020
- uses: actions/checkout@v6
2121

2222
- name: Setup Bazel
23-
uses: bazel-contrib/setup-bazel@0.19.0
24-
with:
25-
bazelisk-cache: false
26-
disk-cache: false
27-
repository-cache: false
23+
uses: ./.github/actions/setup-bazel-self-hosted
2824

2925
- name: Presubmit Checks
3026
# The presubmit workflow performs formatting checks, license checks
@@ -40,11 +36,7 @@ jobs:
4036
- uses: actions/checkout@v6
4137

4238
- name: Setup Bazel
43-
uses: bazel-contrib/setup-bazel@0.19.0
44-
with:
45-
bazelisk-cache: false
46-
disk-cache: false
47-
repository-cache: false
39+
uses: ./.github/actions/setup-bazel-self-hosted
4840

4941
- name: Run tests
5042
# See workflows.json for the `ci` definition.
@@ -59,11 +51,7 @@ jobs:
5951
- uses: actions/checkout@v6
6052

6153
- name: Setup Bazel
62-
uses: bazel-contrib/setup-bazel@0.19.0
63-
with:
64-
bazelisk-cache: false
65-
disk-cache: false
66-
repository-cache: false
54+
uses: ./.github/actions/setup-bazel-self-hosted
6755

6856
- name: Build
6957
# See workflows.json for the `default` definition.

0 commit comments

Comments
 (0)