feat: add incoming ref data to non-flakes entrypoint
We can now implement a Nix library for Buildbot CI. :) We dump it into a file, it's better to pass large stuff and easier to escape things. Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
parent
b3a0b5a69e
commit
94c1a1411f
|
@ -8,6 +8,7 @@ from collections.abc import Generator
|
|||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any
|
||||
import tempfile
|
||||
|
||||
import buildbot
|
||||
from buildbot.configurators import ConfiguratorBase
|
||||
|
@ -453,13 +454,14 @@ class NixEvalCommand(buildstep.ShellMixin, steps.BuildStep):
|
|||
|
||||
return result
|
||||
|
||||
def make_job_evaluator(name: str, settings: EvaluatorSettings, flake: bool) -> NixEvalCommand:
|
||||
def make_job_evaluator(name: str, settings: EvaluatorSettings, flake: bool, incoming_ref_filename: str) -> NixEvalCommand:
|
||||
actual_command = []
|
||||
|
||||
if flake:
|
||||
actual_command += ["--flake", f".#{FLAKE_TARGET_ATTRIBUTE_FOR_JOBS}"]
|
||||
else:
|
||||
actual_command += ["--expr", "import ./.ci/buildbot.nix"]
|
||||
actual_command += ["--expr",
|
||||
f"import ./.ci/buildbot.nix {{ incoming_ref_data = builtins.fromJSON (builtins.readFile {incoming_ref_filename}); }}"]
|
||||
|
||||
return NixEvalCommand(
|
||||
env={},
|
||||
|
@ -504,6 +506,15 @@ class NixConfigure(buildstep.CommandMixin, steps.BuildStep):
|
|||
except Exception:
|
||||
configure_log: Log = yield self.addLog("stdio")
|
||||
|
||||
# This information can be passed at job evaluation time
|
||||
# to skip some jobs, e.g. expensive jobs, etc.
|
||||
# Transfer incoming ref data to the target.
|
||||
self.build.addStepsAfterCurrentStep(
|
||||
[
|
||||
steps.JSONPropertiesDownload(workerdest="incoming-ref.json")
|
||||
]
|
||||
)
|
||||
|
||||
# Takes precedence.
|
||||
configure_log.addStdout("checking if there's a .ci/buildbot.nix...\n")
|
||||
ci_buildbot_defn_exists = yield self.pathExists('build/.ci/buildbot.nix')
|
||||
|
@ -514,7 +525,8 @@ class NixConfigure(buildstep.CommandMixin, steps.BuildStep):
|
|||
make_job_evaluator(
|
||||
"evaluate `.ci/buildbot.nix` jobs",
|
||||
self.evaluator_settings,
|
||||
False
|
||||
False,
|
||||
"../incoming-ref.json"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
@ -527,7 +539,8 @@ class NixConfigure(buildstep.CommandMixin, steps.BuildStep):
|
|||
make_job_evaluator(
|
||||
"evaluate `flake.nix` jobs",
|
||||
self.evaluator_settings,
|
||||
True
|
||||
True,
|
||||
"../incoming-ref.json"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue