Something went wrong. Try again.
A local Git merge queue with content-bound gate verdicts
Something went wrong. Try again.
5.1 kB · 108 lines
OCaml
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109(** What a land says while it waits (doc/rules.md, rule 5).
On a terminal the progress is a live panel; anywhere else it is one line for each change of state, and at least one line every thirty seconds while nothing changes. A value of this type is one such change, or one such beat, as the model knows it: the shell draws it as a row of the panel, or prints {!pp}'s line. *)
(** The type for where one check of a land stands, with the seconds it has stood there, or the time its run took once it ended. *)type check = | Waiting of { attempt : int; seconds : int; held : string option } (** Not started: it waits for a build slot, its land's or another build's; [held] names the [mq slot] hold its wait saw ({!Order.constructor-Held}). *) | Preparing of { attempt : int; seconds : int } (** It holds a build slot, and its worktree and dependency generations are being made ready ({!Event.Preparing}). *) | Running of { attempt : int; seconds : int } (** Its command runs ({!Event.Running}). *) | Ended of { result : Check.result; seconds : int; attempt : int; stopped : string option; } (** Its last run ended, with no rerun to come. *) | Reused of { result : Check.result } (** Its verdict was taken from a stored result. *)
type checks = { checks : (Check.name * check) list; (** Each check of the land, in the order its run listed them. *) past : int option; (** The seconds since the last check ended, once every check has: the land records their results and moves on. *)}(** The type for where the checks of a land stand. *)
val checks : now:Ptime.t -> (Ptime.t * Event.kind) list -> checks option(** [checks ~now story] is where the checks of a land stand at [now], from the records of its run, oldest first, each with its time: its last {!Event.constructor-Checking} on, then each run's start, phase and end. [None] when [story] holds no {!Event.constructor-Checking}. The one producer of the land's progress line, of what [mq status] says of its checks, and of their JSON. *)
val check_words : check -> string(** [check_words c] is [c]'s state in words: [waiting to start] (for a build slot, or for its land's dependency generations), followed by [behind mq slot (BUILD) since ...] when its wait saw that hold, [preparing], [running], [running its rerun], or the last run's result ([passed], [failed], ...), and [reused]. *)
val check_seconds : check -> int option(** [check_seconds c] is the seconds [c] has stood in its state, or the time its last run took; [None] for a reused verdict. *)
val pp_checks : checks Fmt.t(** [pp_checks] formats where the checks stand: each check, its state and its seconds, as in [build passed (40s), test running (12s)], then, once each has ended, how long the land has been past them. *)
(** The type for one change of state, or one beat, of a land. *)type t = | Landing of { branch : Branch.t; target : Branch.t; commits : int; (** Its own commits; [0] for the lock commit alone. *) dry_run : bool; source_of : Branch.t option; (** The branch's base, when the land goes into the branch that base takes its commits from (doc/rules.md, rule 1). *) } (** The land took the branch and replays its commits onto [target]. *) | Checking of { branch : Branch.t; target : Branch.t; checks : Check.name list; } (** A run started checking the replayed tree. *) | Checked of { branch : Branch.t; check : Check.name; result : Check.result; seconds : int; attempt : int; (** [1], or [2] for the rerun of a failure. *) log : Fpath.t option; (** Its output, which a panel names. *) stopped : string option; (** Why mq stopped it, when it did. *) } (** One run of a check ended. *) | Rerunning of { branch : Branch.t; check : Check.name } (** A failed check runs once more, to tell a flake from a red. *) | Running of { branch : Branch.t; checks : checks } (** Where each check stands: the beat while nothing changes, and the line after a check ends while another has yet to. *) | Moving of { branch : Branch.t; target : Branch.t } (** Every check passed: [target] moves to the checked commits. *) | Line of string (** Any other line, said as it is. *)
val of_event : Branch.t -> Event.kind -> t list(** [of_event name k] is the progress of the change of state [k] the journal records for the branch [name]: a run's take of the entry names the target it replays onto, a run's start names the checks it runs, each run of a check its result and time, with a rerun's start after it, and each probe of a bisection its prefix, then its result and time. It is [[]] for every other kind. *)
val pp : t Fmt.t(** [pp] formats a progress as its line, as in [checking fix: build test], [fix: check build passed (3s)] and [checking fix: build passed (40s), test running (12s)]. *)