2026-02-09 07:29:45 -08:00
|
|
|
#!/usr/bin/env -S uv run --script
|
|
|
|
|
# /// script
|
|
|
|
|
# requires-python = ">=3.12"
|
C1: SHA-pin tooling dependencies (2026-04 cycle) (#344)
## Summary
Monthly tooling dependency refresh, with a one-time conversion from version-tag pins (`rev = "vX.Y.Z"`, `image:tag`, `>=`) to SHA / digest pins everywhere.
## Changes
- **prek hooks**: all `rev = "vX.Y.Z"` → commit SHA + `# vX.Y.Z` comment. Bumped trufflehog (3.94.0→3.95.2), kingfisher (1.91.0→1.97.0), ruff (0.15.7→0.15.12), shfmt (3.13.0→3.13.1), prettier (3.8.1→3.8.3), actionlint (1.7.11→1.7.12).
- **fly/Dockerfile**: tag pins → `image@sha256:...` digest pins. Bumped nginx (1.29.6→1.30.0-alpine), tailscale (v1.94.1→v1.94.2 — still inside the safe pre-1.96.5 range), alloy (v1.14.1→v1.16.0).
- **mise-tasks**: PEP 723 inline deps converted from `>=` to `==` (PEP 508 doesn't support hashes inline). All scripts pinned to current latest: rich 15.0.0, typer 0.25.0, pyyaml 6.0.3, httpx 0.28.1.
- **prek `additional_dependencies`**: ansible-lint==26.4.0, ansible-core==2.20.5.
- **taplo-lint**: pass `--no-schema`. Upstream's `--default-schema-catalogs` returns a format taplo v0.9.3 can't parse — we don't validate against TOML schemas anyway, so this turns off the broken catalog fetch.
- **docs/update-tooling-dependencies**: documents the SHA-pin convention, `docker buildx imagetools inspect` for digest lookup, and `prek clean` before re-verifying (cache grows to several GiB).
Forgejo workflow `actions/checkout@v6.0.2` was already at the latest SHA — no change.
## Test plan
- [x] `prek run --all-files` passes after `prek clean`
- [x] `deploy-fly` workflow builds and deploys the new fly image on merge
- [x] `fly status -a blumeops-proxy` healthy after deploy
- [x] Spot-check a few mise tasks (`mise run blumeops-tasks`, `mise run docs-check-links`) to confirm pinned deps resolve cleanly
Reviewed-on: https://forge.eblu.me/eblume/blumeops/pulls/344
2026-04-30 16:51:43 -07:00
|
|
|
# dependencies = ["pyyaml==6.0.3", "rich==15.0.0", "typer==0.25.0"]
|
2026-02-09 07:29:45 -08:00
|
|
|
# ///
|
|
|
|
|
#MISE description="Review the most stale documentation card by last-reviewed date"
|
2026-02-22 10:20:11 -08:00
|
|
|
#USAGE flag "--limit <limit>" default="15" help="Number of docs to show in the table"
|
2026-02-09 07:29:45 -08:00
|
|
|
"""Review the most stale documentation card by last-reviewed date.
|
|
|
|
|
|
|
|
|
|
Scans all markdown files in docs/ (excluding changelog.d/) and sorts them
|
2026-03-17 13:22:01 -07:00
|
|
|
by the ``last-reviewed`` frontmatter field, with git last-modified date as
|
|
|
|
|
a tiebreaker (least recently updated first). Docs without the field are
|
2026-02-09 07:29:45 -08:00
|
|
|
treated as never-reviewed and float to the top. Displays a staleness
|
|
|
|
|
table and then shows the most stale doc with a review checklist.
|
|
|
|
|
|
|
|
|
|
After reviewing, update the card's frontmatter:
|
|
|
|
|
|
|
|
|
|
last-reviewed: YYYY-MM-DD
|
|
|
|
|
|
|
|
|
|
Usage: mise run docs-review [-- --limit 10]
|
|
|
|
|
"""
|
|
|
|
|
|
2026-03-17 13:22:01 -07:00
|
|
|
import subprocess
|
2026-02-09 07:29:45 -08:00
|
|
|
import sys
|
2026-03-17 13:22:01 -07:00
|
|
|
from datetime import date, datetime, timezone
|
2026-02-09 07:29:45 -08:00
|
|
|
from pathlib import Path
|
|
|
|
|
from typing import Annotated
|
|
|
|
|
|
|
|
|
|
import typer
|
|
|
|
|
import yaml
|
|
|
|
|
from rich.console import Console
|
|
|
|
|
from rich.markdown import Markdown
|
|
|
|
|
from rich.panel import Panel
|
|
|
|
|
from rich.table import Table
|
|
|
|
|
|
|
|
|
|
DOCS_DIR = Path(__file__).parent.parent / "docs"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def extract_frontmatter(file_path: Path) -> dict | None:
|
|
|
|
|
"""Extract YAML frontmatter from a markdown file."""
|
|
|
|
|
content = file_path.read_text()
|
|
|
|
|
if not content.startswith("---"):
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
end_idx = content.find("---", 3)
|
|
|
|
|
if end_idx == -1:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
frontmatter_text = content[3:end_idx].strip()
|
|
|
|
|
try:
|
|
|
|
|
return yaml.safe_load(frontmatter_text) or {}
|
|
|
|
|
except yaml.YAMLError:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_last_reviewed(frontmatter: dict) -> date | None:
|
|
|
|
|
"""Extract last-reviewed date from frontmatter."""
|
|
|
|
|
raw = frontmatter.get("last-reviewed")
|
|
|
|
|
if raw is None:
|
|
|
|
|
return None
|
|
|
|
|
if isinstance(raw, date):
|
|
|
|
|
return raw
|
|
|
|
|
try:
|
|
|
|
|
return date.fromisoformat(str(raw))
|
|
|
|
|
except ValueError:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
2026-03-17 13:22:01 -07:00
|
|
|
def git_last_modified(file_path: Path) -> datetime | None:
|
|
|
|
|
"""Get the last git commit date for a file."""
|
|
|
|
|
try:
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
["git", "log", "-1", "--format=%aI", "--", str(file_path)],
|
|
|
|
|
capture_output=True,
|
|
|
|
|
text=True,
|
|
|
|
|
check=True,
|
|
|
|
|
)
|
|
|
|
|
date_str = result.stdout.strip()
|
|
|
|
|
if not date_str:
|
|
|
|
|
return None
|
|
|
|
|
return datetime.fromisoformat(date_str)
|
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
2026-02-09 07:29:45 -08:00
|
|
|
def main(
|
|
|
|
|
limit: Annotated[int, typer.Option(help="Number of docs to show in the table")] = 15,
|
|
|
|
|
) -> None:
|
|
|
|
|
console = Console()
|
|
|
|
|
today = date.today()
|
|
|
|
|
|
2026-03-17 13:22:01 -07:00
|
|
|
entries: list[tuple[str, date | None, datetime | None, Path]] = []
|
2026-02-09 07:29:45 -08:00
|
|
|
|
|
|
|
|
for md_file in sorted(DOCS_DIR.rglob("*.md")):
|
|
|
|
|
if "changelog.d" in md_file.parts:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
frontmatter = extract_frontmatter(md_file)
|
|
|
|
|
last_reviewed = get_last_reviewed(frontmatter) if frontmatter else None
|
2026-03-17 13:22:01 -07:00
|
|
|
last_updated = git_last_modified(md_file)
|
2026-02-09 07:29:45 -08:00
|
|
|
rel_path = str(md_file.relative_to(DOCS_DIR))
|
2026-03-17 13:22:01 -07:00
|
|
|
entries.append((rel_path, last_reviewed, last_updated, md_file))
|
|
|
|
|
|
|
|
|
|
# Sort: never-reviewed first (None), then oldest reviewed,
|
|
|
|
|
# then least recently updated as tiebreaker
|
|
|
|
|
entries.sort(key=lambda e: (
|
|
|
|
|
e[1] is not None,
|
|
|
|
|
e[1] or date.min,
|
|
|
|
|
e[2] or datetime.min.replace(tzinfo=timezone.utc),
|
|
|
|
|
))
|
2026-02-09 07:29:45 -08:00
|
|
|
|
|
|
|
|
never_reviewed = sum(1 for e in entries if e[1] is None)
|
|
|
|
|
|
|
|
|
|
# --- Staleness table ---
|
|
|
|
|
console.print()
|
|
|
|
|
console.print(Panel(
|
|
|
|
|
f"[bold]{len(entries)}[/bold] total docs, "
|
|
|
|
|
f"[bold red]{never_reviewed}[/bold red] never reviewed",
|
|
|
|
|
title="[bold]Documentation Review Queue[/bold]",
|
|
|
|
|
border_style="cyan",
|
|
|
|
|
))
|
|
|
|
|
console.print()
|
|
|
|
|
|
|
|
|
|
table = Table(show_header=True, header_style="bold")
|
|
|
|
|
table.add_column("#", justify="right")
|
|
|
|
|
table.add_column("File")
|
|
|
|
|
table.add_column("Last Reviewed", justify="right")
|
|
|
|
|
table.add_column("Age (days)", justify="right")
|
2026-03-17 13:22:01 -07:00
|
|
|
table.add_column("Last Updated", justify="right")
|
2026-02-09 07:29:45 -08:00
|
|
|
|
2026-03-17 13:22:01 -07:00
|
|
|
for i, (rel_path, last_reviewed, last_updated, _) in enumerate(entries[:limit], 1):
|
|
|
|
|
updated_str = last_updated.strftime("%Y-%m-%d") if last_updated else "?"
|
2026-02-09 07:29:45 -08:00
|
|
|
if last_reviewed is None:
|
|
|
|
|
table.add_row(
|
|
|
|
|
str(i),
|
|
|
|
|
f"[red]{rel_path}[/red]",
|
|
|
|
|
"[red]never[/red]",
|
|
|
|
|
"[red]—[/red]",
|
2026-03-17 13:22:01 -07:00
|
|
|
updated_str,
|
2026-02-09 07:29:45 -08:00
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
age = (today - last_reviewed).days
|
|
|
|
|
style = "yellow" if age > 90 else ""
|
|
|
|
|
age_str = f"[{style}]{age}[/{style}]" if style else str(age)
|
|
|
|
|
path_str = f"[{style}]{rel_path}[/{style}]" if style else rel_path
|
|
|
|
|
date_str = f"[{style}]{last_reviewed}[/{style}]" if style else str(last_reviewed)
|
2026-03-17 13:22:01 -07:00
|
|
|
table.add_row(str(i), path_str, date_str, age_str, updated_str)
|
2026-02-09 07:29:45 -08:00
|
|
|
|
|
|
|
|
remaining = len(entries) - limit
|
|
|
|
|
if remaining > 0:
|
2026-03-17 13:22:01 -07:00
|
|
|
table.add_row("", f"[dim]… {remaining} more[/dim]", "", "", "")
|
2026-02-09 07:29:45 -08:00
|
|
|
|
|
|
|
|
console.print(table)
|
|
|
|
|
console.print()
|
|
|
|
|
|
|
|
|
|
# --- Show the most stale doc ---
|
|
|
|
|
if not entries:
|
|
|
|
|
console.print("[bold red]No documentation files found![/bold red]")
|
|
|
|
|
raise typer.Exit(code=1)
|
|
|
|
|
|
2026-03-17 13:22:01 -07:00
|
|
|
top_path, top_reviewed, _, top_file = entries[0]
|
2026-02-09 07:29:45 -08:00
|
|
|
console.print(Panel(
|
|
|
|
|
f"[bold cyan]{top_path}[/bold cyan]\n"
|
|
|
|
|
+ (f"[dim]Last reviewed: {top_reviewed}[/dim]" if top_reviewed else "[dim red]Never reviewed[/dim red]"),
|
|
|
|
|
title="[bold]Up For Review[/bold]",
|
|
|
|
|
border_style="green",
|
|
|
|
|
))
|
|
|
|
|
console.print()
|
|
|
|
|
|
2026-02-26 07:24:37 -08:00
|
|
|
console.print(f"[bold]Read the file:[/bold] {top_file.resolve()}")
|
|
|
|
|
console.print()
|
2026-02-09 07:29:45 -08:00
|
|
|
|
|
|
|
|
console.print()
|
|
|
|
|
console.print(Panel(
|
|
|
|
|
"[bold]Review Checklist:[/bold]\n\n"
|
|
|
|
|
"• Is the information accurate and up-to-date?\n"
|
|
|
|
|
"• Are there broken or missing wiki-links?\n"
|
|
|
|
|
"• Should this card link to other related cards?\n"
|
|
|
|
|
"• Is the card too large and should be split?\n"
|
|
|
|
|
"• Is the card too small and should be merged?\n"
|
|
|
|
|
"• Does the frontmatter (tags, title) make sense?\n"
|
|
|
|
|
"• Is the card in the correct category (reference/how-to/etc)?\n\n"
|
|
|
|
|
"[bold]Verify Deployed State:[/bold]\n\n"
|
|
|
|
|
"• If ArgoCD app: is it synced? (argocd app get <app>)\n"
|
|
|
|
|
"• If Ansible role: does it apply idempotently? (--check --diff)\n"
|
|
|
|
|
"• If Pulumi: is there drift? (pulumi preview)\n\n"
|
|
|
|
|
"[bold]After Review:[/bold]\n\n"
|
|
|
|
|
"• Update the card's frontmatter: [cyan]last-reviewed: "
|
|
|
|
|
+ str(today)
|
|
|
|
|
+ "[/cyan]\n"
|
2026-03-11 18:11:34 -07:00
|
|
|
"• Commit the change (along with any fixes)\n"
|
|
|
|
|
"• User: run [cyan]mise run docs-preview <card-path>[/cyan] for a rendered visual check",
|
2026-02-09 07:29:45 -08:00
|
|
|
title="[bold yellow]Review Guidance[/bold yellow]",
|
|
|
|
|
border_style="yellow",
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
typer.run(main)
|