From 95f3e2bf138b904c0f306a5da895e8ca94922475 Mon Sep 17 00:00:00 2001 From: Andrey Babanin Date: Tue, 27 Jan 2026 16:55:50 +0100 Subject: [PATCH 1/2] Restrict bazel cache writes to push events - Upgrade bazel-contrib/setup-bazel to v0.18.0 - Set cache-save to only write on push events to prevent pull requests from polluting the Bazel cache - Disable caching for copyright and format as it doesn't bring much for these simple workflows, but polutes github cache --- .github/workflows/copyright.yml | 7 ++++--- .github/workflows/docs-verify.yml | 3 ++- .github/workflows/docs.yml | 3 ++- .github/workflows/format.yml | 7 ++++--- .github/workflows/license-check.yml | 3 ++- .github/workflows/qnx-build.yml | 3 ++- .github/workflows/static-analysis.yml | 3 ++- .github/workflows/tests.yml | 3 ++- README.md | 4 +++- 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/copyright.yml b/.github/workflows/copyright.yml index 2d61391..47431ee 100644 --- a/.github/workflows/copyright.yml +++ b/.github/workflows/copyright.yml @@ -30,11 +30,12 @@ jobs: uses: actions/checkout@v4.2.2 - name: Setup Bazel with shared caching - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: - disk-cache: true - repository-cache: true + disk-cache: false + repository-cache: false bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} - name: Run Copyright Check run: | diff --git a/.github/workflows/docs-verify.yml b/.github/workflows/docs-verify.yml index 3a3ff34..84be0e5 100644 --- a/.github/workflows/docs-verify.yml +++ b/.github/workflows/docs-verify.yml @@ -57,11 +57,12 @@ jobs: echo "pip_cache=${BASE}/pip" >> "$GITHUB_OUTPUT" - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: disk-cache: false repository-cache: false bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} - name: Prepare cache dirs shell: bash diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7ac07b0..9a96fce 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -80,11 +80,12 @@ jobs: echo "pip_cache=${BASE}/pip" >> "$GITHUB_OUTPUT" - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: disk-cache: false repository-cache: false bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} - name: Prepare cache dirs shell: bash diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 2613578..d917e53 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -29,11 +29,12 @@ jobs: uses: actions/checkout@v4.2.2 - name: Setup Bazel with shared caching - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: - disk-cache: true - repository-cache: true + disk-cache: false + repository-cache: false bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} - name: Run Formatting Check diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml index 9c8cde8..04489f8 100644 --- a/.github/workflows/license-check.yml +++ b/.github/workflows/license-check.yml @@ -44,11 +44,12 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - name: Setup Bazel with shared caching - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: disk-cache: true repository-cache: true bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} - name: Run License Check via Bazel run: | diff --git a/.github/workflows/qnx-build.yml b/.github/workflows/qnx-build.yml index 7daa55a..2dfdd55 100644 --- a/.github/workflows/qnx-build.yml +++ b/.github/workflows/qnx-build.yml @@ -64,11 +64,12 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - name: Setup Bazel with shared caching - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: disk-cache: true repository-cache: true bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} - name: Prepare QNX license env: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index a9392b9..2f284d8 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -31,11 +31,12 @@ jobs: uses: actions/checkout@v4.2.2 - name: Setup Bazel with shared caching - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: disk-cache: true repository-cache: true bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} - name: Run Static Analysis via Bazel run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac79960..2d0747e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,11 +35,12 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - name: Setup Bazel with shared caching - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: disk-cache: true repository-cache: true bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} - name: Run Tests via Bazel run: | diff --git a/README.md b/README.md index 2f721bf..bea930e 100644 --- a/README.md +++ b/README.md @@ -308,11 +308,12 @@ To improve performance and reduce redundant downloads across workflow runs, the ```yaml - name: Setup Bazel with shared caching - uses: bazel-contrib/setup-bazel@0.14.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: disk-cache: true repository-cache: true bazelisk-cache: true + cache-save: ${{ github.event_name == 'push' }} ``` ### Benefits @@ -320,6 +321,7 @@ To improve performance and reduce redundant downloads across workflow runs, the - **`disk-cache`**: Stores compiled Bazel outputs across jobs. - **`repository-cache`**: Caches external dependencies (e.g., modules, WORKSPACE fetches). - **`bazelisk-cache`**: Avoids re-downloading Bazel binaries. +- **`cache-save`**: Saves the cache only on push events to avoid unnecessary cache updates (e.g., from pull requests). This setup significantly reduces CI build time and improves reuse across different workflows. From 0688019d42aa6af0ba31df06c7f064226febab70 Mon Sep 17 00:00:00 2001 From: Andrey Babanin Date: Tue, 27 Jan 2026 18:15:19 +0100 Subject: [PATCH 2/2] Add optional bazel-disk-cache input to QNX build workflow By introducing a parameter, workflows can now pass a custom string to use as cache key for workflow separation. --- .github/workflows/qnx-build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/qnx-build.yml b/.github/workflows/qnx-build.yml index 2dfdd55..9625ef8 100644 --- a/.github/workflows/qnx-build.yml +++ b/.github/workflows/qnx-build.yml @@ -36,6 +36,11 @@ on: required: false default: "workflow-approval" type: string + bazel-disk-cache: + description: "Enable Bazel disk cache on GitHub. The value can be a string to use as cache key for separating workflows" + required: false + default: "true" + type: string secrets: score-qnx-license: description: "Base64-encoded QNX license content" @@ -66,7 +71,7 @@ jobs: - name: Setup Bazel with shared caching uses: bazel-contrib/setup-bazel@0.18.0 with: - disk-cache: true + disk-cache: ${{ inputs.bazel-disk-cache }} repository-cache: true bazelisk-cache: true cache-save: ${{ github.event_name == 'push' }}