From e1f97863f794ac1ec3eb4b48e27eb3f0386a58a0 Mon Sep 17 00:00:00 2001 From: Daniel Toyama Date: Sun, 19 Jul 2026 06:03:50 -0700 Subject: [PATCH] Experiment with Bazel external caching and performance flags in OSS CI. PiperOrigin-RevId: 950378772 --- .bazelrc | 5 +++++ .github/workflows/tests.yml | 17 +++++++++-------- MODULE.bazel | 14 +++++++++++++- requirements.txt | 2 +- 4 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 .bazelrc diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 00000000..395c8bf4 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,5 @@ +# Default build and test options for AndroidEnv +build --cxxopt=-std=c++17 +build --host_cxxopt=-std=c++17 +build --incompatible_enable_proto_toolchain_resolution +build --announce_rc diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 284151aa..6a503ca1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,13 +28,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.19.0 - with: - bazelisk-cache: true - disk-cache: true - repository-cache: true - - name: Configure MODULE.bazel python version run: | MATRIX_VER="${{ matrix.python-version }}" @@ -42,9 +35,17 @@ jobs: sed -i "s/python_version = \"3.11\"/python_version = \"$MATRIX_VER\"/g" MODULE.bazel sed -i "s/python_3_11/python_$VER_UNDERSCORE/g" MODULE.bazel + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.19.0 + with: + bazelisk-cache: true + disk-cache: true + repository-cache: true + external-cache: true + - name: Run tests run: | - bazel test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //... + bazel test //... - name: Upload test logs if: always() uses: actions/upload-artifact@v4 diff --git a/MODULE.bazel b/MODULE.bazel index e1cda6f1..364e4142 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,9 +6,21 @@ module( # Core rules bazel_dep(name = "rules_python", version = "2.2.0") bazel_dep(name = "rules_proto_grpc_python", version = "5.8.0") -bazel_dep(name = "protobuf", version = "27.2") +bazel_dep(name = "protobuf", version = "31.1") bazel_dep(name = "rules_proto", version = "6.0.2") +# Hermetic Pre-built Protoc Toolchain +bazel_dep(name = "toolchains_protoc", version = "0.6.1") + +protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc") +protoc.toolchain( + google_protobuf = "com_google_protobuf", + version = "v31.1", +) +use_repo(protoc, "toolchains_protoc_hub") + +register_toolchains("@toolchains_protoc_hub//:all") + # Hermetic Python Toolchain python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( diff --git a/requirements.txt b/requirements.txt index bd1e2c69..88672903 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ absl-py==2.1.0 dm-env==1.6 numpy==2.1.0 portpicker==1.6.0 -pygame==2.6.0 +pygame>=2.6.0 pillow>=10.4.0 gymnasium==0.29.1 protobuf>=6,<7