Skip to content

Emit statuses for effects #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildbot_effects/buildbot_effects/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def run_command(args: argparse.Namespace, options: EffectsOptions) -> None:
drv = next(iter(drvs.values()))

secrets = json.loads(options.secrets.read_text()) if options.secrets else {}
run_effects(drv_path, drv, secrets=secrets)
run_effects(drv_path, drv, secrets=secrets, debug=args.debug)


def run_all_command(args: argparse.Namespace, options: EffectsOptions) -> None:
Expand Down
15 changes: 15 additions & 0 deletions buildbot_nix/buildbot_nix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ def __init__(
**kwargs,
)

async def run(self) -> int: # type: ignore[override]
if self.build:
await CombinedBuildEvent.produce_event_for_build(
self.master, CombinedBuildEvent.STARTED_NIX_EFFECTS, self.build, None
)

results = await super().run()

if self.build:
await CombinedBuildEvent.produce_event_for_build(
self.master, CombinedBuildEvent.FINISHED_NIX_EFFECTS, self.build, None
)

return results

def createTriggerProperties(self, props: Any) -> Any: # noqa: N802
return props

Expand Down
13 changes: 13 additions & 0 deletions buildbot_nix/buildbot_nix/nix_status_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class CombinedBuildEvent(Enum):
FINISHED_NIX_EVAL = "finished-nix-eval"
STARTED_NIX_BUILD = "started-nix-build"
FINISHED_NIX_BUILD = "finished-nix-build"
STARTED_NIX_EFFECTS = "started-nix-effects"
FINISHED_NIX_EFFECTS = "finished-nix-effects"

@staticmethod
async def produce_event_for_build_requests_by_id(
Expand Down Expand Up @@ -88,6 +90,8 @@ class BuildNixEvalStatusGenerator(BuildStatusGeneratorMixin):
("builds", None, str(CombinedBuildEvent.FINISHED_NIX_EVAL.name)),
("builds", None, str(CombinedBuildEvent.STARTED_NIX_BUILD.name)),
("builds", None, str(CombinedBuildEvent.FINISHED_NIX_BUILD.name)),
("builds", None, str(CombinedBuildEvent.STARTED_NIX_EFFECTS.name)),
("builds", None, str(CombinedBuildEvent.FINISHED_NIX_EFFECTS.name)),
("buildrequests", None, str(CombinedBuildEvent.STARTED_NIX_BUILD.name)),
("buildrequests", None, str(CombinedBuildEvent.FINISHED_NIX_BUILD.name)),
]
Expand Down Expand Up @@ -223,6 +227,14 @@ async def generate(
"nix-build",
"generator",
)
case (
CombinedBuildEvent.STARTED_NIX_EFFECTS
| CombinedBuildEvent.FINISHED_NIX_EFFECTS
):
report["builds"][0]["properties"]["status_name"] = (
"nix-effects",
"generator",
)
case _:
msg = f"Unexpected event: {event_typed}"
raise ValueError(msg)
Expand All @@ -231,6 +243,7 @@ async def generate(
case (
CombinedBuildEvent.FINISHED_NIX_EVAL
| CombinedBuildEvent.FINISHED_NIX_BUILD
| CombinedBuildEvent.FINISHED_NIX_EFFECTS
):
report["builds"][0]["complete"] = True
report["builds"][0]["complete_at"] = datetime.now(tz=UTC)
Expand Down