From b199ebaf154abf60a3d21169062c33419d315a72 Mon Sep 17 00:00:00 2001 From: Michael Plump Date: Tue, 10 Dec 2024 09:07:48 -0500 Subject: [PATCH] test: Fix the Bazel integration test. (#9604) Bazel just released version 8.0.0 which uses a MODULE.bazel file instead of a WORKSPACE file. See https://bazel.build/external/migration I also updated to a new version of rules_oci that supports this new MODULE.bazel. --- integration/testdata/bazel-rules-oci/BUILD | 12 ++++++-- .../testdata/bazel-rules-oci/MODULE.bazel | 13 ++++++++ .../testdata/bazel-rules-oci/WORKSPACE | 30 ------------------- .../testdata/bazel-rules-oci/sub-dir/BUILD | 14 ++++++--- 4 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 integration/testdata/bazel-rules-oci/MODULE.bazel delete mode 100644 integration/testdata/bazel-rules-oci/WORKSPACE diff --git a/integration/testdata/bazel-rules-oci/BUILD b/integration/testdata/bazel-rules-oci/BUILD index 821f8c599d9..5abab2d3de8 100644 --- a/integration/testdata/bazel-rules-oci/BUILD +++ b/integration/testdata/bazel-rules-oci/BUILD @@ -1,7 +1,13 @@ -load("@rules_oci//oci:defs.bzl", "oci_tarball") +load("@rules_oci//oci:defs.bzl", "oci_load") -oci_tarball( - name = "hello.tar", +oci_load( + name = "hello", image = "@hello//:hello", repo_tags = ["hello:latest"], ) + +filegroup( + name = "hello.tar", + srcs = [":hello"], + output_group = "tarball", +) diff --git a/integration/testdata/bazel-rules-oci/MODULE.bazel b/integration/testdata/bazel-rules-oci/MODULE.bazel new file mode 100644 index 00000000000..0990fef854e --- /dev/null +++ b/integration/testdata/bazel-rules-oci/MODULE.bazel @@ -0,0 +1,13 @@ +bazel_dep(name = "rules_oci", version = "2.0.1") + +oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") + +# Declare external images you need to pull, for example: +oci.pull( + name = "hello", + digest = "sha256:b510f29de2dfd80b88f7cd569db177a514117081bc8825eb64e423bd3db0fe64", + image = "us-docker.pkg.dev/google-samples/containers/gke/hello-app", +) + +# For each oci.pull call, repeat the "name" here to expose them as dependencies. +use_repo(oci, "hello") diff --git a/integration/testdata/bazel-rules-oci/WORKSPACE b/integration/testdata/bazel-rules-oci/WORKSPACE deleted file mode 100644 index 07e22a13b7b..00000000000 --- a/integration/testdata/bazel-rules-oci/WORKSPACE +++ /dev/null @@ -1,30 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "rules_oci", - sha256 = "db57efd706f01eb3ce771468366baa1614b5b25f4cce99757e2b8d942155b8ec", - strip_prefix = "rules_oci-1.0.0", - url = "https://github.com/bazel-contrib/rules_oci/releases/download/v1.0.0/rules_oci-v1.0.0.tar.gz", -) - -load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies") - -rules_oci_dependencies() - -load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "LATEST_ZOT_VERSION", "oci_register_toolchains") - -oci_register_toolchains( - name = "oci", - crane_version = LATEST_CRANE_VERSION, - # Uncommenting the zot toolchain will cause it to be used instead of crane for some tasks. - # Note that it does not support docker-format images. - # zot_version = LATEST_ZOT_VERSION, -) - -load("@rules_oci//oci:pull.bzl", "oci_pull") - -oci_pull( - name = "hello", - digest = "sha256:845f77fab71033404f4cfceaa1ddb27b70c3551ceb22a5e7f4498cdda6c9daea", - image = "us-docker.pkg.dev/google-samples/containers/gke/hello-app", -) diff --git a/integration/testdata/bazel-rules-oci/sub-dir/BUILD b/integration/testdata/bazel-rules-oci/sub-dir/BUILD index 14dd5caba2d..5abab2d3de8 100644 --- a/integration/testdata/bazel-rules-oci/sub-dir/BUILD +++ b/integration/testdata/bazel-rules-oci/sub-dir/BUILD @@ -1,7 +1,13 @@ -load("@rules_oci//oci:defs.bzl", "oci_tarball") +load("@rules_oci//oci:defs.bzl", "oci_load") -oci_tarball( - name = "hello.tar", +oci_load( + name = "hello", image = "@hello//:hello", - repo_tags = ["hello-whatever:latest"], + repo_tags = ["hello:latest"], +) + +filegroup( + name = "hello.tar", + srcs = [":hello"], + output_group = "tarball", )