From 4b27af30b08e5df7cab9449f0fcd843b853904c0 Mon Sep 17 00:00:00 2001 From: Kris Foster Date: Mon, 13 Jan 2025 11:48:31 +0000 Subject: [PATCH] initial prep for bcr --- .bazelrc | 1 + .bazelversion | 2 +- MODULE.bazel | 18 +++++ README.md | 2 +- docker_compose_test/docker_compose_test.bzl | 2 +- examples/.bazelrc | 1 + examples/.bazelversion | 2 +- examples/MODULE.bazel | 53 +++++++++++++++ examples/WORKSPACE | 75 --------------------- repositories.bzl | 11 +-- 10 files changed, 78 insertions(+), 89 deletions(-) create mode 100644 .bazelrc create mode 100644 MODULE.bazel create mode 100644 examples/MODULE.bazel diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..011eb53 --- /dev/null +++ b/.bazelrc @@ -0,0 +1 @@ +common --lockfile_mode=off diff --git a/.bazelversion b/.bazelversion index 19b860c..815da58 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.4.0 +7.4.1 diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..14e271e --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,18 @@ +# Copyright (c) 2025, Salesforce, Inc. +# SPDX-License-Identifier: Apache-2 + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bazel_dep(name = "rules_pkg", version = "0.10.1") +bazel_dep(name = "rules_oci", version = "2.2.0") +bazel_dep(name = "rules_go", version = "0.50.1") diff --git a/README.md b/README.md index 69de1de..04a9594 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ You can pass `javacopts` when building the uber junit test binary using `uber_ja ### go_docker_compose_test ``` -(cd examples && bazel test --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 go-test-image-test) +(cd examples && bazel test --platforms=@rules_go//go/toolchain:linux_amd64 go-test-image-test) ``` In this example, the test source files, dependencies and test image base are passed into the macro. The macro builds a binary containing the test source files and dependencies which are executed as part of the docker-compose test. diff --git a/docker_compose_test/docker_compose_test.bzl b/docker_compose_test/docker_compose_test.bzl index 13c57d5..89fd688 100644 --- a/docker_compose_test/docker_compose_test.bzl +++ b/docker_compose_test/docker_compose_test.bzl @@ -15,7 +15,7 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar") load("@repo_absolute_path//:build_root.bzl", "BUILD_WORKSPACE_DIRECTORY") -load("@io_bazel_rules_go//go:def.bzl", "go_test") +load("@rules_go//go:def.bzl", "go_test") load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load") common_tags = [ diff --git a/examples/.bazelrc b/examples/.bazelrc index 8b8c145..e97c450 100644 --- a/examples/.bazelrc +++ b/examples/.bazelrc @@ -1,2 +1,3 @@ common --test_output=errors common --verbose_explanations +common --lockfile_mode=off diff --git a/examples/.bazelversion b/examples/.bazelversion index 19b860c..815da58 100644 --- a/examples/.bazelversion +++ b/examples/.bazelversion @@ -1 +1 @@ -6.4.0 +7.4.1 diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel new file mode 100644 index 0000000..e3245db --- /dev/null +++ b/examples/MODULE.bazel @@ -0,0 +1,53 @@ +# Copyright (c) 2025, Salesforce, Inc. +# SPDX-License-Identifier: Apache-2 + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bazel_dep(name = "rules_oci", version = "2.2.0") +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_jvm_external", version = "6.2") +bazel_dep(name = "rules_go", version = "0.50.1") + +oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") +oci.pull( + name = "openjdk", + digest = "sha256:29c44ad7bb159a29a4458b74e8d37c1995cb8dc32abdd35e6d3e3d493e682d10", + image = "openjdk", + platforms = [ + "linux/amd64", + "linux/arm64/v8", + ], +) +oci.pull( + name = "ubuntu", + digest = "sha256:278628f08d4979fb9af9ead44277dbc9c92c2465922310916ad0c46ec9999295", + image = "ubuntu", + platforms = [ + "linux/amd64", + "linux/arm64/v8", + ], +) +use_repo(oci, "openjdk", "openjdk_linux_amd64", "openjdk_linux_arm64_v8", "ubuntu", "ubuntu_linux_amd64", "ubuntu_linux_arm64_v8") + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + artifacts = [ + "org.junit.jupiter:junit-jupiter-api:5.10.1", + "org.junit.platform:junit-platform-console-standalone:1.10.0", + ], + lock_file = "//:maven_install.json", + repositories = [ + "https://repo1.maven.org/maven2", + ], +) +use_repo(maven, "maven") diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 23a78fb..2adef29 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -13,89 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - local_repository( name="rules_docker_compose_test", path= "..", ) -http_archive( - name = "rules_oci", - sha256 = "1bd16e455278d523f01326e0c3964cd64d7840a7e99cdd6e2617e59f698f3504", - strip_prefix = "rules_oci-2.2.0", - url = "https://github.com/bazel-contrib/rules_oci/releases/download/v2.2.0/rules_oci-v2.2.0.tar.gz", -) - -RULES_JVM_EXTERNAL_TAG = "6.0" -RULES_JVM_EXTERNAL_SHA = "85fd6bad58ac76cc3a27c8e051e4255ff9ccd8c92ba879670d195622e7c0a9b7" - -http_archive( - name = "rules_jvm_external", - strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, - sha256 = RULES_JVM_EXTERNAL_SHA, - url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG) -) - -load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies") -rules_oci_dependencies() - -load("@rules_oci//oci:repositories.bzl", "oci_register_toolchains") -oci_register_toolchains(name = "oci") - -load("@rules_oci//oci:pull.bzl", "oci_pull") - -oci_pull( - name = "openjdk", - digest = "sha256:29c44ad7bb159a29a4458b74e8d37c1995cb8dc32abdd35e6d3e3d493e682d10", - image = "openjdk", - platforms = [ - "linux/amd64", - "linux/arm64/v8", - ], -) - -oci_pull( - name = "ubuntu", - digest = "sha256:278628f08d4979fb9af9ead44277dbc9c92c2465922310916ad0c46ec9999295", - image = "ubuntu", - platforms = [ - "linux/amd64", - "linux/arm64/v8", - ], -) - -load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") -rules_jvm_external_deps() - -load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") -rules_jvm_external_setup() - -load("@rules_jvm_external//:defs.bzl", "maven_install") - -# if the list of dependencies changes run: -# bazel run @unpinned_maven//:pin -maven_install( - artifacts = [ - "org.junit.jupiter:junit-jupiter-api:5.10.1", - "org.junit.platform:junit-platform-console-standalone:1.10.0", - ], - repositories = [ - "https://repo1.maven.org/maven2", - ], - maven_install_json = "//:maven_install.json", -) - -load("@maven//:defs.bzl", "pinned_maven_install") -pinned_maven_install() - load("@rules_docker_compose_test//:repositories.bzl", "rules_docker_compose_test_repositories") rules_docker_compose_test_repositories() load("@rules_docker_compose_test//:setup.bzl", "rules_docker_compose_test_dependencies", "repo_absolute_path") rules_docker_compose_test_dependencies() repo_absolute_path(name="repo_absolute_path") - -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") -go_rules_dependencies() -go_register_toolchains(version = "1.23.0") diff --git a/repositories.bzl b/repositories.bzl index 4538670..4557907 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -36,19 +36,10 @@ def rules_docker_compose_test_repositories(): ) http_archive( - name = "io_bazel_rules_go", + name = "rules_go", sha256 = "f4a9314518ca6acfa16cc4ab43b0b8ce1e4ea64b81c38d8a3772883f153346b8", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.50.1/rules_go-v0.50.1.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.50.1/rules_go-v0.50.1.zip", ], ) - - http_archive( - name = "platforms", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", - ], - sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", - )