I've implemented a custom Bazel test rule. The test executable pulls a Docker image from a local registry. That image can be pushed to the local registry using oci_push
. So, in order to make sure the image is always up-to-date, I have to manually push it before running the test each time. It's a two-step process, sort-of like this:
bazel run //image:push-local
bazel test //tests:test
The first step is annoying and easily fettable. I'd like to make it so that running bazel test //tests:test
always pushes the up-to-date image first, then executes the test which pulls that image. I can't figure out how to do it.
I tried adding a prerequisite
attribute to the custom test rule, which gets handled in the implementation like this:
ctx.actions.run(
executable = ctx.attr.prerequisite[DefaultInfo].files_to_run,
outputs = [],
)
But that fails:
Error in run: param 'outputs' may not be empty
Well, there aren't any outputs. The oci_push
rule just returns an executable.
Is there some way to express to Bazel "you should always run this executable rule before running this test"?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742321087a4421822.html
评论列表(0条)