treewide: clean up test static binary targets
This removes some intermediate targets only used for transitions by
consolidating them into a single one.
Change-Id: I46dcbcb731038edd2b67259de1811018f5ba43da
Reviewed-on: https://review.monogon.dev/c/monogon/+/3753
Reviewed-by: Leopold Schabel <leo@monogon.tech>
Tested-by: Jenkins CI
Vouch-Run-CI: Tim Windelschmidt <tim@monogon.tech>
diff --git a/cloud/agent/takeover/BUILD.bazel b/cloud/agent/takeover/BUILD.bazel
index 63747a9..2b28464 100644
--- a/cloud/agent/takeover/BUILD.bazel
+++ b/cloud/agent/takeover/BUILD.bazel
@@ -1,3 +1,4 @@
+load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("//build/static_binary_tarball:def.bzl", "static_binary_tarball")
load("//osbase/build:def.bzl", "node_initramfs")
@@ -26,6 +27,27 @@
],
)
+go_binary(
+ name = "takeover_bin",
+ embed = [":takeover_lib"],
+ visibility = ["//visibility:private"],
+)
+
+# Used by e2e tests, forces a static build
+platform_transition_binary(
+ name = "takeover",
+ binary = ":takeover_bin",
+ target_platform = "//build/platforms:linux_amd64_static",
+ visibility = ["//visibility:public"],
+)
+
+# Used by container_images, forces a static build
+static_binary_tarball(
+ name = "takeover_layer",
+ executable = ":takeover_bin",
+ visibility = ["//visibility:public"],
+)
+
node_initramfs(
name = "initramfs",
files = {
@@ -39,16 +61,3 @@
],
visibility = ["//cloud/agent:__subpackages__"],
)
-
-go_binary(
- name = "takeover",
- embed = [":takeover_lib"],
- visibility = ["//visibility:public"],
-)
-
-# Used by container_images, forces a static build of the test_agent.
-static_binary_tarball(
- name = "takeover_layer",
- executable = ":takeover",
- visibility = ["//visibility:public"],
-)
diff --git a/cloud/agent/takeover/e2e/BUILD.bazel b/cloud/agent/takeover/e2e/BUILD.bazel
index 7259fc5..3ca92ee 100644
--- a/cloud/agent/takeover/e2e/BUILD.bazel
+++ b/cloud/agent/takeover/e2e/BUILD.bazel
@@ -4,6 +4,7 @@
name = "e2e_test",
srcs = ["main_test.go"],
data = [
+ # We use the layer instead of the binary to not add a transition target
"//cloud/agent/takeover",
"//third_party/edk2:OVMF_CODE.fd",
"//third_party/edk2:OVMF_VARS.fd",
@@ -13,7 +14,8 @@
"xCloudImagePath": "$(rlocationpath @debian_11_cloudimage//file )",
"xOvmfVarsPath": "$(rlocationpath //third_party/edk2:OVMF_VARS.fd )",
"xOvmfCodePath": "$(rlocationpath //third_party/edk2:OVMF_CODE.fd )",
- "xTakeoverPath": "$(rlocationpath //cloud/agent/takeover )",
+ # TODO(tim): Hardcoded because of https://github.com/monogon-dev/monogon/issues/316
+ "xTakeoverPath": "_main/cloud/agent/takeover/takeover_bin_/takeover_bin",
},
deps = [
"//cloud/agent/api",
diff --git a/cloud/agent/takeover/e2e/main_test.go b/cloud/agent/takeover/e2e/main_test.go
index 0521cc9..b141e63 100644
--- a/cloud/agent/takeover/e2e/main_test.go
+++ b/cloud/agent/takeover/e2e/main_test.go
@@ -174,6 +174,7 @@
t.Fatal(err)
}
defer takeoverSrcFile.Close()
+
if _, err := io.Copy(takeoverFile, takeoverSrcFile); err != nil {
t.Fatal(err)
}
diff --git a/metropolis/node/kubernetes/pause/BUILD.bazel b/metropolis/node/kubernetes/pause/BUILD.bazel
index 9bf992d..aa0c754 100644
--- a/metropolis/node/kubernetes/pause/BUILD.bazel
+++ b/metropolis/node/kubernetes/pause/BUILD.bazel
@@ -1,3 +1,6 @@
+load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
+load("//build/static_binary_tarball:def.bzl", "static_binary_tarball")
+
cc_binary(
name = "pause",
srcs = [
@@ -8,29 +11,16 @@
],
)
-load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
-
-platform_transition_binary(
- name = "pause_transitioned",
- binary = ":pause",
- target_platform = "//build/platforms:linux_amd64_static",
- visibility = ["//visibility:private"],
-)
-
-load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-
-pkg_tar(
+static_binary_tarball(
name = "pause_layer",
- srcs = [":pause_transitioned"],
+ executable = ":pause",
visibility = ["//visibility:private"],
)
-load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
-
oci_image(
name = "pause_image",
architecture = "amd64",
- entrypoint = ["/pause"],
+ entrypoint = ["/app/metropolis/node/kubernetes/pause/pause"],
os = "linux",
tars = [":pause_layer"],
visibility = ["//visibility:public"],
diff --git a/metropolis/test/e2e/httpserver/BUILD.bazel b/metropolis/test/e2e/httpserver/BUILD.bazel
index 5d60598..9370eeb 100644
--- a/metropolis/test/e2e/httpserver/BUILD.bazel
+++ b/metropolis/test/e2e/httpserver/BUILD.bazel
@@ -1,5 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
-load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
+load("@rules_oci//oci:defs.bzl", "oci_image")
+load("//build/static_binary_tarball:def.bzl", "static_binary_tarball")
go_library(
name = "httpserver_lib",
@@ -15,27 +16,16 @@
visibility = ["//visibility:private"],
)
-platform_transition_binary(
- name = "httpserver_transitioned",
- binary = ":httpserver",
- target_platform = "//build/platforms:linux_amd64_static",
- visibility = ["//visibility:private"],
-)
-
-load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-
-pkg_tar(
+static_binary_tarball(
name = "httpserver_layer",
- srcs = [":httpserver_transitioned"],
+ executable = ":httpserver",
visibility = ["//visibility:private"],
)
-load("@rules_oci//oci:defs.bzl", "oci_image")
-
oci_image(
name = "httpserver_image",
base = "@distroless_base",
- entrypoint = ["/httpserver"],
+ entrypoint = ["/app/metropolis/test/e2e/httpserver/httpserver_/httpserver"],
tars = [":httpserver_layer"],
visibility = ["//metropolis/test/e2e:__pkg__"],
workdir = "/app",
diff --git a/metropolis/test/e2e/persistentvolume/BUILD.bazel b/metropolis/test/e2e/persistentvolume/BUILD.bazel
index e98f630..cf0917e 100644
--- a/metropolis/test/e2e/persistentvolume/BUILD.bazel
+++ b/metropolis/test/e2e/persistentvolume/BUILD.bazel
@@ -1,4 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
+load("@rules_oci//oci:defs.bzl", "oci_image")
+load("//build/static_binary_tarball:def.bzl", "static_binary_tarball")
go_library(
name = "persistentvolume_lib",
@@ -18,29 +20,16 @@
visibility = ["//visibility:private"],
)
-load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
-
-platform_transition_binary(
- name = "persistentvolume_transitioned",
- binary = ":persistentvolume",
- target_platform = "//build/platforms:linux_amd64_static",
- visibility = ["//visibility:private"],
-)
-
-load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-
-pkg_tar(
+static_binary_tarball(
name = "persistentvolume_layer",
- srcs = [":persistentvolume_transitioned"],
+ executable = ":persistentvolume",
visibility = ["//visibility:private"],
)
-load("@rules_oci//oci:defs.bzl", "oci_image")
-
oci_image(
name = "persistentvolume_image",
base = "@distroless_base",
- entrypoint = ["/persistentvolume"],
+ entrypoint = ["/app/metropolis/test/e2e/persistentvolume/persistentvolume_/persistentvolume"],
tars = [":persistentvolume_layer"],
visibility = ["//metropolis/test/e2e:__pkg__"],
workdir = "/app",
diff --git a/metropolis/test/e2e/preseedtest/BUILD.bazel b/metropolis/test/e2e/preseedtest/BUILD.bazel
index fe9fda9..68f5717 100644
--- a/metropolis/test/e2e/preseedtest/BUILD.bazel
+++ b/metropolis/test/e2e/preseedtest/BUILD.bazel
@@ -1,4 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
+load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
+load("//build/static_binary_tarball:def.bzl", "static_binary_tarball")
go_library(
name = "preseedtest_lib",
@@ -14,29 +16,16 @@
visibility = ["//visibility:private"],
)
-load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
-
-platform_transition_binary(
- name = "preseedtest_transitioned",
- binary = ":preseedtest",
- target_platform = "//build/platforms:linux_amd64_static",
- visibility = ["//visibility:private"],
-)
-
-load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-
-pkg_tar(
+static_binary_tarball(
name = "preseedtest_layer",
- srcs = [":preseedtest_transitioned"],
+ executable = ":preseedtest",
visibility = ["//visibility:private"],
)
-load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
-
oci_image(
name = "preseedtest_image",
base = "@distroless_base",
- entrypoint = ["/preseedtest"],
+ entrypoint = ["/app/metropolis/test/e2e/preseedtest/preseedtest_/preseedtest"],
tars = [":preseedtest_layer"],
visibility = ["//visibility:private"],
workdir = "/app",
diff --git a/metropolis/test/e2e/selftest/BUILD.bazel b/metropolis/test/e2e/selftest/BUILD.bazel
index 0990150..23445a0 100644
--- a/metropolis/test/e2e/selftest/BUILD.bazel
+++ b/metropolis/test/e2e/selftest/BUILD.bazel
@@ -1,4 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
+load("@rules_oci//oci:defs.bzl", "oci_image")
+load("//build/static_binary_tarball:def.bzl", "static_binary_tarball")
go_library(
name = "selftest_lib",
@@ -14,29 +16,16 @@
visibility = ["//visibility:private"],
)
-load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
-
-platform_transition_binary(
- name = "selftest_transitioned",
- binary = ":selftest",
- target_platform = "//build/platforms:linux_amd64_static",
- visibility = ["//visibility:private"],
-)
-
-load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-
-pkg_tar(
+static_binary_tarball(
name = "selftest_layer",
- srcs = [":selftest_transitioned"],
+ executable = ":selftest",
visibility = ["//visibility:private"],
)
-load("@rules_oci//oci:defs.bzl", "oci_image")
-
oci_image(
name = "selftest_image",
base = "@distroless_base",
- entrypoint = ["/selftest"],
+ entrypoint = ["/app/metropolis/test/e2e/selftest/selftest_/selftest"],
tars = [":selftest_layer"],
visibility = ["//metropolis/test/e2e:__pkg__"],
workdir = "/app",
diff --git a/metropolis/test/e2e/suites/ha_cold/BUILD.bazel b/metropolis/test/e2e/suites/ha_cold/BUILD.bazel
index d3370d0..a70ee55 100644
--- a/metropolis/test/e2e/suites/ha_cold/BUILD.bazel
+++ b/metropolis/test/e2e/suites/ha_cold/BUILD.bazel
@@ -3,11 +3,6 @@
go_test(
name = "ha_cold_test",
srcs = ["run_test.go"],
- data = [
- "//metropolis/node:image",
- "//metropolis/test/e2e:testimages_manifest",
- "//third_party/edk2:firmware",
- ],
tags = [
"resources:iops:5000",
"resources:cpu:3",
diff --git a/metropolis/test/launch/cli/launch/BUILD.bazel b/metropolis/test/launch/cli/launch/BUILD.bazel
index f0edefc..038373f 100644
--- a/metropolis/test/launch/cli/launch/BUILD.bazel
+++ b/metropolis/test/launch/cli/launch/BUILD.bazel
@@ -1,5 +1,5 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@bazel_skylib//rules:native_binary.bzl", "native_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "launch_lib",
@@ -15,10 +15,6 @@
go_binary(
name = "launch",
- data = [
- "//metropolis/node:image",
- "//third_party/edk2:firmware",
- ],
embed = [":launch_lib"],
visibility = ["//visibility:public"],
)