Switch to calling the image as a binary, instead of "docker loading" it manually.
def _impl(ctx):
ext_run_location = ctx.executable._structure_test.short_path
- tar_location = ctx.attr.image.files.to_list()[0].short_path
config_location = ctx.file.config.short_path
+ load_location = ctx.executable.image.short_path
# docker_build rules always generate an image named 'bazel/$package:$name'.
image_name = "bazel/%s:%s" % (ctx.attr.image.label.package, ctx.attr.image.label.name)
@@ -25,10 +25,14 @@ def _impl(ctx):
# Generate a shell script to execute ext_run with the correct flags.
test_contents = """\
#!/bin/bash
+set -ex
+# Execute the image loader script.
+%s
+
+# Run the tests.
%s \
-i %s \
- -t %s \
- -c %s""" % (ext_run_location, image_name, tar_location, config_location)
+ -c %s""" % (load_location, ext_run_location, image_name, config_location)
ctx.file_action(
output=ctx.outputs.executable,
content=test_contents
@@ -36,9 +40,12 @@ def _impl(ctx):
return struct(runfiles=ctx.runfiles(files = [
ctx.executable._structure_test,
+ ctx.executable.image,
ctx.file.config] +
- ctx.attr.image.files.to_list(),
- ))
+ ctx.attr.image.files.to_list() +
+ ctx.attr.image.data_runfiles.files.to_list()
+ ),
+ )
structure_test = rule(
attrs = {
@@ -50,6 +57,8 @@ structure_test = rule(
),
"image": attr.label(
mandatory = True,
+ executable = True,
+ cfg = "target",
),
"config": attr.label(
mandatory = True,
