Skip to content

Commit

Permalink
Enable remote Bazel cache through Google Cloud Storage
Browse files Browse the repository at this point in the history
This commit lands a support for public read-only remote Bazel cache
stored on Google Cloud Storage at
https://storage.googleapis.com/seleniumhq-bazel-remote-cache. The
storage bucket is public so anyone on the internet can use it to speed
up building Selenium locally.

The cache is written on the trunk CI builds by specifying
--remote_upload_local_results=true in CI .bazelrc. Likewise, Selenium
committers can write to the cache by getting the JSON key and adding
the following to the .bazelrc.local:
build --remote_upload_local_results=true --google_credentials=<path-to-json-key>

For now, the bucket is stored in @p0deje personal Google cloud and we
should eventually move it SeleniumHQ account if/once we have it.
  • Loading branch information
p0deje committed Dec 14, 2022
1 parent e8ae58d commit 87b4de8
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 121 deletions.
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ build:linux --workspace_status_command=scripts/build-info.sh
build:macos --workspace_status_command=scripts/build-info.sh
build:windows --workspace_status_command="powershell.exe scripts/build-info.ps1"

# Enable read-only public remote cache.
# To enable write mode, add the following to your .bazelrc.local:
# build --remote_upload_local_results=true --google_credentials=<path-to-json-key>

build --remote_cache=https://storage.googleapis.com/seleniumhq-bazel-remote-cache --remote_upload_local_results=false

# Make sure we get something helpful when tests fail

build --verbose_failures
Expand Down
4 changes: 0 additions & 4 deletions .github/.bazelrc.local
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ startup --output_base=/tmp/bazel
# Set up caching on local disk so incremental builds are faster
# See https://bazel.build/designs/2016/09/30/repository-cache.html
build --repository_cache=~/.cache/bazel-repo
test --repository_cache=~/.cache/bazel-repo
# See https://docs.bazel.build/versions/master/remote-caching.html#disk-cache
build --disk_cache=~/.cache/bazel-disk
test --disk_cache=~/.cache/bazel-disk

# Make output easier to read
build --curses=no
Expand Down
4 changes: 3 additions & 1 deletion .github/.bazelrc.windows.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Use predefined path for building so we could cache `external/`.
startup --output_base=D:/_bazel
build --disk_cache=D:/_bazel-disk

