Skip to content

Commit

Permalink
fix: provider name should not be only set to cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
opicaud committed Jan 5, 2024
1 parent 6047706 commit d79c701
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions private/pact/pact_test.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//private:provider.bzl", "SideCarInfo", "ContractInfo")
load("//private:provider.bzl", "SideCarInfo", "ContractInfo", "ProviderInfo")

def pact_test(**kwargs):
_consumer = kwargs["consumer"]
Expand All @@ -23,6 +23,8 @@ def _impl(ctx):
dict.update({p.basename: p.short_path})
if ctx.attr.provider[SideCarInfo].file == p.basename:
dict.update({ctx.attr.provider[SideCarInfo].file: p.short_path})
if ctx.attr.provider[ProviderInfo].file == p.basename:
dict.update({ctx.attr.provider[SideCarInfo].file: p.short_path})
dict.update({"contract": ctx.attr.consumer[ContractInfo].name + "-" + ctx.attr.provider[ContractInfo].name})
ctx.actions.expand_template(
template = ctx.file._script,
Expand All @@ -36,7 +38,7 @@ def _impl(ctx):
"{pact_verifier_cli}": pact_reference.pact_verifier_cli.short_path,
"{pact_verifier_cli_opts}": dict.setdefault("cli_args", "nop"),
"{side_car_opts}": dict.setdefault("side_car_cli_args", "nop"),
"{provider_bin}": dict.setdefault("cmd", "nop"),
"{provider_bin}": dict.setdefault(ctx.attr.provider[ProviderInfo].file, "nop"),
"{side_car_bin}": dict.setdefault(ctx.attr.provider[SideCarInfo].file, "nop"),
"{env_side_car}": dict.setdefault("env_side_car","nop"),
"{health_check_side_car}": dict.setdefault("health_check_side_car", "nop"),
Expand Down
5 changes: 4 additions & 1 deletion private/pact/provider.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//private:provider.bzl", "SideCarInfo", "ContractInfo")
load("//private:provider.bzl", "SideCarInfo", "ContractInfo", "ProviderInfo")

def _provider_impl(ctx):
args = ctx.actions.args()
Expand All @@ -11,15 +11,18 @@ def _provider_impl(ctx):
ctx.attr.srcs[DefaultInfo].default_runfiles.files.to_list()
)


if ctx.attr.deps == []:
return [DefaultInfo(runfiles = runfiles),
ProviderInfo(file = ctx.attr.srcs[DefaultInfo].files_to_run.executable.basename),
SideCarInfo(file = "nop"),
ContractInfo(name = ctx.attr.name)]

for dep in ctx.attr.deps:
runfiles = runfiles.merge(dep[DefaultInfo].default_runfiles)

return [DefaultInfo(runfiles = runfiles),
ProviderInfo(file = ctx.attr.srcs[DefaultInfo].files_to_run.executable.basename),
SideCarInfo(file = dep[SideCarInfo].file),
ContractInfo(name = ctx.attr.name)]
provider = rule(
Expand Down
1 change: 1 addition & 0 deletions private/provider.bzl
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SideCarInfo = provider("file")
ContractInfo = provider("name")
ProviderInfo = provider("file")

0 comments on commit d79c701

Please sign in to comment.