Skip to content
Draft
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
23 changes: 21 additions & 2 deletions .github/workflows/test-setup-bazel-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ jobs:
with:
unique-cache-name: ${{ github.workflow }}-${{ github.job }}

- name: Print ~/.bazelrc
shell: bash
run: |
set -euo pipefail
echo "~/.bazelrc contents:"
cat "${HOME}/.bazelrc"

- name: Verify ~/.bazelrc was written by action with cache configuration
shell: bash
run: |
Expand All @@ -70,8 +77,20 @@ jobs:
exit 1
fi

echo "~/.bazelrc contents:"
cat "${HOME}/.bazelrc"
if ! grep -Fq -- "--experimental_disk_cache_gc_max_age=" "${HOME}/.bazelrc"; then
echo "ERROR: ~/.bazelrc does not contain experimental_disk_cache_gc_max_age configuration"
exit 1
fi

if ! grep -Fq -- "--experimental_disk_cache_gc_max_size=" "${HOME}/.bazelrc"; then
echo "ERROR: ~/.bazelrc does not contain experimental_disk_cache_gc_max_size configuration"
exit 1
fi

if ! grep -Fq -- "--experimental_disk_cache_gc_idle_delay=" "${HOME}/.bazelrc"; then
echo "ERROR: ~/.bazelrc does not contain experimental_disk_cache_gc_idle_delay configuration"
exit 1
fi

- name: Run bazel info to verify workspace and cache configuration are valid
shell: bash
Expand Down
14 changes: 12 additions & 2 deletions setup-bazel-cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ Bazel builds can be slow. Caching helps — but only if the cache is set up corr
steps:
- uses: eclipse-score/cicd-actions/setup-bazel-cache@<sha>
with:
unique-cache-name: ${{ github.workflow }}-${{ github.job }} [-matrix-uid]
unique-cache-name: [${{ github.workflow }}-]${{ github.job }}[-<matrix-uid>]
# Optional parameters with default values:
main-branch: main
disk_cache_gc_max_size: 5G
```

Using `github.workflow` and `github.job` together gives each job its own cache automatically. Append a matrix identifier if the same job runs with different configurations that produce different build outputs.
Parameters:

- unique-cache-name: A unique name for the cache. This is required to avoid conflicts between different jobs and workflows.
Using `github.workflow` and `github.job` together gives each job its own cache automatically.
Append a matrix identifier if the same job runs with different configurations that produce different build outputs.
Omit `github.workflow` if you use `workflow_call` triggers and want to avoid nesting caches under the caller's workflow name.
- main-branch: The branch that is allowed to save the cache. Override if your default branch has a different name.
- disk_cache_gc_max_size: Maximum size of the Bazel disk cache. Set to 0 for unlimited.

## Required permissions

Expand Down
14 changes: 14 additions & 0 deletions setup-bazel-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ inputs:
required: false
default: "main"

disk_cache_gc_max_size:
description: Maximum size of the Bazel disk cache. Set to 0 for unlimited. Default is 5G, which is big enough for a standard build of communication (uses 3.6GB).
required: false
default: "5G"

# Non stable API, subject to change without deprecation. Not intended for public use.
_bazelisk_cache:
description: For debugging purposes only.
Expand Down Expand Up @@ -60,3 +65,12 @@ runs:
repository-cache: ${{ inputs._repository_cache }} # true
cache-optimized: ${{ inputs._cache_optimized }} # true
external-cache: ${{ inputs._external_cache }} # false

- name: Setup Bazel Cache
shell: bash
run: |
echo "Bazel Cache: Configuring Bazel disk cache retention time (60 days)..."
echo "common --experimental_disk_cache_gc_max_age=60d" >> ~/.bazelrc
echo "Bazel Cache: Configuring Bazel disk cache max size (${{ inputs.disk_cache_gc_max_size }})..."
echo "common --experimental_disk_cache_gc_max_size=${{ inputs.disk_cache_gc_max_size }}" >> ~/.bazelrc
echo "common --experimental_disk_cache_gc_idle_delay=0m" >> ~/.bazelrc
Loading