# Set up caching on local disk so incremental builds are faster
# See https://bazel.build/designs/2016/09/30/repository-cache.html
build --repository_cache=D:/_bazel-repo
15 changes: 13 additions & 2 deletions .github/actions/cache-bazel/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
key:
description: Extra cache key
required: true
gcs-key:
description: GCS Key
required: false
runs:
using: "composite"
steps:
Expand All @@ -29,7 +32,6 @@ runs:
D:\_bazel\external\bundle
D:\_bazel\external\rules_ruby
D:\_bazel\external\rules_ruby_dist
D:\_bazel-disk
D:\_bazel-repo
key: ${{ runner.os }}-bazel-${{ inputs.workflow }}-${{ inputs.key }}-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
Expand All @@ -40,9 +42,18 @@ runs:
with:
path: |
/tmp/bazel/external
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-${{ inputs.workflow }}-${{ inputs.key }}-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-${{ inputs.workflow }}-${{ inputs.key }}-
${{ runner.os }}-bazel-${{ inputs.workflow }}-
- run: |
echo '${{ inputs.gcs-key }}' >> gcs.json
echo "build --remote_upload_local_results=true --google_credentials=gcs.json" >> .bazelrc
if: github.ref == 'refs/head/trunk' && runner.os != 'Windows'
shell: bash
- run: |
echo ${{ inputs.gcs-key }}>>gcs.json
echo "build --remote_upload_local_results=true --google_credentials=gcs.json">>.bazelrc
if: github.ref == 'refs/head/trunk' && runner.os == 'Windows'
shell: cmd
1 change: 1 addition & 0 deletions .github/workflows/ci-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
with:
workflow: dotnet
key: ${{ matrix.driver }}-${{ matrix.framework }}
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup dotnet tests
uses: ./.github/actions/bazel
with:
Expand Down
96 changes: 32 additions & 64 deletions .github/workflows/ci-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-build-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-build-
workflow: bazel
key: build
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -59,15 +56,11 @@ jobs:
with:
fetch-depth: 0
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-small-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-small-tests-
${{ runner.os }}-bazel-build-
workflow: bazel
key: small-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -93,15 +86,11 @@ jobs:
with:
fetch-depth: 0
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-medium-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-medium-tests-
${{ runner.os }}-bazel-build-
workflow: bazel
key: medium-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -121,15 +110,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-lint-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-lint-
${{ runner.os }}-bazel-build-
workflow: bazel
key: lint
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -156,15 +141,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-${{ matrix.browser }}-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-${{ matrix.browser }}-tests-
${{ runner.os }}-bazel-build-
workflow: bazel
key: ${{ matrix.browser }}-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Fluxbox
run: sudo apt-get -y install fluxbox
- name: Setup Java
Expand Down Expand Up @@ -213,16 +194,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-${{ matrix.browser }}-server-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-${{ matrix.browser }}-server-tests-
${{ runner.os }}-bazel-${{ matrix.browser }}-tests-
${{ runner.os }}-bazel-build-
workflow: bazel
key: ${{ matrix.browser }}-server-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Fluxbox
run: sudo apt-get -y install fluxbox
- name: Setup Java
Expand Down Expand Up @@ -263,15 +239,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-firefox-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-firefox-tests-
${{ runner.os }}-bazel-build-
workflow: bazel
key: firefox-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Fluxbox
run: sudo apt-get -y install fluxbox
- name: Setup Java
Expand Down Expand Up @@ -306,15 +278,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-firefox-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-firefox-tests-
${{ runner.os }}-bazel-build-
workflow: bazel
key: firefox-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/ci-javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-node-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-node-tests-
${{ runner.os }}-bazel-build-
workflow: bazel
key: node-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v1
with:
Expand Down Expand Up @@ -86,14 +82,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
uses: ./.github/actions/cache-bazel
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-atom-firefox-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-atom-firefox-tests-
workflow: bazel
key: atom-firefox-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand Down
55 changes: 20 additions & 35 deletions .github/workflows/ci-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-python-unit-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-python-unit-tests-
uses: ./.github/actions/cache-bazel
with:
workflow: python
key: unit-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -116,15 +113,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-chrome-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-chrome-tests-
${{ runner.os }}-bazel-python-unit-tests-
uses: ./.github/actions/cache-bazel
with:
workflow: python
key: chrome-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Fluxbox
run: sudo apt-get -y install fluxbox
- name: Setup Chrome
Expand All @@ -149,15 +142,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-firefox-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-firefox-tests-
${{ runner.os }}-bazel-python-unit-tests-
uses: ./.github/actions/cache-bazel
with:
workflow: python
key: firefox-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Fluxbox
run: sudo apt-get -y install fluxbox
- name: Setup Java
Expand Down Expand Up @@ -189,15 +178,11 @@ jobs:
- name: Checkout source tree
uses: actions/checkout@v3
- name: Cache Bazel artifacts
uses: actions/cache@v3
with:
path: |
~/.cache/bazel-disk
~/.cache/bazel-repo
key: ${{ runner.os }}-bazel-firefox-tests-${{ hashFiles('**/BUILD.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-firefox-tests-
${{ runner.os }}-bazel-python-unit-tests-
uses: ./.github/actions/cache-bazel
with:
workflow: python
key: firefox-tests
gcs-key: ${{ secrets.GOOGLE_CLOUD_STORAGE_KEY }}
- name: Setup Fluxbox
run: sudo apt-get -y install fluxbox
- name: Setup Java
Expand Down
Loading

0 comments on commit 87b4de8

Please sign in to comment.