Juggernaut.Store.History (Juggernaut v0.4.0)

Copy Markdown View Source

The append-only run history, history/runs.ndjson (design notes §7.2).

One JSON object per finished run, appended by the controller only. read/1 returns the records it understands (format 1) in file order, oldest first, and lists the lines it skipped and why; it never fails on old or foreign lines.

A record (string keys): format, run_id, started_at, finished_at, actor, commit, dirty, dirty_hash, base, lane, scope, argv, config_fingerprint, juggernaut, elixir, otp, seed, workers, phases ([{"name", "ms"}]), counts, kill_kinds, score, verdict, exit_code, error (why a run ended in exit 3, else null), reused ({"results", "recorded_ms"}), recycles (a count) and selection (results per selection reason: tests, file, suite, warm_first, boot). Summary fields are null for a run without a summary.

Summary

Functions

Appends the record of run as one line. When the file does not end with a newline (an earlier append was cut off), a newline is written first, so read/1 skips the torn line on its own and the new record stays readable. root must be a prepared store (Layout.check/1).

Parses history file contents (see read/1).

Reads the history: %{records: [...], skipped: [...]}, records oldest first. A missing file is an empty history.

The history record of a run.

Types

entry()

@type entry() :: %{required(String.t()) => term()}

skipped()

@type skipped() :: %{line: pos_integer(), reason: String.t()}

Functions

append(root, run)

@spec append(Path.t(), Juggernaut.Run.t()) :: :ok | {:error, Juggernaut.Error.t()}

Appends the record of run as one line. When the file does not end with a newline (an earlier append was cut off), a newline is written first, so read/1 skips the torn line on its own and the new record stays readable. root must be a prepared store (Layout.check/1).

parse(contents)

@spec parse(String.t()) :: %{records: [entry()], skipped: [skipped()]}

Parses history file contents (see read/1).

read(root)

@spec read(Path.t()) :: %{records: [entry()], skipped: [skipped()]}

Reads the history: %{records: [...], skipped: [...]}, records oldest first. A missing file is an empty history.

record(run)

@spec record(Juggernaut.Run.t()) :: entry()

The history record of a run.