Skip to content

Commit

Permalink
chore: refactor Bazel remote cache config (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrindel authored Dec 1, 2023
1 parent dbd5359 commit 6a9b4a8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
17 changes: 16 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Remote Cache Configuration
build:remote-cache --bes_results_url=https://app.buildbuddy.io/invocation/
build:remote-cache --bes_backend=grpcs://remote.buildbuddy.io
build:remote-cache --remote_cache=grpcs://remote.buildbuddy.io
build:remote-cache --remote_timeout=3600
# Avoid failures of the form `deadline exceeded after 14999958197ns DEADLINE_EXCEEDED`.
# See https://github.com/tweag/rules_haskell/issues/1498.
build:remote-cache --keep_backend_build_event_connections_alive=false
# All clients except CI should be configured as read-only
build:remote-cache --noremote_upload_local_results

common:ghc_8_10_7 --repo_env=GHC_VERSION=8.10.7

common:ghc_9_0_2 --repo_env=GHC_VERSION=9.0.2
Expand All @@ -8,4 +19,8 @@ common:ghc_9_4_5 --repo_env=GHC_VERSION=9.4.5

common:bzlmod --enable_bzlmod

try-import .bazelrc.local
# Try to load a file that includes the remote cache authentication flag
try-import %workspace%/.bazelrc.auth

# Try to load any configuration that is specific for this host
try-import %workspace%/.bazelrc.local
8 changes: 2 additions & 6 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- uses: tweag/configure-bazel-remote-cache-auth@v0
with:
buildbuddy_api_key: ${{ secrets.BUILDBUDDY_API_KEY }}
bazelrc_path: .bazelrc.local
bazelrc_path: .bazelrc.auth
- name: Configure
run: |
# Convert "ghc_X_Y_Z" to "X.Y.Z".
Expand All @@ -56,11 +56,7 @@ jobs:
cat >>.bazelrc.local <<EOF
build --host_platform=@rules_nixpkgs_core//platforms:host
build --bes_results_url=https://app.buildbuddy.io/invocation/
build --bes_backend=grpcs://cloud.buildbuddy.io
build --remote_cache=grpcs://cloud.buildbuddy.io
build --remote_timeout=600
build --keep_backend_build_event_connections_alive=false
build --config=remote-cache
build --repository_cache=~/repo-cache/
$bzlmod_setting
EOF
Expand Down
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing to `gazelle_cabal`

## Bazel Remote Cache

The remote cache configuration for this repository is stored in [.bazelrc](/.bazelrc) and grouped
under the name, `remote-cache`. It is configured to allow read-only access for all clients and
read-write for CI.

To enable the remote cache,

1. Add `build --remote_header=x-buildbuddy-api-key=${buildbuddy_api_key}` to `.bazelrc.auth`
at the root of the workspace, replacing `${buildbuddy_api_key}` with the actual API key value.
1. Add `build --config=remote-cache` to `.bazelrc.local` at the root of the workspace.

0 comments on commit 6a9b4a8

Please sign in to comment.