remove skipped-builds builder
run all of them on the normal build worker. this significantly simplifies the overall scheduler/builder config and removes a triplication of possible builds paths.
This commit is contained in:
parent
753df8e340
commit
156e6e3dea
|
@ -31,8 +31,6 @@ from .github_projects import (
|
||||||
slugify_project_name,
|
slugify_project_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
SKIPPED_BUILDER_NAME = "skipped-builds"
|
|
||||||
|
|
||||||
log = Logger()
|
log = Logger()
|
||||||
|
|
||||||
class LixSystemsOAuth2(OAuth2Auth):
|
class LixSystemsOAuth2(OAuth2Auth):
|
||||||
|
@ -57,7 +55,6 @@ class BuildTrigger(Trigger):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
builds_scheduler: str,
|
builds_scheduler: str,
|
||||||
skipped_builds_scheduler: str,
|
|
||||||
jobs: list[dict[str, Any]],
|
jobs: list[dict[str, Any]],
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -66,11 +63,10 @@ class BuildTrigger(Trigger):
|
||||||
self.jobs = jobs
|
self.jobs = jobs
|
||||||
self.config = None
|
self.config = None
|
||||||
self.builds_scheduler = builds_scheduler
|
self.builds_scheduler = builds_scheduler
|
||||||
self.skipped_builds_scheduler = skipped_builds_scheduler
|
|
||||||
Trigger.__init__(
|
Trigger.__init__(
|
||||||
self,
|
self,
|
||||||
waitForFinish=True,
|
waitForFinish=True,
|
||||||
schedulerNames=[builds_scheduler, skipped_builds_scheduler],
|
schedulerNames=[builds_scheduler],
|
||||||
haltOnFailure=True,
|
haltOnFailure=True,
|
||||||
flunkOnFailure=True,
|
flunkOnFailure=True,
|
||||||
sourceStamps=[],
|
sourceStamps=[],
|
||||||
|
@ -99,11 +95,7 @@ class BuildTrigger(Trigger):
|
||||||
|
|
||||||
if error is not None:
|
if error is not None:
|
||||||
props.setProperty("error", error, source)
|
props.setProperty("error", error, source)
|
||||||
triggered_schedulers.append((self.skipped_builds_scheduler, props))
|
triggered_schedulers.append((self.builds_scheduler, props))
|
||||||
continue
|
|
||||||
|
|
||||||
if job.get("isCached"):
|
|
||||||
triggered_schedulers.append((self.skipped_builds_scheduler, props))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
drv_path = job.get("drvPath")
|
drv_path = job.get("drvPath")
|
||||||
|
@ -117,6 +109,7 @@ class BuildTrigger(Trigger):
|
||||||
props.setProperty("system", system, source)
|
props.setProperty("system", system, source)
|
||||||
props.setProperty("drv_path", drv_path, source)
|
props.setProperty("drv_path", drv_path, source)
|
||||||
props.setProperty("out_path", out_path, source)
|
props.setProperty("out_path", out_path, source)
|
||||||
|
props.setProperty("isCached", job.get("isCached"), source)
|
||||||
|
|
||||||
triggered_schedulers.append((self.builds_scheduler, props))
|
triggered_schedulers.append((self.builds_scheduler, props))
|
||||||
return triggered_schedulers
|
return triggered_schedulers
|
||||||
|
@ -179,7 +172,6 @@ class NixEvalCommand(buildstep.ShellMixin, steps.BuildStep):
|
||||||
[
|
[
|
||||||
BuildTrigger(
|
BuildTrigger(
|
||||||
builds_scheduler=f"lix-nix-build",
|
builds_scheduler=f"lix-nix-build",
|
||||||
skipped_builds_scheduler=f"lix-nix-skipped-build",
|
|
||||||
name="build flake",
|
name="build flake",
|
||||||
jobs=filtered_jobs,
|
jobs=filtered_jobs,
|
||||||
),
|
),
|
||||||
|
@ -189,19 +181,6 @@ class NixEvalCommand(buildstep.ShellMixin, steps.BuildStep):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class EvalErrorStep(steps.BuildStep):
|
|
||||||
"""Shows the error message of a failed evaluation."""
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
def run(self) -> Generator[Any, object, Any]:
|
|
||||||
error = self.getProperty("error")
|
|
||||||
attr = self.getProperty("attr")
|
|
||||||
# show eval error
|
|
||||||
error_log: Log = yield self.addLog("nix_error")
|
|
||||||
error_log.addStderr(f"{attr} failed to evaluate:\n{error}")
|
|
||||||
return util.FAILURE
|
|
||||||
|
|
||||||
|
|
||||||
class NixBuildCommand(buildstep.ShellMixin, steps.BuildStep):
|
class NixBuildCommand(buildstep.ShellMixin, steps.BuildStep):
|
||||||
"""Builds a nix derivation."""
|
"""Builds a nix derivation."""
|
||||||
|
|
||||||
|
@ -211,6 +190,20 @@ class NixBuildCommand(buildstep.ShellMixin, steps.BuildStep):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def run(self) -> Generator[Any, object, Any]:
|
def run(self) -> Generator[Any, object, Any]:
|
||||||
|
if error := self.getProperty("error"):
|
||||||
|
attr = self.getProperty("attr")
|
||||||
|
# show eval error
|
||||||
|
error_log: Log = yield self.addLog("nix_error")
|
||||||
|
error_log.addStderr(f"{attr} failed to evaluate:\n{error}")
|
||||||
|
return util.FAILURE
|
||||||
|
|
||||||
|
if self.getProperty("isCached"):
|
||||||
|
yield self.addCompleteLog(
|
||||||
|
"cached outpath from previous builds",
|
||||||
|
# buildbot apparently hides the first line in the ui?
|
||||||
|
f'\n{self.getProperty("out_path")}\n')
|
||||||
|
return util.SKIPPED
|
||||||
|
|
||||||
# run `nix build`
|
# run `nix build`
|
||||||
cmd: remotecommand.RemoteCommand = yield self.makeRemoteShellCommand()
|
cmd: remotecommand.RemoteCommand = yield self.makeRemoteShellCommand()
|
||||||
yield self.runCommand(cmd)
|
yield self.runCommand(cmd)
|
||||||
|
@ -390,38 +383,6 @@ def nix_build_config(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def nix_skipped_build_config(
|
|
||||||
project: GerritProject,
|
|
||||||
worker_names: list[str],
|
|
||||||
) -> util.BuilderConfig:
|
|
||||||
"""Dummy builder that is triggered when a build is skipped."""
|
|
||||||
factory = util.BuildFactory()
|
|
||||||
factory.addStep(
|
|
||||||
EvalErrorStep(
|
|
||||||
name="Nix evaluation",
|
|
||||||
doStepIf=lambda s: s.getProperty("error"),
|
|
||||||
hideStepIf=lambda _, s: not s.getProperty("error"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
# This is just a dummy step showing the cached build
|
|
||||||
factory.addStep(
|
|
||||||
steps.BuildStep(
|
|
||||||
name="Nix build (cached)",
|
|
||||||
doStepIf=lambda _: False,
|
|
||||||
hideStepIf=lambda _, s: s.getProperty("error"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return util.BuilderConfig(
|
|
||||||
name=f"{project.name}/nix-skipped-build",
|
|
||||||
project=project.name,
|
|
||||||
workernames=worker_names,
|
|
||||||
collapseRequests=False,
|
|
||||||
env={},
|
|
||||||
factory=factory,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def read_secret_file(secret_name: str) -> str:
|
def read_secret_file(secret_name: str) -> str:
|
||||||
directory = os.environ.get("CREDENTIALS_DIRECTORY")
|
directory = os.environ.get("CREDENTIALS_DIRECTORY")
|
||||||
if directory is None:
|
if directory is None:
|
||||||
|
@ -458,11 +419,6 @@ def config_for_project(
|
||||||
name=f"{project.name}-nix-build",
|
name=f"{project.name}-nix-build",
|
||||||
builderNames=[f"{project.name}/nix-build"],
|
builderNames=[f"{project.name}/nix-build"],
|
||||||
),
|
),
|
||||||
# this is triggered from `nix-eval` when the build is skipped
|
|
||||||
schedulers.Triggerable(
|
|
||||||
name=f"{project.name}-nix-skipped-build",
|
|
||||||
builderNames=[f"{project.name}/nix-skipped-build"],
|
|
||||||
),
|
|
||||||
# allow to manually trigger a nix-build
|
# allow to manually trigger a nix-build
|
||||||
schedulers.ForceScheduler(
|
schedulers.ForceScheduler(
|
||||||
name=f"{project.name}-force",
|
name=f"{project.name}-force",
|
||||||
|
@ -502,7 +458,6 @@ def config_for_project(
|
||||||
worker_names,
|
worker_names,
|
||||||
outputs_path=outputs_path,
|
outputs_path=outputs_path,
|
||||||
),
|
),
|
||||||
nix_skipped_build_config(project, [SKIPPED_BUILDER_NAME]),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -688,7 +643,6 @@ class GerritNixConfigurator(ConfiguratorBase):
|
||||||
)
|
)
|
||||||
|
|
||||||
config["change_source"] = self.gerrit_change_source
|
config["change_source"] = self.gerrit_change_source
|
||||||
config["workers"].append(worker.LocalWorker(SKIPPED_BUILDER_NAME))
|
|
||||||
config["services"].append(
|
config["services"].append(
|
||||||
reporters.GerritStatusPush(self.gerrit_server, self.gerrit_user,
|
reporters.GerritStatusPush(self.gerrit_server, self.gerrit_user,
|
||||||
port=2022,
|
port=2022,
|
||||||
|
|
Loading…
Reference in a new issue