From c1b440304059c06e5f00d508230d73e824cfb2b1 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Tue, 13 Oct 2026 13:31:47 -0700 Subject: [PATCH] Fix and update Bazel build/test configuration: - Run Bazel CI tests under the configured matrix JDK runtimes rather than always using `.bazelrc`'s default runtime (which prior to this CL was JDK 21). - Standardize the version matrix on [8, 11, 25]. - I will have to bypass the Copybara presubmit for this CL because it will still be looking for a JDK 22 Flogger job instead of the new JDK 25 job (b/360096677). Maybe I should rename all our projects' "25" jobs to "latest LTS".... - I will "have to" update [the Flogger branch-protection rules](https://github.com/google/flogger/settings/branch_protection_rules/42636378) to require the new JDK 25 job instead of the JDK 22 job that I'm removing. (IIRC, nothing actually blocks on that, but it's nice for it to match our "real" rules.) - Huh, apparently GitHub is nudging me from branch-protection rules to ["rulesets."](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets) I'm not going to worry about that now. - For Bazel toolchain/`exec` operations, use a JDK 25 (including allowing Java 25 language features), and for the `bazel`/`mvn` VM itself, have CI request JDK 27. - 25 (as the most recent LTS) is the newest version that Bazel has available for automatic download across all platforms. (It has 27 for Linux only.) - For selecting the language version, use `--java_language_version=8` instead of `--release` or `-source -target`. It's shorter and more standard, and Bazel even silences the deprecation warning that we'd otherwise see when targeting 8. - Remove redundant debug-info javac options (`-g`) in Flogger: `rules_java` enables it (along with `-parameters`) by default nowadays. - Enable `--experimental_one_version_enforcement=error` as widely as we can. - Upgrade Flogger's `bazel_common` dep. - Set `test --test_env=TZ=UTC`. - Configure `ci.yml` to cache the right(?) Bazel information (`~/.cache/bazel/*/cache`, including `cache/repos/v1`, instead of `~/.cache/bazel/*/*/external`). Prep work: - Skip Flogger tests that use Mockito under Java 8. Mockito 5+ requires Java 11+. (It would make sense to skip under Java 9 and Java 10, too, but meh.) - Set `--jvmopt=-Dnet.bytebuddy.experimental=true` for Flogger to enable support for Java-25 class files. Compare cl/996591293. RELNOTES=n/a PiperOrigin-RevId: 998856377 --- .bazelrc | 10 +++++++++- .github/workflows/ci.yml | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index 95f53c2..a384e91 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1 +1,9 @@ -build --java_runtime_version=21 --javacopt='--release 8' +build --java_language_version=8 --tool_java_language_version=25 +build --java_runtime_version=25 --tool_java_runtime_version=25 + +build --experimental_one_version_enforcement=error +# TODO(cpovirk): Remove after upgrading to a version of rules_java without an +# error_prone_annotations dep (after cl/998596263). +build --noone_version_enforcement_on_java_tests + +test --test_env=TZ=UTC diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d08b19b..6006258 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,15 +31,15 @@ jobs: - name: 'Cache Bazel dependencies' uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with: - path: ~/.cache/bazel/*/*/external + path: ~/.cache/bazel/*/cache key: bazel-${{ hashFiles('MODULE.bazel') }} restore-keys: | bazel- - - name: 'Set up JDK ${{ matrix.java }}' + - name: 'Set up JDK 27' uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 with: - java-version: ${{ matrix.java }} + java-version: 27 distribution: 'temurin' - name: 'Test' shell: bash - run: bazelisk test --lockfile_mode=error --test_output=errors //... + run: bazelisk test --java_runtime_version=${{ matrix.java }} --lockfile_mode=error --test_output=errors //...