zuke
Zuke for Python: author your build as typed Python, run it on the Zuke engine.
zuke on PyPI ↗ 29 symbols
Symbols
class BooleanParameter(Parameter) A boolean parameter: a flag that takes no value.
-
default(value: bool) -> SelfThe value when the flag is not given.
-
value: bool | NoneThe resolved value, or
Nonewhen unset.
class Build Extend this with targets as fields; see target.
-
deadline: ClassVar[Duration | None]How long the whole run may take, as a duration or milliseconds.
-
unforceable: ClassVar[tuple[Target, ...]]Targets
--forcemay never re-run. -
targets_: ClassVar[dict[str, Target]]The targets by name, in declaration order; set when the subclass is made.
-
parameters_: ClassVar[dict[str, Parameter]]The parameters by name, in declaration order; set when the subclass is made.
-
groups_: ClassVar[dict[str, Group]]The groups by name, in declaration order; set when the subclass is made.
-
ci_: ClassVar[dict[str, Ci]]The CI files by name, in declaration order; set when the subclass is made.
-
on_start() -> Awaitable[None] | NoneOverride to run before the first target; sync or async.
-
on_target_start(target: str) -> Awaitable[None] | NoneOverride to run before each target; sync or async.
-
on_target_end(target: str, status: str) -> Awaitable[None] | NoneOverride to run after each target settles, with its status; sync or async.
-
on_finish(ok: bool) -> Awaitable[None] | NoneOverride to run when the build is done, told whether it succeeded.
-
hooks_() -> dict[str, bool]Which hooks this build overrides: the ones the engine will call.
-
describe() -> dict[str, object]The manifest: what
build.describeanswers. -
configure(parameters: Mapping[str, str | None]) -> NoneTake the resolved parameters from
build.configure. -
target_(name: str, method: str) -> TargetThe target
methodasks about, or aProtocolErrornaming it. -
service_(name: str, method: str) -> ServiceThe service
methodasks about, or aProtocolErrornaming it.
class Ci(Field) One CI file. Start one with ci.
-
provider(provider: Provider) -> SelfThe provider to render for; GitHub when not set.
-
path(path: str) -> SelfThe output path, overriding the one the field name implies.
-
pipeline(fields: Mapping[str, object]) -> SelfThe pipeline fields, and the jobs unless
invokesorfan_outdo. -
invokes(*entries: Field | str | Mapping[str, object]) -> SelfThe targets to run as jobs: bare, or through
invoketo adjust. -
fan_out(options: bool | Mapping[str, object]=True) -> SelfOne job per target in the graph, with the fan-out options.
-
pins(pins: Mapping[str, object]) -> SelfPinned action references by action name.
-
references() -> list[Field | str]Every target the file invokes, for the build to check.
-
manifest() -> dict[str, object]The file as the manifest's
cilist carries it.
def ci() -> Ci A new CI file, to configure fluently and assign to a build field.
class CommandError(Exception) A command ServiceContext.sh ran exited with a code other than zero.
-
argv: tuple[str, ...]The command, as discrete arguments.
-
result: ExecResultIts exit code and output.
class Context(ServiceContext) What a body is handed: the run it is part of, and all the engine serves it.
-
run_id: strThe run's id, as the run record and
zuke resumename it. -
dry_run: boolWhether the run is a
--dry-run. -
state: StateHandleThis target's durable state.
-
state_of(target: str) -> StateHandleAnother target's durable state.
-
async outcome_of(target: str) -> Outcome | NoneWhat
targetdid in this run, orNoneif it has not run. -
async outcomes() -> dict[str, Outcome]What every settled target did in this run, by name.
-
async summary(pairs: Mapping[str, str | float]) -> NoneReport notes into this target's row of the build summary.
-
async plan() -> PlanThe run's plan: the planned targets and each one's dependencies.
-
async signals() -> dict[str, object]The external signals this run has received, by name.
Duration = str | int A duration as the engine takes it: "5m", "250ms" or milliseconds.
class ExecResult What a command the engine ran for the body came back with.
-
code: intThe exit code.
-
stdout: strWhat it printed to stdout.
-
stderr: strWhat it printed to stderr.
class Group(Field) A parallel batch of targets, named like one. Start one with group.
-
members_: tuple[Target, ...]The targets in the group.
-
manifest() -> dict[str, object]The group as the engine's manifest describes it.
def group(*members: Target) -> Group A new group of members, to assign to a build field.
def invoke(target: Field | str, *, after: Sequence[Field | str]=(), **adjustments: object) -> dict[str, object] An invoked target with the runner's adjustments, for Ci.invokes.
after adds needs: edges; the other keywords, such as matrix, are the invocation's fields as the engine names them.
class LockSettings A cross-run lock, as .lock(lambda s: ...) configures it.
-
key(key: str) -> SelfThe lock's key, shared by every run that must not overlap.
-
ttl(ttl: Duration) -> SelfHow long the lock may be held.
-
wait_up_to(limit: Duration) -> SelfHow long to wait for a held lock before giving up.
-
poll_every(interval: Duration) -> SelfHow often to poll a held lock.
-
hold_for_run() -> SelfKeep the lock until the run ends rather than until the target does.
-
manifest() -> dict[str, object]The
locksection oftarget.settings.
class NumberListParameter(Parameter) A list of numbers: a comma-separated value on the command line.
-
value: list[float] | NoneThe resolved values, each an
intwhen whole, orNonewhen unset.
class NumberParameter(Parameter) A number parameter.
-
default(value: float) -> SelfThe value when none is supplied.
-
array() -> NumberListParameterMake it a list instead: a comma-separated value.
-
value: float | NoneThe resolved value, an
intwhen it is whole, orNonewhen unset.
class Outcome What another target in this run did, as Context.outcome_of tells.
-
status: strThe record's status:
succeeded,failed,skipped,waiting, … -
error: str | NoneThe failure's message, when it failed.
-
started_at: str | NoneWhen it started, ISO-8601, if it did.
-
ended_at: str | NoneWhen it settled, ISO-8601, if it has.
class Parameter(Field) What every parameter has, whatever its kind. Start one with parameter.
-
required() -> SelfA value must be supplied.
-
secret() -> SelfMask the value and redact it from everything the run prints or records.
-
flag(name: str) -> SelfThe command-line flag, when it is not derived from the field name.
-
env(name: str) -> SelfThe environment variable, when it is not derived from the field name.
-
resolve(value: str | None) -> NoneTake the value the engine resolved, in CLI form, or
Nonewhen unset. -
manifest() -> dict[str, object]The parameter as the engine's manifest describes it.
def parameter(description: str='') -> StringParameter A new string parameter; .number(), .boolean() or .array() recast it.
The description is what --help shows for it.
class Plan The run's plan, as Context.plan reports it.
-
targets: list[str]The planned targets, in order.
-
dependencies: dict[str, list[str]]Each planned target's dependencies.
def run(build: type[Build]) -> None Host build when the engine started this file; otherwise do nothing.
A build file ends with run(MyBuild). Started by the engine, the file becomes its worker. Imported, by a test say, the call is a no-op, even inside a command the engine is running for a body, whose environment still names the engine. Run by hand with python, it says how a build is run and exits.
class Service(Target) A target the engine starts before its dependants and stops after them.
Start one with service. Its phases get a ServiceContext, which can run commands but has no body-only call.
-
start(phase: Start) -> SelfThe start phase; it answers the handle the probe and the stop phase get.
-
ready(probe: Ready, timeout: Duration | None=None) -> SelfThe readiness probe, asked until it answers true or
timeoutpasses. -
stop(phase: Stop) -> SelfThe stop phase, run once every dependant has settled.
-
manifest() -> dict[str, object]The service as the engine's manifest describes it.
-
async start_(ctx: ServiceContext) -> strAnswer
service.start. -
async ready_(ctx: ServiceContext, handle: str) -> boolAnswer
service.ready. -
async stop_(ctx: ServiceContext, handle: str) -> NoneAnswer
service.stop; a service with no stop phase has nothing to do.
def service() -> Service A new service, to configure fluently and assign to a build field.
class ServiceContext What a service phase is handed: the engine's services a phase may use.
-
target: strThe target whose phase or body this is.
-
async call_(method: str, **params: object) -> objectAsk the engine as this target; an engine-side cancel unwinds the caller.
-
async sh(*argv: str, cwd: str | None=None, env: Mapping[str, str] | None=None, stdin: str | None=None, check: bool=True) -> ExecResultRun
argvthrough the engine, in the worker's directory and environment.cwdandenvadjust those for this command;stdinis fed to it. RaisesCommandErroron a non-zero code unlesscheckis off. -
async secret(value: str) -> NoneRedact
valuefrom everything the run prints or records from now on. -
async log(line: str) -> NoneLog a line attributed to this target.
class StateHandle Durable state of one target, kept by the engine across runs and resumes.
-
async get() -> dict[str, object]The state as last written.
-
async set(patch: Mapping[str, object]) -> NoneMerge
patchinto the state. -
async try_set(patch: Mapping[str, object]) -> boolMerge
patchif the engine will record it now; whether it did.
class StringListParameter(Parameter) A list of strings: a comma-separated value on the command line.
-
value: list[str] | NoneThe resolved values, or
Nonewhen unset.
class StringParameter(Parameter) A string parameter, the default kind.
-
default(value: str) -> SelfThe value when none is supplied.
-
options(*values: str) -> SelfThe only values accepted.
-
number() -> NumberParameterMake it a number parameter instead.
-
boolean() -> BooleanParameterMake it a boolean parameter instead: a flag that takes no value.
-
array() -> StringListParameterMake it a list instead: a comma-separated value.
-
value: str | NoneThe resolved value, or
Nonewhen unset.
class Target(Field) A unit of work the engine schedules. Start one with target.
-
body_: Body | NoneThe body, or
Nonefor a target that only aggregates its dependencies. -
description(text: str) -> SelfThe line
--listshows for this target. -
depends_on(*targets: Target) -> SelfTargets that must succeed first; each is a sibling field declared above.
-
unlisted() -> SelfHide the target from
--listand--help. -
inputs(*paths: str) -> SelfPaths whose contents key the cache.
-
outputs(*paths: str) -> SelfPaths that must exist for a cache hit.
-
produces(*paths: str) -> SelfArtifact paths this target produces.
-
retry(times: int, delay: Duration=0) -> SelfRun the body up to
timesmore times after it fails,delayapart. -
timeout(limit: Duration) -> SelfFail an attempt that runs longer than
limit. -
before(*targets: Target | str) -> SelfRun before these when both are planned; a string names a later field.
-
after(*targets: Target | str) -> SelfRun after these when both are planned; a string names a later field.
-
triggers(*targets: Target | str) -> SelfPull these in and run them after this one; a string names a later field.
-
proceed_after_failure() -> SelfKeep the build running after this target fails.
-
always() -> SelfRun even after the build has failed.
-
dry_runnable() -> SelfRun the body under
--dry-runtoo. -
requires(*parameters: Parameter) -> SelfParameters that must resolve before this target runs.
-
on_cancel(compensation: Target | str) -> SelfThe target to run when the run is cancelled after this one succeeded.
-
on_failure(disposition: Target | str) -> SelfOn failure: a compensation target,
"fail"or"cancel-run". -
executes(body: Body) -> SelfThe body, sync or async.
-
condition(check: Check) -> SelfRun only when
checkanswers true, asked just before the target's turn. -
cache_key(key: CacheKey) -> SelfAn extra key the cache fingerprint includes, asked when fingerprinting.
-
lock(configure: Configure[LockSettings]) -> SelfHold a cross-run lock while this target runs; see
LockSettings. -
waits_for(configure: Configure[WaitSettings]) -> SelfSuspend the run here until a trigger fires; see
WaitSettings. -
validate_during(configure: Configure[ValidateDuringSettings]) -> SelfRun checks on an interval while the body runs; see ValidateDuringSettings.
-
references() -> list[tuple[str, Target | str]]Every target this one names, and the setter that named it, for the build.
-
parameters() -> list[Parameter]The parameters this target requires, for the build to check.
-
manifest() -> dict[str, object]The target as the engine's manifest describes it.
-
async run_body(ctx: Context) -> NoneRun the body, if any, awaiting it when it is async.
-
async condition_() -> boolAnswer
target.condition. -
async cache_key_() -> strAnswer
target.cacheKey. -
settings_() -> dict[str, object]Answer
target.settings: the declared sections, evaluated now. -
async wait_check_() -> boolAnswer
wait.check: theresume_whenpredicate. -
async validate_(check: str) -> NoneAnswer
target.validate: run the named check, which raises to fail.
def target() -> Target A new target, to configure fluently and assign to a build field.
class ValidateDuringSettings Checks run on an interval while the body runs, from .validate_during.
-
every(interval: Duration) -> SelfThe interval between rounds of checks.
-
check(name: str, validation: Validation) -> SelfA named check; it raises to report a problem.
-
checks: dict[str, Validation]The checks by name, in the order declared.
-
manifest() -> dict[str, object]The
validateDuringsection oftarget.settings.
class WaitSettings A wait gate, as .waits_for(lambda s: ...) configures it.
-
external_signal(name: str) -> SelfWait for
zuke resume <run> --signal <name>. -
resume_when(check: Check, every: Duration | None=None) -> SelfWait until
checkanswers true, asked oneveryinterval. -
timeout(limit: Duration) -> SelfHow long to wait before the timeout disposition applies.
-
on_timeout(disposition: Field | str) -> SelfOn timeout: a compensation target,
"fail"or"cancel-run". -
check: Check | NoneThe
resume_whenpredicate, when that is the trigger. -
manifest() -> dict[str, object]The
waitsForsection oftarget.settings.