chore(*): refactor the whole code #8
|
@ -417,30 +417,6 @@ class NixBuildCommand(buildstep.ShellMixin, steps.BuildStep):
|
|||
return cmd.results()
|
||||
|
||||
|
||||
class UpdateBuildOutput(steps.BuildStep):
|
||||
"""Updates store paths in a public www directory.
|
||||
This is useful to prefetch updates without having to evaluate
|
||||
on the target machine.
|
||||
"""
|
||||
|
||||
def __init__(self, path: Path, **kwargs: Any) -> None:
|
||||
super().__init__(**kwargs)
|
||||
self.path = path
|
||||
|
||||
def run(self) -> Generator[Any, object, Any]:
|
||||
props = self.build.getProperties()
|
||||
if props.getProperty("branch") != props.getProperty(
|
||||
"github.repository.default_branch",
|
||||
):
|
||||
return util.SKIPPED
|
||||
|
||||
attr = Path(props.getProperty("attr")).name
|
||||
out_path = props.getProperty("out_path")
|
||||
# XXX don't hardcode this
|
||||
self.path.mkdir(parents=True, exist_ok=True)
|
||||
(self.path / attr).write_text(out_path)
|
||||
return util.SUCCESS
|
||||
|
||||
|
||||
def nix_eval_config(
|
||||
project: GerritProject,
|
||||
|
@ -521,7 +497,6 @@ def nix_build_config(
|
|||
project: GerritProject,
|
||||
worker_arch: str,
|
||||
worker_names: list[str],
|
||||
outputs_path: Path | None = None,
|
||||
signing_keyfile: str | None = None,
|
||||
binary_cache_config: S3BinaryCacheConfig | None = None
|
||||
) -> util.BuilderConfig:
|
||||
|
@ -611,13 +586,7 @@ def nix_build_config(
|
|||
command=["rm", "-f", util.Interpolate("result-%(prop:attr)s")],
|
||||
),
|
||||
)
|
||||
if outputs_path is not None:
|
||||
factory.addStep(
|
||||
UpdateBuildOutput(
|
||||
name="Update build output",
|
||||
path=outputs_path,
|
||||
),
|
||||
)
|
||||
|
||||
return util.BuilderConfig(
|
||||
name=f"{project.name}/nix-build/{worker_arch}",
|
||||
project=project.name,
|
||||
|
@ -645,7 +614,6 @@ def config_for_project(
|
|||
nix_eval_worker_count: int,
|
||||
nix_eval_max_memory_size: int,
|
||||
eval_lock: util.MasterLock,
|
||||
outputs_path: Path | None = None,
|
||||
signing_keyfile: str | None = None,
|
||||
binary_cache_config: S3BinaryCacheConfig | None = None
|
||||
) -> Project:
|
||||
|
@ -708,7 +676,6 @@ def config_for_project(
|
|||
project,
|
||||
arch,
|
||||
[ f"{w}-{arch}" for w in worker_names ],
|
||||
outputs_path=outputs_path,
|
||||
signing_keyfile=signing_keyfile,
|
||||
binary_cache_config=binary_cache_config
|
||||
)
|
||||
|
@ -816,7 +783,6 @@ class GerritNixConfigurator(ConfiguratorBase):
|
|||
signing_keyfile: str | None = None,
|
||||
prometheus_config: dict[str, int | str] | None = None,
|
||||
binary_cache_config: dict[str, str] | None = None,
|
||||
outputs_path: str | None = None,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.gerrit_server = gerrit_server
|
||||
|
@ -834,10 +800,6 @@ class GerritNixConfigurator(ConfiguratorBase):
|
|||
else:
|
||||
self.binary_cache_config = None
|
||||
self.signing_keyfile = signing_keyfile
|
||||
if outputs_path is None:
|
||||
self.outputs_path = None
|
||||
else:
|
||||
self.outputs_path = Path(outputs_path)
|
||||
|
||||
def configure(self, config: dict[str, Any]) -> None:
|
||||
worker_config = json.loads(read_secret_file(self.nix_workers_secret_name))
|
||||
|
@ -866,7 +828,6 @@ class GerritNixConfigurator(ConfiguratorBase):
|
|||
self.nix_eval_worker_count or multiprocessing.cpu_count(),
|
||||
self.nix_eval_max_memory_size,
|
||||
eval_lock,
|
||||
self.outputs_path,
|
||||
signing_keyfile=self.signing_keyfile,
|
||||
binary_cache_config=self.binary_cache_config
|
||||
)
|
||||
|
|
|
@ -51,13 +51,6 @@ in
|
|||
example = "buildbot.numtide.com";
|
||||
};
|
||||
|
||||
outputsPath = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
description = "Path where we store the latest build store paths names for nix attributes as text files. This path will be exposed via nginx at \${domain}/nix-outputs";
|
||||
default = null;
|
||||
example = "/var/www/buildbot/nix-outputs";
|
||||
};
|
||||
|
||||
signingKeyFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
description = "A path to a Nix signing key";
|
||||
|
@ -173,7 +166,6 @@ in
|
|||
nix_eval_max_memory_size=${builtins.toJSON cfg.evalMaxMemorySize},
|
||||
nix_eval_worker_count=${if cfg.evalWorkerCount == null then "None" else builtins.toString cfg.evalWorkerCount},
|
||||
nix_supported_systems=${builtins.toJSON cfg.buildSystems},
|
||||
outputs_path=${if cfg.outputsPath == null then "None" else builtins.toJSON cfg.outputsPath},
|
||||
prometheus_config=${if (!cfg.prometheus.enable) then "None" else builtins.toJSON {
|
||||
inherit (cfg.prometheus) address port;
|
||||
}},
|
||||
|
@ -259,13 +251,7 @@ in
|
|||
# raise the proxy timeout for the websocket
|
||||
extraConfig = "proxy_read_timeout 6000s;";
|
||||
};
|
||||
} // lib.optionalAttrs (cfg.outputsPath != null) {
|
||||
"/nix-outputs".root = cfg.outputsPath;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = lib.optional (cfg.outputsPath != null)
|
||||
# Allow buildbot-coordinator to write to this directory
|
||||
"d ${cfg.outputsPath} 0755 buildbot buildbot - -";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue