From 8898444a82f7f913ed5efcecf7b12c01ca71deaa Mon Sep 17 00:00:00 2001 From: rmaddikery Date: Mon, 15 Jun 2026 17:21:58 +0200 Subject: [PATCH] workflows - unify bazel caching - combine workflows for x86_64 config - Unifies bazel caches for workflows so that PRs can restore a warm cache without pollluting it. - nightly runs can seed it --- .github/workflows/build.yml | 77 ------------ .github/workflows/build_and_test_host.yml | 114 ++++++++++++++++++ .github/workflows/component_tests.yml | 65 ---------- .github/workflows/component_tests_nightly.yml | 27 +---- .github/workflows/sanitizers.yml | 8 +- 5 files changed, 126 insertions(+), 165 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/build_and_test_host.yml delete mode 100644 .github/workflows/component_tests.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d6bcbf65..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,77 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* - -name: Bazel Build - -on: - pull_request: - types: [opened, reopened, synchronize] - merge_group: - types: [checks_requested] - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SCORE_QNX_USER: ${{ secrets.SCORE_QNX_USER }} - SCORE_QNX_PASSWORD: ${{ secrets.SCORE_QNX_PASSWORD }} - SCORE_QNX_LICENSE: ${{ secrets.SCORE_QNX_LICENSE }} -jobs: - build: - name: Build Bazel Code - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4.2.2 - - - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.15.0 - with: - bazelisk-version: 1.26.0 # newest LTS before 1 Jun 2025 - disk-cache: true - repository-cache: true - bazelisk-cache: true - - - name: Bazel info (discover paths) - id: bazel-info - run: | - echo "BAZEL_OUTPUT_BASE=$(bazel info output_base)" >> $GITHUB_ENV - echo "BAZEL_USER_ROOT=$(bazel info output_user_root)" >> $GITHUB_ENV - echo "BAZEL_REPO_CACHE=$(bazel info repository_cache)" >> $GITHUB_ENV - bazel info - - - name: Cache Bazel output base - uses: actions/cache@v4 - with: - path: | - ${{ env.BAZEL_OUTPUT_BASE }}/action_cache - ${{ env.BAZEL_OUTPUT_BASE }}/bazel-out - ${{ env.BAZEL_OUTPUT_BASE }}/external - ${{ env.BAZEL_OUTPUT_BASE }}/execroot - key: bazel-ob-v2-${{ runner.os }}-${{ hashFiles('.bazelversion', 'MODULE.bazel', 'MODULE.bazel.lock', '**/*.bzl') }} - restore-keys: | - bazel-ob-v2-${{ runner.os }}- - - - name: Build with Bazel - run: | - # Exclude targets that are not expected to build the source code, e.g. documentation, format check, live preview, product integration tests. - # Please execute "bazel query 'kind(rule, //:*)'" to find the list of all excluded targets by this option. - bazel build --lockfile_mode=error --config x86_64-linux -- \ - //... \ - -//:* \ - -//score/test/component/... - - - name: Test with Bazel - run: | - # Component tests run in component_tests.yml; exclude here to avoid pulling in QNX deps. - bazel test --lockfile_mode=error --config x86_64-linux \ - --test_tag_filters=-no_ci \ - -- //score/... -//score/test/component/... diff --git a/.github/workflows/build_and_test_host.yml b/.github/workflows/build_and_test_host.yml new file mode 100644 index 00000000..da0b2ea4 --- /dev/null +++ b/.github/workflows/build_and_test_host.yml @@ -0,0 +1,114 @@ +# ******************************************************************************* +# Copyright (c) 2026 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +# Consolidated x86_64-linux build_and_test_host pipeline. +# +# Pattern: build once, test many -- WITHIN THE SAME BAZEL CONFIG. +# - The `build` job compiles the x86_64-linux graph a single time and warms a +# shared Bazel disk cache (disk-cache namespace = this workflow). +# - Test jobs use the SAME config (--config x86_64-linux) and `needs: build`, +# so they start after the cache is saved, get cache hits, and only link + +# run tests. + +name: build_and_test_host + +on: + pull_request: + types: [opened, reopened, synchronize] + merge_group: + types: [checks_requested] + +permissions: + contents: read + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +# Shared by every job so they restore/save the same per-workflow disk cache. +# cache-save is true only off-PR (merge_group) so PRs restore without polluting. +jobs: + build: + name: Build (x86_64-linux) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4.2.2 + + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.18.0 + with: + bazelisk-version: 1.26.0 + disk-cache: ${{ github.workflow }} + repository-cache: true + bazelisk-cache: true + cache-save: ${{ github.event_name != 'pull_request' }} + + - name: Build with Bazel + run: | + # Exclude targets that are not expected to build the source code, e.g. + # documentation, format check, live preview, product integration tests. + bazel build --lockfile_mode=error --config x86_64-linux -- \ + //... \ + -//:* \ + -//score/test/component/... + + unit-tests: + name: Unit Tests (x86_64-linux) + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4.2.2 + + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.18.0 + with: + bazelisk-version: 1.26.0 + disk-cache: ${{ github.workflow }} + repository-cache: true + bazelisk-cache: true + cache-save: ${{ github.event_name != 'pull_request' }} + + - name: Test with Bazel + run: | + # Component tests run in their own job; exclude here to avoid QNX deps. + bazel test --lockfile_mode=error --config x86_64-linux \ + --test_tag_filters=-no_ci \ + -- //score/... -//score/test/component/... + + component-tests: + name: Component Tests (x86_64-linux) + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4.2.2 + + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.18.0 + with: + bazelisk-version: 1.26.0 + disk-cache: ${{ github.workflow }} + repository-cache: true + bazelisk-cache: true + cache-save: ${{ github.event_name != 'pull_request' }} + + - name: Run component tests + run: | + bazel test --lockfile_mode=error --config x86_64-linux \ + --test_tag_filters=integration \ + --test_output=errors \ + //score/test/component/datarouter:test_datarouter_filters \ + //score/test/component/mw_log:test_mw_log \ + //score/test/component/mw_log:test_mw_log_filters + diff --git a/.github/workflows/component_tests.yml b/.github/workflows/component_tests.yml deleted file mode 100644 index f607f7b2..00000000 --- a/.github/workflows/component_tests.yml +++ /dev/null @@ -1,65 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* - -name: Component Tests - -on: - pull_request: - types: [opened, reopened, synchronize] - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - component-tests: - name: Run Component Tests - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4.2.2 - - - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.15.0 - with: - bazelisk-version: 1.26.0 - disk-cache: true - repository-cache: true - bazelisk-cache: true - - - name: Bazel info (discover paths) - id: bazel-info - run: | - echo "BAZEL_OUTPUT_BASE=$(bazel info output_base)" >> $GITHUB_ENV - echo "BAZEL_REPO_CACHE=$(bazel info repository_cache)" >> $GITHUB_ENV - bazel info - - - name: Cache Bazel output base - uses: actions/cache@v4 - with: - path: | - ${{ env.BAZEL_OUTPUT_BASE }}/action_cache - ${{ env.BAZEL_OUTPUT_BASE }}/bazel-out - ${{ env.BAZEL_OUTPUT_BASE }}/external - ${{ env.BAZEL_OUTPUT_BASE }}/execroot - key: bazel-ob-component-v1-${{ runner.os }}-${{ hashFiles('.bazelversion', 'MODULE.bazel', 'MODULE.bazel.lock', '**/*.bzl') }} - restore-keys: | - bazel-ob-component-v1-${{ runner.os }}- - - - name: Run component tests - run: | - bazel test --lockfile_mode=error --config x86_64-linux \ - --test_tag_filters=integration \ - --test_output=errors \ - //score/test/component/datarouter:test_datarouter_filters \ - //score/test/component/mw_log:test_mw_log \ - //score/test/component/mw_log:test_mw_log_filters diff --git a/.github/workflows/component_tests_nightly.yml b/.github/workflows/component_tests_nightly.yml index 62232ee7..10041011 100644 --- a/.github/workflows/component_tests_nightly.yml +++ b/.github/workflows/component_tests_nightly.yml @@ -30,31 +30,16 @@ jobs: uses: actions/checkout@v4.2.2 - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.15.0 + uses: bazel-contrib/setup-bazel@0.18.0 with: bazelisk-version: 1.26.0 - disk-cache: true + # Per-workflow disk cache namespace; the action falls back to the + # most recent cache via its built-in restore-keys prefix. + disk-cache: ${{ github.workflow }} repository-cache: true bazelisk-cache: true - - - name: Bazel info (discover paths) - id: bazel-info - run: | - echo "BAZEL_OUTPUT_BASE=$(bazel info output_base)" >> $GITHUB_ENV - echo "BAZEL_REPO_CACHE=$(bazel info repository_cache)" >> $GITHUB_ENV - bazel info - - - name: Cache Bazel output base - uses: actions/cache@v4 - with: - path: | - ${{ env.BAZEL_OUTPUT_BASE }}/action_cache - ${{ env.BAZEL_OUTPUT_BASE }}/bazel-out - ${{ env.BAZEL_OUTPUT_BASE }}/external - ${{ env.BAZEL_OUTPUT_BASE }}/execroot - key: bazel-ob-component-v1-${{ runner.os }}-${{ hashFiles('.bazelversion', 'MODULE.bazel', 'MODULE.bazel.lock', '**/*.bzl') }} - restore-keys: | - bazel-ob-component-v1-${{ runner.os }}- + # Nightly runs (schedule/dispatch) save to seed the warm cache. + cache-save: ${{ github.event_name != 'pull_request' }} - name: Run component tests run: | diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 4a465a37..fe742356 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -42,10 +42,14 @@ jobs: uses: bazel-contrib/setup-bazel@0.18.0 with: bazelisk-version: 1.26.0 - disk-cache: true + # Per-workflow disk cache namespace; the action falls back to the + # most recent cache via its built-in restore-keys prefix. + disk-cache: ${{ github.workflow }} repository-cache: true bazelisk-cache: true - cache-save: ${{ github.event_name == 'push' }} + # Restore on PRs without polluting the shared cache; save on + # merge_group so the integrated state seeds the warm cache. + cache-save: ${{ github.event_name != 'pull_request' }} - name: Run sanitizer tests via Bazel run: |