Skip to content

Commit b36223c

Browse files
committed
Fix GitHub status not updating to pending before evaluation
The status generator wasn't catching STARTED events because of confusion between enum names (STARTED_NIX_EVAL) and values (started-nix-eval). Events were produced with one format but the generator expected another, so GitHub never received the pending status when evaluation started. Standardized on using enum.value throughout for consistency with how Buildbot's event system works.
1 parent 2156e1f commit b36223c

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

buildbot_nix/buildbot_nix/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ def __init__(
101101
)
102102

103103
async def run(self) -> int: # type: ignore[override]
104-
if self.build:
104+
if self.build and self.master:
105105
await CombinedBuildEvent.produce_event_for_build(
106106
self.master, CombinedBuildEvent.STARTED_NIX_EFFECTS, self.build, None
107107
)
108108

109109
results = await super().run()
110110

111-
if self.build:
111+
if self.build and self.master:
112112
await CombinedBuildEvent.produce_event_for_build(
113113
self.master, CombinedBuildEvent.FINISHED_NIX_EFFECTS, self.build, None
114114
)
@@ -176,9 +176,8 @@ async def produce_event(self, event: str, result: None | int) -> None:
176176
)
177177
if result is not None:
178178
build["results"] = result
179-
self.master.mq.produce(
180-
("builds", str(self.build.buildid), event), copy.deepcopy(build)
181-
)
179+
event_key = ("builds", str(self.build.buildid), event)
180+
self.master.mq.produce(event_key, copy.deepcopy(build))
182181

183182
async def run(self) -> int:
184183
await self.produce_event(CombinedBuildEvent.STARTED_NIX_EVAL.value, None)

buildbot_nix/buildbot_nix/nix_status_generator.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,26 @@ async def produce_event_for_build(
7272
build_db: Any = await master.data.get(("builds", str(build.buildid)))
7373
if result is not None:
7474
build_db["results"] = result
75-
master.mq.produce(
76-
("builds", str(build.buildid), event.name), copy.deepcopy(build_db)
77-
)
75+
event_key = ("builds", str(build.buildid), event.value)
76+
master.mq.produce(event_key, copy.deepcopy(build_db))
7877
elif isinstance(build, dict):
7978
if result is not None:
8079
build["results"] = result
81-
master.mq.produce(
82-
("builds", str(build["buildid"]), event.name), copy.deepcopy(build)
83-
)
80+
event_key = ("builds", str(build["buildid"]), event.value)
81+
master.mq.produce(event_key, copy.deepcopy(build))
8482

8583

8684
@implementer(IReportGenerator)
8785
class BuildNixEvalStatusGenerator(BuildStatusGeneratorMixin):
8886
wanted_event_keys: ClassVar[list[Any]] = [
89-
("builds", None, str(CombinedBuildEvent.STARTED_NIX_EVAL.name)),
90-
("builds", None, str(CombinedBuildEvent.FINISHED_NIX_EVAL.name)),
91-
("builds", None, str(CombinedBuildEvent.STARTED_NIX_BUILD.name)),
92-
("builds", None, str(CombinedBuildEvent.FINISHED_NIX_BUILD.name)),
93-
("builds", None, str(CombinedBuildEvent.STARTED_NIX_EFFECTS.name)),
94-
("builds", None, str(CombinedBuildEvent.FINISHED_NIX_EFFECTS.name)),
95-
("buildrequests", None, str(CombinedBuildEvent.STARTED_NIX_BUILD.name)),
96-
("buildrequests", None, str(CombinedBuildEvent.FINISHED_NIX_BUILD.name)),
87+
("builds", None, CombinedBuildEvent.STARTED_NIX_EVAL.value),
88+
("builds", None, CombinedBuildEvent.FINISHED_NIX_EVAL.value),
89+
("builds", None, CombinedBuildEvent.STARTED_NIX_BUILD.value),
90+
("builds", None, CombinedBuildEvent.FINISHED_NIX_BUILD.value),
91+
("builds", None, CombinedBuildEvent.STARTED_NIX_EFFECTS.value),
92+
("builds", None, CombinedBuildEvent.FINISHED_NIX_EFFECTS.value),
93+
("buildrequests", None, CombinedBuildEvent.STARTED_NIX_BUILD.value),
94+
("buildrequests", None, CombinedBuildEvent.FINISHED_NIX_BUILD.value),
9795
]
9896

9997
compare_attrs: ClassVar[list[str]] = ["start_formatter", "end_formatter"]
@@ -185,9 +183,14 @@ async def generate(
185183
) -> None | dict[str, Any]:
186184
what, _, event = key
187185
if what == "builds":
188-
is_new = event == "new"
186+
# Check if this is a start event
187+
is_start_event = event in [
188+
CombinedBuildEvent.STARTED_NIX_EVAL.value,
189+
CombinedBuildEvent.STARTED_NIX_BUILD.value,
190+
CombinedBuildEvent.STARTED_NIX_EFFECTS.value,
191+
]
189192

190-
formatter = self.start_formatter if is_new else self.end_formatter
193+
formatter = self.start_formatter if is_start_event else self.end_formatter
191194

192195
await getDetailsForBuild(
193196
master,
@@ -204,9 +207,8 @@ async def generate(
204207
report: dict[str, Any] = await self.build_message(
205208
formatter, master, reporter, data
206209
)
207-
208-
event_typed: CombinedBuildEvent = CombinedBuildEvent.__members__[event]
209-
match event_typed:
210+
event_type = CombinedBuildEvent(event)
211+
match event_type:
210212
case (
211213
CombinedBuildEvent.STARTED_NIX_EVAL
212214
| CombinedBuildEvent.FINISHED_NIX_EVAL
@@ -236,10 +238,10 @@ async def generate(
236238
"generator",
237239
)
238240
case _:
239-
msg = f"Unexpected event: {event_typed}"
241+
msg = f"Unexpected event: {event_type}"
240242
raise ValueError(msg)
241243

242-
match event_typed:
244+
match event_type:
243245
case (
244246
CombinedBuildEvent.FINISHED_NIX_EVAL
245247
| CombinedBuildEvent.FINISHED_NIX_BUILD

0 commit comments

Comments
 (0)