Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s
CI / tests (pull_request) Successful in 6m34s
This commit is contained in:
@@ -18,9 +18,9 @@ from larv_review.scoring_setup import removed_setup
|
||||
Say = typing.Callable[[str], None]
|
||||
|
||||
|
||||
def record_ruling(votes_file: pathlib.Path, home: pathlib.Path, now: float) -> str | Failure:
|
||||
def record_ruling(votes_file: pathlib.Path, home: pathlib.Path, env: typing.Mapping[str, str], now: float) -> str | Failure:
|
||||
"""Records the ruling the votes file's seats reach, and returns what the tool prints: the ruling and where it went, or which seats to launch where they split."""
|
||||
read = read_seats(votes_file, True, home, now)
|
||||
read = read_seats(votes_file, True, home, env, now)
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
heading_read, seats_read = read
|
||||
@@ -35,25 +35,25 @@ def record_ruling(votes_file: pathlib.Path, home: pathlib.Path, now: float) -> s
|
||||
if split(overall_votes):
|
||||
return f"Split: {tally}. Launch the maintainability senior and Junior A together, add their lines to the votes file, and run this again."
|
||||
ruled = ruling(overall_votes)
|
||||
appended_to = append(seats_read.read, ruling_entry(heading_read.title, seats_read.seats, written, counts, ruled), home)
|
||||
appended_to = append(seats_read.read, ruling_entry(heading_read.title, seats_read.seats, written, counts, ruled), home, env)
|
||||
return appended_to if isinstance(appended_to, Failure) else f"Ruling: {ruled}. Overall votes as counted: {tally}.\n{appended_to}"
|
||||
|
||||
|
||||
def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home: pathlib.Path, now: float, say: Say, warn: Say) -> Failure | None:
|
||||
def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home: pathlib.Path, env: typing.Mapping[str, str], now: float, say: Say, warn: Say) -> Failure | None:
|
||||
"""Records the scoring run the scores file holds in the comprehension history, and ranks the plan again. It says each result as soon as it has it, since a later step may fail after the run is recorded."""
|
||||
read = read_seats(scores_file, False, home, now)
|
||||
read = read_seats(scores_file, False, home, env, now)
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
named, given = read
|
||||
scoring = scored_seats(given)
|
||||
if isinstance(scoring, Failure):
|
||||
return scoring
|
||||
reasons = plan_reasons(default, ids, home)
|
||||
reasons = plan_reasons(default, ids, home, env)
|
||||
if isinstance(reasons, Failure):
|
||||
return reasons
|
||||
if not reasons:
|
||||
return Failure("no plan item or release calls this scoring run; name the item IDs the chunk ships, as needs-scoring-run took them")
|
||||
config = located(None, home)
|
||||
config = located(None, home, env)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
checkout = str(config.top)
|
||||
@@ -61,7 +61,7 @@ def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home
|
||||
if isinstance(todo, Failure):
|
||||
return todo
|
||||
plan = todo.items
|
||||
appended_to = append(given.read, scoring_entry(named.title, scoring), home)
|
||||
appended_to = append(given.read, scoring_entry(named.title, scoring), home, env)
|
||||
if isinstance(appended_to, Failure):
|
||||
return appended_to
|
||||
say(appended_to)
|
||||
@@ -70,14 +70,14 @@ def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home
|
||||
say(f"Floor: {', '.join(under)} under the floor of {config.readability_floor}.")
|
||||
if step := floor_step(scoring.means, plan, ids, config.readability_floor):
|
||||
say(step)
|
||||
reranked = rerank(home, warn)
|
||||
removed = removed_setup(checkout, home)
|
||||
reranked = rerank(home, env, warn)
|
||||
removed = removed_setup(checkout, home, env)
|
||||
return reranked or (removed and Failure(f"recorded the run, but {removed.reason}"))
|
||||
|
||||
|
||||
def rerank(home: pathlib.Path, warn: Say) -> Failure | None:
|
||||
def rerank(home: pathlib.Path, env: typing.Mapping[str, str], warn: Say) -> Failure | None:
|
||||
"""Rank the project's todo.md again as rank_todo.py does, since the overall sets code health's weight, and fail where rank_todo.py would. The run stays recorded whatever happens, so those failures say to settle todo.md and run rank_todo.py on it, not to record the run again."""
|
||||
config = located(None, home)
|
||||
config = located(None, home, env)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
todo = config.plan_file
|
||||
@@ -102,13 +102,13 @@ def scored_seats(given: SeatsFile) -> ScoringRun | Failure:
|
||||
return ScoringRun(given.seats, found, means(list(found.values())))
|
||||
|
||||
|
||||
def read_seats(path: pathlib.Path, paired: bool, home: pathlib.Path, now: float) -> tuple[Heading, SeatsFile] | Failure:
|
||||
def read_seats(path: pathlib.Path, paired: bool, home: pathlib.Path, env: typing.Mapping[str, str], now: float) -> tuple[Heading, SeatsFile] | Failure:
|
||||
"""The heading the seats file's entry goes under, and the file, as decided says. Its callers run it first, so a file it refuses fails before anything is printed."""
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read {path}: {failure}")
|
||||
history = history_file(home)
|
||||
history = history_file(home, env)
|
||||
if isinstance(history, Failure):
|
||||
return history
|
||||
return decided(text, now, paired, commit_exists, history)
|
||||
@@ -129,8 +129,8 @@ def decided(text: str, now: float, paired: bool, commit_known: typing.Callable[[
|
||||
return named, given
|
||||
|
||||
|
||||
def read_places(home: pathlib.Path) -> str | Failure:
|
||||
history = history_file(home)
|
||||
def read_places(home: pathlib.Path, env: typing.Mapping[str, str]) -> str | Failure:
|
||||
history = history_file(home, env)
|
||||
return history if isinstance(history, Failure) else places_report(history[1])
|
||||
|
||||
|
||||
@@ -139,20 +139,20 @@ def places_report(history: str) -> str:
|
||||
return (latest_places(history) or "Seats found no places hard.").rstrip("\n")
|
||||
|
||||
|
||||
def read_agreement(home: pathlib.Path) -> str | Failure:
|
||||
history = history_file(home)
|
||||
def read_agreement(home: pathlib.Path, env: typing.Mapping[str, str]) -> str | Failure:
|
||||
history = history_file(home, env)
|
||||
return history if isinstance(history, Failure) else agreement_report(history[1])
|
||||
|
||||
|
||||
def history_file(home: pathlib.Path) -> tuple[RecordStore, str] | Failure:
|
||||
def history_file(home: pathlib.Path, env: typing.Mapping[str, str]) -> tuple[RecordStore, str] | Failure:
|
||||
"""The store the project's config names for its comprehension history, and the history's text, empty where there is none yet."""
|
||||
held = held_history(home)
|
||||
held = held_history(home, env)
|
||||
return held if isinstance(held, Failure) else (held[0], held[1].text)
|
||||
|
||||
|
||||
def held_history(home: pathlib.Path) -> tuple[RecordStore, Held] | Failure:
|
||||
def held_history(home: pathlib.Path, env: typing.Mapping[str, str]) -> tuple[RecordStore, Held] | Failure:
|
||||
"""The store the project's config names for its comprehension history, and the history as it stands, with the version a write over it names."""
|
||||
config = located(None, home)
|
||||
config = located(None, home, env)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
history = store(config, "comprehension-history")
|
||||
@@ -160,9 +160,9 @@ def held_history(home: pathlib.Path) -> tuple[RecordStore, Held] | Failure:
|
||||
return held if isinstance(held, Failure) else (history, held)
|
||||
|
||||
|
||||
def append(read: str, entry: str, home: pathlib.Path) -> str | Failure:
|
||||
def append(read: str, entry: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> str | Failure:
|
||||
"""Appends entry and returns the line the tool prints; a Failure where the history already holds an entry on what the seats read."""
|
||||
read_history = held_history(home)
|
||||
read_history = held_history(home, env)
|
||||
return read_history if isinstance(read_history, Failure) else appended_to(*read_history, read, entry)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user