Skip to content

Initial preparations for adding rules_docker_compose_test to BCR #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --lockfile_mode=off
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.0
7.4.1
18 changes: 18 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docker_compose_test/docker_compose_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions examples/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
common --test_output=errors
common --verbose_explanations
common --lockfile_mode=off
2 changes: 1 addition & 1 deletion examples/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.0
7.4.1
53 changes: 53 additions & 0 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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")
75 changes: 0 additions & 75 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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")
11 changes: 1 addition & 10 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Loading