From 62b084912cdaf35c30f09259d027d6506cd59791 Mon Sep 17 00:00:00 2001 From: Lutz Reinhardt Date: Thu, 18 Jun 2026 15:12:00 +0000 Subject: [PATCH 1/8] feat: Add disk cache garbage collection to setup-bazel-cache The caches saved by setup-bazel-cache can at the moment grow without limits. This puts a limit to the disk cache. --- setup-bazel-cache/README.md | 10 +++++++++- setup-bazel-cache/action.yml | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/setup-bazel-cache/README.md b/setup-bazel-cache/README.md index d3e55c8..87853ee 100644 --- a/setup-bazel-cache/README.md +++ b/setup-bazel-cache/README.md @@ -9,9 +9,17 @@ steps: - uses: eclipse-score/cicd-actions/setup-bazel-cache@ with: unique-cache-name: ${{ github.workflow }}-${{ github.job }} [-matrix-uid] + # Optional parameters with default values: + main-branch: main + disk_cache_gc_max_size: 5GB ``` -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. +- 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 diff --git a/setup-bazel-cache/action.yml b/setup-bazel-cache/action.yml index 3c3ec0e..c8de15a 100644 --- a/setup-bazel-cache/action.yml +++ b/setup-bazel-cache/action.yml @@ -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 5GB, which is big enough for a standard build of communication (uses 3.6GB). + required: false + default: "5GB" + # Non stable API, subject to change without deprecation. Not intended for public use. _bazelisk_cache: description: For debugging purposes only. @@ -51,6 +56,14 @@ inputs: runs: using: composite steps: + - 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" - uses: castler/setup-bazel@68beb23a00fcbd742821ab5e8e730866fec63eaf # cache-optimized branch 2026-06-09 with: disk-cache: ${{ inputs.unique-cache-name }} From eb3d091813ca732333339017a1d5309221127f36 Mon Sep 17 00:00:00 2001 From: Lutz Reinhardt Date: Thu, 18 Jun 2026 15:14:37 +0000 Subject: [PATCH 2/8] fix substitution error --- setup-bazel-cache/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup-bazel-cache/action.yml b/setup-bazel-cache/action.yml index c8de15a..ba5d2ae 100644 --- a/setup-bazel-cache/action.yml +++ b/setup-bazel-cache/action.yml @@ -61,8 +61,8 @@ runs: 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 "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" - uses: castler/setup-bazel@68beb23a00fcbd742821ab5e8e730866fec63eaf # cache-optimized branch 2026-06-09 with: From 8d5bf089b2023b2f2d179cc2331b43cf173eb1f4 Mon Sep 17 00:00:00 2001 From: Lutz Reinhardt Date: Thu, 18 Jun 2026 15:29:02 +0000 Subject: [PATCH 3/8] fix shell command --- setup-bazel-cache/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-bazel-cache/action.yml b/setup-bazel-cache/action.yml index ba5d2ae..ef09e36 100644 --- a/setup-bazel-cache/action.yml +++ b/setup-bazel-cache/action.yml @@ -63,7 +63,7 @@ runs: 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" + echo "common --experimental_disk_cache_gc_idle_delay=0m" >> ~/.bazelrc - uses: castler/setup-bazel@68beb23a00fcbd742821ab5e8e730866fec63eaf # cache-optimized branch 2026-06-09 with: disk-cache: ${{ inputs.unique-cache-name }} From 44739f74f43ef8be6a31bb6a4e4730f39148e632 Mon Sep 17 00:00:00 2001 From: Lutz Reinhardt Date: Thu, 18 Jun 2026 15:33:08 +0000 Subject: [PATCH 4/8] check for added settings in test --- .github/workflows/test-setup-bazel-cache.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/test-setup-bazel-cache.yml b/.github/workflows/test-setup-bazel-cache.yml index 40cefce..ad733ff 100644 --- a/.github/workflows/test-setup-bazel-cache.yml +++ b/.github/workflows/test-setup-bazel-cache.yml @@ -70,6 +70,21 @@ jobs: exit 1 fi + 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 + echo "~/.bazelrc contents:" cat "${HOME}/.bazelrc" From 5edd4cb70baed8e41204fcc4155fbbf33891e489 Mon Sep 17 00:00:00 2001 From: Lutz Reinhardt Date: Thu, 18 Jun 2026 15:36:44 +0000 Subject: [PATCH 5/8] improve workflow logging --- .github/workflows/test-setup-bazel-cache.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-setup-bazel-cache.yml b/.github/workflows/test-setup-bazel-cache.yml index ad733ff..a39552b 100644 --- a/.github/workflows/test-setup-bazel-cache.yml +++ b/.github/workflows/test-setup-bazel-cache.yml @@ -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: | @@ -85,9 +92,6 @@ jobs: exit 1 fi - echo "~/.bazelrc contents:" - cat "${HOME}/.bazelrc" - - name: Run bazel info to verify workspace and cache configuration are valid shell: bash run: bazel info --announce_rc From 5cd37eaa824be9a335b40501a9274f112b80ca09 Mon Sep 17 00:00:00 2001 From: Lutz Reinhardt Date: Thu, 18 Jun 2026 15:39:03 +0000 Subject: [PATCH 6/8] set bazel caching after using setup-bazel --- setup-bazel-cache/action.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/setup-bazel-cache/action.yml b/setup-bazel-cache/action.yml index ef09e36..9700be3 100644 --- a/setup-bazel-cache/action.yml +++ b/setup-bazel-cache/action.yml @@ -56,14 +56,6 @@ inputs: runs: using: composite steps: - - 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 - uses: castler/setup-bazel@68beb23a00fcbd742821ab5e8e730866fec63eaf # cache-optimized branch 2026-06-09 with: disk-cache: ${{ inputs.unique-cache-name }} @@ -73,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 From dc4c7e7030af870849f364d87ae49e1d7aa7195f Mon Sep 17 00:00:00 2001 From: Lutz Reinhardt Date: Thu, 18 Jun 2026 15:43:10 +0000 Subject: [PATCH 7/8] correct max size parameter --- setup-bazel-cache/README.md | 2 +- setup-bazel-cache/action.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup-bazel-cache/README.md b/setup-bazel-cache/README.md index 87853ee..88db31f 100644 --- a/setup-bazel-cache/README.md +++ b/setup-bazel-cache/README.md @@ -11,7 +11,7 @@ steps: unique-cache-name: ${{ github.workflow }}-${{ github.job }} [-matrix-uid] # Optional parameters with default values: main-branch: main - disk_cache_gc_max_size: 5GB + disk_cache_gc_max_size: 5G ``` Parameters: diff --git a/setup-bazel-cache/action.yml b/setup-bazel-cache/action.yml index 9700be3..e541da8 100644 --- a/setup-bazel-cache/action.yml +++ b/setup-bazel-cache/action.yml @@ -25,9 +25,9 @@ inputs: default: "main" disk_cache_gc_max_size: - description: Maximum size of the Bazel disk cache. Set to 0 for unlimited. Default is 5GB, which is big enough for a standard build of communication (uses 3.6GB). + 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: "5GB" + default: "5G" # Non stable API, subject to change without deprecation. Not intended for public use. _bazelisk_cache: From 3b218cb89c17441e67e05d1d053758744ac6d7e7 Mon Sep 17 00:00:00 2001 From: Lutz Reinhardt Date: Fri, 19 Jun 2026 10:08:11 +0000 Subject: [PATCH 8/8] make github.workflow in cache name optional --- setup-bazel-cache/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup-bazel-cache/README.md b/setup-bazel-cache/README.md index 88db31f..58c5095 100644 --- a/setup-bazel-cache/README.md +++ b/setup-bazel-cache/README.md @@ -8,7 +8,7 @@ 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@ with: - unique-cache-name: ${{ github.workflow }}-${{ github.job }} [-matrix-uid] + unique-cache-name: [${{ github.workflow }}-]${{ github.job }}[-] # Optional parameters with default values: main-branch: main disk_cache_gc_max_size: 5G @@ -17,7 +17,9 @@ steps: 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. + 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.