def run_koji_build_report_handler(event: dict, package_config: dict, job_config: dict): handler = KojiBuildReportHandler( package_config=load_package_config(package_config), job_config=load_job_config(job_config), data=EventData.from_event_dict(event), koji_event=KojiBuildEvent.from_event_dict(event), ) return get_handlers_task_results(handler.run_job(), event)
def parse_koji_event(event) -> Optional[KojiBuildEvent]: if event.get("topic" ) != "org.fedoraproject.prod.buildsys.task.state.change": return None build_id = event.get("id") logger.info(f"Koji event: build_id={build_id}") state = nested_get(event, "info", "state") if not state: logger.debug("Cannot find build state.") return None state_enum = KojiBuildState( event.get("new")) if "new" in event else None old_state = KojiBuildState( event.get("old")) if "old" in event else None start_time = nested_get(event, "info", "start_time") completion_time = nested_get(event, "info", "completion_time") rpm_build_task_id = None for children in nested_get(event, "info", "children", default=[]): if children.get("method") == "buildArch": rpm_build_task_id = children.get("id") break return KojiBuildEvent( build_id=build_id, state=state_enum, old_state=old_state, start_time=start_time, completion_time=completion_time, rpm_build_task_id=rpm_build_task_id, )
def test_get_koji_rpm_build_web_url(id_, result): event = KojiBuildEvent(build_id=flexmock(), state=flexmock(), rpm_build_task_id=id_) assert event.get_koji_rpm_build_web_url() == result