feat: support Gerrit in Buildbot #1
|
@ -61,11 +61,11 @@ class BuildTrigger(steps.BuildStep):
|
|||
self,
|
||||
builds_scheduler: str,
|
||||
jobs: list[dict[str, Any]],
|
||||
drv_info: dict[str, Any],
|
||||
all_deps: dict[str, Any],
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
self.jobs = jobs
|
||||
self.drv_info = drv_info
|
||||
self.all_deps = all_deps
|
||||
self.config = None
|
||||
self.builds_scheduler = builds_scheduler
|
||||
self._result_list = []
|
||||
|
@ -159,20 +159,9 @@ class BuildTrigger(steps.BuildStep):
|
|||
build_props = self.build.getProperties()
|
||||
source = f"nix-eval-lix"
|
||||
|
||||
all_deps = dict()
|
||||
for drv, info in self.drv_info.items():
|
||||
all_deps[drv] = set(info.get("inputDrvs").keys())
|
||||
def closure_of(key, deps):
|
||||
r, size = set([key]), 0
|
||||
while len(r) != size:
|
||||
size = len(r)
|
||||
r.update(*[ deps[k] for k in r ])
|
||||
return r.difference([key])
|
||||
job_set = set(( drv for drv in ( job.get("drvPath") for job in self.jobs ) if drv ))
|
||||
all_deps = { k: list(closure_of(k, all_deps).intersection(job_set)) for k in job_set }
|
||||
builds_to_schedule = list(self.jobs)
|
||||
build_schedule_order = []
|
||||
sorter = graphlib.TopologicalSorter(all_deps)
|
||||
sorter = graphlib.TopologicalSorter(self.all_deps)
|
||||
for item in sorter.static_order():
|
||||
i = 0
|
||||
while i < len(builds_to_schedule):
|
||||
|
@ -191,7 +180,7 @@ class BuildTrigger(steps.BuildStep):
|
|||
print('Scheduling..')
|
||||
schedule_now = []
|
||||
for build in list(build_schedule_order):
|
||||
if all_deps.get(build.get("drvPath"), []) == []:
|
||||
if self.all_deps.get(build.get("drvPath"), []) == []:
|
||||
build_schedule_order.remove(build)
|
||||
schedule_now.append(build)
|
||||
if len(schedule_now) == 0:
|
||||
|
@ -238,7 +227,7 @@ class BuildTrigger(steps.BuildStep):
|
|||
while True:
|
||||
old_paths = list(failed_paths)
|
||||
for build in list(build_schedule_order):
|
||||
deps = all_deps.get(build.get("drvPath"), [])
|
||||
deps = self.all_deps.get(build.get("drvPath"), [])
|
||||
for path in old_paths:
|
||||
if path in deps:
|
||||
failed_checks.append(build)
|
||||
|
@ -252,9 +241,9 @@ class BuildTrigger(steps.BuildStep):
|
|||
print(' Removed jobs: ' + ', '.join(removed))
|
||||
all_results = worst_status(result, all_results)
|
||||
print(f' New result: {util.Results[all_results].upper()}')
|
||||
for dep in all_deps:
|
||||
if job.get("drvPath") in all_deps[dep]:
|
||||
all_deps[dep].remove(job.get("drvPath"))
|
||||
for dep in self.all_deps:
|
||||
if job.get("drvPath") in self.all_deps[dep]:
|
||||
self.all_deps[dep].remove(job.get("drvPath"))
|
||||
print('Done!')
|
||||
if self.ended:
|
||||
return util.CANCELLED
|
||||
|
@ -328,6 +317,17 @@ class NixEvalCommand(buildstep.ShellMixin, steps.BuildStep):
|
|||
except json.JSONDecodeError as e:
|
||||
msg = f"Failed to parse `nix derivation show` output for {cmd.command}"
|
||||
raise BuildbotNixError(msg) from e
|
||||
all_deps = dict()
|
||||
for drv, info in drv_info.items():
|
||||
all_deps[drv] = set(info.get("inputDrvs").keys())
|
||||
def closure_of(key, deps):
|
||||
r, size = set([key]), 0
|
||||
while len(r) != size:
|
||||
size = len(r)
|
||||
r.update(*[ deps[k] for k in r ])
|
||||
return r.difference([key])
|
||||
job_set = set(( drv for drv in ( job.get("drvPath") for job in filtered_jobs ) if drv ))
|
||||
all_deps = { k: list(closure_of(k, all_deps).intersection(job_set)) for k in job_set }
|
||||
|
||||
self.build.addStepsAfterCurrentStep(
|
||||
[
|
||||
|
@ -335,7 +335,7 @@ class NixEvalCommand(buildstep.ShellMixin, steps.BuildStep):
|
|||
builds_scheduler=f"lix-nix-build",
|
||||
name="build flake",
|
||||
jobs=filtered_jobs,
|
||||
drv_info=drv_info,
|
||||
all_deps=all_deps,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue