Pre-requisite action in custom Bazel rule - Stack Overflow

I've implemented a custom Bazel test rule. The test executable pulls a Docker image from a local r

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

相关推荐

  • Pre-requisite action in custom Bazel rule - Stack Overflow

    I've implemented a custom Bazel test rule. The test executable pulls a Docker image from a local r

    15小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信