From 444ca887d9ee50e6f551f8e58396865fb9573485 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Thu, 12 Dec 2024 02:21:20 +0900 Subject: [PATCH] ci: fix CI after bazel 8 release (#2492) Summary: * Remove the old `7.x` config from all `.bazelrc`. * Drop bazel 6 from example testing/support. The `.bazelrc` for enabling `WORKSPACE` cannot work across bazel 6,7,8. * Add missing `BUILD.bazel` file for integration tests. * Remove an integration test runner for `bazel 6.x`. * RBE test for bazel 8 is still not working. * bump `rules_java` for internal WORKSPACE dependencies to a version that supports `8.x`. * start running bazel-in-bazel integration tests using bazel `8.x`. * until bazel-contrib/rules_bazel_integration_test#414 is merged, we need to use bazel 7 for the delete_packagese pre-commit hook, not sure about how to track this as the `cgrindel/bazel-lib` needs a new version. Fixes #2378 --------- Co-authored-by: Richard Levasseur --- .bazelci/presubmit.yml | 23 +++++++++----------- .bazelrc | 4 ++-- .bazelversion | 2 +- .pre-commit-config.yaml | 4 +++- CHANGELOG.md | 4 +++- MODULE.bazel | 8 +++---- WORKSPACE | 15 +++++++++++++ examples/build_file_generation/.bazelrc | 6 ++--- examples/pip_parse/.bazelrc | 2 +- examples/pip_parse_vendored/.bazelrc | 5 +++-- examples/pip_repository_annotations/.bazelrc | 5 +++-- examples/py_proto_library/.bazelrc | 5 +++-- internal_dev_deps.bzl | 5 ++--- internal_dev_setup.bzl | 4 ---- python/BUILD.bazel | 1 + python/runtime_env_toolchains/BUILD.bazel | 6 +++++ tests/integration/BUILD.bazel | 23 +------------------- version.bzl | 4 ++-- 18 files changed, 63 insertions(+), 63 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 8c0252c3c8..f1a912cf80 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -18,12 +18,12 @@ buildifier: # Use a specific version to avoid skew issues when new versions are released. version: 6.1.0 warnings: "all" -# NOTE: Minimum supported version is 6.x for workspace; 7.x for bzlmod +# NOTE: Minimum supported version is 7.x .minimum_supported_version: &minimum_supported_version # For testing minimum supported version. # NOTE: Keep in sync with //:version.bzl - bazel: 6.4.0 - skip_in_bazel_downstream_pipeline: "Bazel 6 required" + bazel: 7.x + skip_in_bazel_downstream_pipeline: "Bazel 7 required" .reusable_config: &reusable_config build_targets: - "--" @@ -34,7 +34,6 @@ buildifier: build_flags: - "--keep_going" - "--build_tag_filters=-integration-test" - - "--config=bazel7.x" test_targets: - "--" - "..." @@ -55,6 +54,7 @@ buildifier: build_flags: - "--noenable_bzlmod" - "--enable_workspace" + bazel: 7.x .common_bazelinbazel_config: &common_bazelinbazel_config build_flags: - "--build_tag_filters=integration-test" @@ -159,7 +159,6 @@ tasks: - "--enable_workspace" - "--keep_going" - "--build_tag_filters=-integration-test" - - "--config=bazel7.x" test_targets: - "--" - "..." @@ -187,7 +186,6 @@ tasks: <<: *reusable_config name: "RBE: Ubuntu, minimum Bazel" platform: rbe_ubuntu2004 - bazel: 7.x build_flags: # BazelCI sets --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1, # which prevents cc toolchain autodetection from working correctly @@ -206,6 +204,9 @@ tasks: <<: *reusable_config name: "RBE: Ubuntu" platform: rbe_ubuntu2004 + # TODO @aignas 2024-12-11: get the RBE working in CI for bazel 8.0 + # See https://github.com/bazelbuild/rules_python/issues/2499 + bazel: 7.x test_flags: - "--test_tag_filters=-integration-test,-acceptance-test" - "--extra_toolchains=@buildkite_config//config:cc-toolchain" @@ -412,25 +413,21 @@ tasks: name: "examples/pip_parse_vendored: Ubuntu, workspace, minimum Bazel" working_directory: examples/pip_parse_vendored platform: ubuntu2004 - integration_test_pip_parse_vendored_ubuntu_min_bzlmod: - <<: *minimum_supported_version - <<: *reusable_build_test_all - name: "examples/pip_parse_vendored: Ubuntu, bzlmod, minimum Bazel" - working_directory: examples/pip_parse_vendored - platform: ubuntu2004 - bazel: 7.x integration_test_pip_parse_vendored_ubuntu: <<: *reusable_build_test_all + <<: *common_workspace_flags name: "examples/pip_parse_vendored: Ubuntu" working_directory: examples/pip_parse_vendored platform: ubuntu2004 integration_test_pip_parse_vendored_debian: <<: *reusable_build_test_all + <<: *common_workspace_flags name: "examples/pip_parse_vendored: Debian" working_directory: examples/pip_parse_vendored platform: debian11 integration_test_pip_parse_vendored_macos: <<: *reusable_build_test_all + <<: *common_workspace_flags name: "examples/pip_parse_vendored: MacOS" working_directory: examples/pip_parse_vendored platform: macos diff --git a/.bazelrc b/.bazelrc index c44124d961..ada5c5a0a7 100644 --- a/.bazelrc +++ b/.bazelrc @@ -23,7 +23,7 @@ common --incompatible_disallow_struct_provider_syntax # Windows makes use of runfiles for some rules build --enable_runfiles -# Make Bazel 6 use bzlmod by default +# Make Bazel 7 use bzlmod by default common --enable_bzlmod # Additional config to use for readthedocs builds. @@ -33,6 +33,6 @@ build:rtd --stamp # Some bzl files contain repos only available under bzlmod build:rtd --enable_bzlmod -common:bazel7.x --incompatible_python_disallow_native_rules +common --incompatible_python_disallow_native_rules build --lockfile_mode=update diff --git a/.bazelversion b/.bazelversion index 35907cd9ca..c6b7980b68 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.x +8.x diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 707a8d78aa..2b451e89fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,6 +46,8 @@ repos: - id: update-deleted-packages name: Update deleted packages language: system - entry: bazel run @rules_bazel_integration_test//tools:update_deleted_packages + # 7.x is necessary until https://github.com/bazel-contrib/rules_bazel_integration_test/pull/414 + # is merged and released + entry: env USE_BAZEL_VERSION=7.x bazel run @rules_bazel_integration_test//tools:update_deleted_packages files: ^((examples|tests)/.*/(MODULE.bazel|WORKSPACE|WORKSPACE.bzlmod|BUILD.bazel)|.bazelrc)$ pass_filenames: false diff --git a/CHANGELOG.md b/CHANGELOG.md index bcf9f52324..1f84193e62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,9 @@ Unreleased changes template. {#v0-0-0-changed} ### Changed -* Nothing changed. +* Bazel 6 support is dropped and Bazel 7.4.1 is the minimum supported + version, per our Bazel support matrix. Earlier versions are not + tested by CI, so functionality cannot be guaranteed. {#v0-0-0-fixed} ### Fixed diff --git a/MODULE.bazel b/MODULE.bazel index e4b113e785..57780b2369 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -150,8 +150,8 @@ bazel_binaries.local( name = "self", path = "tests/integration/bazel_from_env", ) -bazel_binaries.download(version = "6.4.0") -bazel_binaries.download(version = "7.4.0") +bazel_binaries.download(version = "7.4.1") +bazel_binaries.download(version = "8.0.0") # For now, don't test with rolling, because that's Bazel 9, which is a ways # away. @@ -162,8 +162,8 @@ use_repo( # These don't appear necessary, but are reported as direct dependencies # that should be use_repo()'d, so we add them as requested "bazel_binaries_bazelisk", - "build_bazel_bazel_6_4_0", - "build_bazel_bazel_7_4_0", + "build_bazel_bazel_7_4_1", + "build_bazel_bazel_8_0_0", # "build_bazel_bazel_rolling", "build_bazel_bazel_self", ) diff --git a/WORKSPACE b/WORKSPACE index c0d9f33a9b..6e9e85ac1e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -21,6 +21,21 @@ load("//:internal_dev_deps.bzl", "rules_python_internal_deps") rules_python_internal_deps() +load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") + +rules_java_dependencies() + +# note that the following line is what is minimally required from protobuf for the java rules +# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl +load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility + +proto_bazel_features(name = "proto_bazel_features") + +# register toolchains +load("@rules_java//java:repositories.bzl", "rules_java_toolchains") + +rules_java_toolchains() + load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() diff --git a/examples/build_file_generation/.bazelrc b/examples/build_file_generation/.bazelrc index fd0f731d2f..306954d7be 100644 --- a/examples/build_file_generation/.bazelrc +++ b/examples/build_file_generation/.bazelrc @@ -5,6 +5,6 @@ build --enable_runfiles # The bzlmod version of this example is in examples/bzlmod_build_file_generation # Once WORKSPACE support is dropped, this example can be entirely deleted. -build --experimental_enable_bzlmod=false - -common:bazel7.x --incompatible_python_disallow_native_rules +common --noenable_bzlmod +common --enable_workspace +common --incompatible_python_disallow_native_rules diff --git a/examples/pip_parse/.bazelrc b/examples/pip_parse/.bazelrc index a56904803c..f263a1744d 100644 --- a/examples/pip_parse/.bazelrc +++ b/examples/pip_parse/.bazelrc @@ -1,3 +1,3 @@ # https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file try-import %workspace%/user.bazelrc -common:bazel7.x --incompatible_python_disallow_native_rules +common --incompatible_python_disallow_native_rules diff --git a/examples/pip_parse_vendored/.bazelrc b/examples/pip_parse_vendored/.bazelrc index be3555d1eb..a6ea2d9138 100644 --- a/examples/pip_parse_vendored/.bazelrc +++ b/examples/pip_parse_vendored/.bazelrc @@ -5,5 +5,6 @@ build --enable_runfiles # Vendoring requirements.bzl files isn't necessary under bzlmod # When workspace support is dropped, this example can be removed. -build --noexperimental_enable_bzlmod -common:bazel7.x --incompatible_python_disallow_native_rules +common --noenable_bzlmod +common --enable_workspace +common --incompatible_python_disallow_native_rules diff --git a/examples/pip_repository_annotations/.bazelrc b/examples/pip_repository_annotations/.bazelrc index d893227946..c16c5a24f2 100644 --- a/examples/pip_repository_annotations/.bazelrc +++ b/examples/pip_repository_annotations/.bazelrc @@ -3,5 +3,6 @@ try-import %workspace%/user.bazelrc # This example is WORKSPACE specific. The equivalent functionality # is in examples/bzlmod as the `whl_mods` feature. -build --experimental_enable_bzlmod=false --enable_workspace=true -common:bazel7.x --incompatible_python_disallow_native_rules +common --noenable_bzlmod +common --enable_workspace +common --incompatible_python_disallow_native_rules diff --git a/examples/py_proto_library/.bazelrc b/examples/py_proto_library/.bazelrc index d73fc5387a..2ed86f591e 100644 --- a/examples/py_proto_library/.bazelrc +++ b/examples/py_proto_library/.bazelrc @@ -1,3 +1,4 @@ # The equivalent bzlmod behavior is covered by examples/bzlmod/py_proto_library -common --noenable_bzlmod --enable_workspace=true -common:bazel7.x --incompatible_python_disallow_native_rules +common --noenable_bzlmod +common --enable_workspace +common --incompatible_python_disallow_native_rules diff --git a/internal_dev_deps.bzl b/internal_dev_deps.bzl index e76ee48e83..0304fb16b7 100644 --- a/internal_dev_deps.bzl +++ b/internal_dev_deps.bzl @@ -195,10 +195,9 @@ def rules_python_internal_deps(): http_archive( name = "rules_java", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_java/releases/download/8.3.1/rules_java-8.3.1.tar.gz", - "https://github.com/bazelbuild/rules_java/releases/download/8.3.1/rules_java-8.3.1.tar.gz", + "https://github.com/bazelbuild/rules_java/releases/download/8.6.2/rules_java-8.6.2.tar.gz", ], - sha256 = "ee786b943e00da4fea7c233e70e5f5b8a01cc69b9341b3f49169f174fe0df1c5", + sha256 = "a64ab04616e76a448c2c2d8165d836f0d2fb0906200d0b7c7376f46dd62e59cc", ) RULES_JVM_EXTERNAL_TAG = "5.2" diff --git a/internal_dev_setup.bzl b/internal_dev_setup.bzl index d6e95e22ce..fc38e3f9c5 100644 --- a/internal_dev_setup.bzl +++ b/internal_dev_setup.bzl @@ -20,7 +20,6 @@ load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies") load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies") load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries") -load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains") load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS") load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS") @@ -47,9 +46,6 @@ def rules_python_internal_setup(): protobuf_deps() - rules_java_dependencies() - rules_java_toolchains() - bazel_integration_test_rules_dependencies() bazel_starlib_dependencies() bazel_binaries(versions = SUPPORTED_BAZEL_VERSIONS) diff --git a/python/BUILD.bazel b/python/BUILD.bazel index 3422ef14fa..b747e2fbc7 100644 --- a/python/BUILD.bazel +++ b/python/BUILD.bazel @@ -43,6 +43,7 @@ filegroup( "//python/pip_install:distribution", "//python/private:distribution", "//python/runfiles:distribution", + "//python/runtime_env_toolchains:distribution", "//python/uv:distribution", ], visibility = ["//:__pkg__"], diff --git a/python/runtime_env_toolchains/BUILD.bazel b/python/runtime_env_toolchains/BUILD.bazel index 21355ac939..5001d12556 100644 --- a/python/runtime_env_toolchains/BUILD.bazel +++ b/python/runtime_env_toolchains/BUILD.bazel @@ -17,3 +17,9 @@ load("//python/private:runtime_env_toolchain.bzl", "define_runtime_env_toolchain package(default_visibility = ["//:__subpackages__"]) define_runtime_env_toolchain(name = "runtime_env_toolchain") + +filegroup( + name = "distribution", + srcs = glob(["**"]), + visibility = ["//python:__pkg__"], +) diff --git a/tests/integration/BUILD.bazel b/tests/integration/BUILD.bazel index 289c85d38a..d178e0f01c 100644 --- a/tests/integration/BUILD.bazel +++ b/tests/integration/BUILD.bazel @@ -19,11 +19,8 @@ load(":integration_test.bzl", "rules_python_integration_test") licenses(["notice"]) -_LEGACY_WORKSPACE_FLAGS = [ +_WORKSPACE_FLAGS = [ "--noenable_bzlmod", -] - -_WORKSPACE_FLAGS = _LEGACY_WORKSPACE_FLAGS + [ "--enable_workspace", ] @@ -35,24 +32,6 @@ _GAZELLE_PLUGIN_FLAGS = [ "--override_module=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin", ] -default_test_runner( - name = "bazel_6_4_workspace_test_runner", - bazel_cmds = [ - "info {}".format(" ".join(_LEGACY_WORKSPACE_FLAGS)), - "test {} //...".format(" ".join(_LEGACY_WORKSPACE_FLAGS)), - ], - visibility = ["//visibility:public"], -) - -default_test_runner( - name = "bazel_6_4_workspace_test_runner_gazelle_plugin", - bazel_cmds = [ - "info {}".format(" ".join(_LEGACY_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)), - "test {} //...".format(" ".join(_LEGACY_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)), - ], - visibility = ["//visibility:public"], -) - default_test_runner( name = "workspace_test_runner", bazel_cmds = [ diff --git a/version.bzl b/version.bzl index 61fb81efd4..4d85b5c420 100644 --- a/version.bzl +++ b/version.bzl @@ -17,11 +17,11 @@ # against. # This version should be updated together with the version of Bazel # in .bazelversion. -BAZEL_VERSION = "7.x" +BAZEL_VERSION = "8.x" # NOTE: Keep in sync with .bazelci/presubmit.yml # This is the minimum supported bazel version, that we have some tests for. -MINIMUM_BAZEL_VERSION = "6.4.0" +MINIMUM_BAZEL_VERSION = "7.4.1" # Versions of Bazel which users should be able to use. # Ensures we don't break backwards-compatibility,