- forge.yaml: the repository's host (Gitea at git.kenschiano.net, limited visibility); the "Report a run" collector, the page's links (data/public/links.json, filled in by site/build.js) and the dataset metadata read it - collection/etl/forge.py: issues, pull requests (merge when checks succeed) and labels for Gitea and GitHub; `python -m collection forge ...` - .gitea/workflows: CI and the daily update (pushes a branch, opens a pull request that merges itself, opens an issue when a source breaks); .github/workflows kept for GitHub - docs: Gitea setup (REPO_SETTINGS), the bot reading atlas files from the repository Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""Files written from the declarative specs, so each rule has one source of truth:
|
|
.github/ISSUE_TEMPLATE/report-a-run.yml from collection/specs/report_form.yaml (report_form.render)
|
|
the CROSSWALK block of core/graph.js from collection/specs/bot.yaml (Ken's bot uses it at run time)
|
|
"""
|
|
import json
|
|
|
|
from . import forge
|
|
from .common import path, read_yaml
|
|
|
|
LINKS = "data/public/links.json"
|
|
|
|
|
|
def links():
|
|
"""The links the page shows, from forge.yaml and pipeline.yaml (site/build.js fills them into the page)."""
|
|
f = forge.config()
|
|
src = read_yaml("collection/pipeline.yaml")["sources"]
|
|
host = f["url"].split("://", 1)[-1].rstrip("/")
|
|
return {
|
|
"repo": forge.repo_url(f), "repo_label": f"{host}/{f['repo']}", "host": host, "kind": f["kind"],
|
|
"visibility": f.get("visibility", "public"),
|
|
"report": forge.new_issue_url(".github/ISSUE_TEMPLATE/report-a-run.yml", f),
|
|
"form": src["reddit_spreadsheet"]["links"]["form"], "sheet": src["reddit_spreadsheet"]["links"]["sheet"],
|
|
}
|
|
|
|
GRAPH_JS = "core/graph.js"
|
|
BEGIN = " // BEGIN CROSSWALK"
|
|
END = " // END CROSSWALK\n"
|
|
|
|
|
|
def graph_js():
|
|
"""core/graph.js with its CROSSWALK block rewritten from the bot spec."""
|
|
text = path(GRAPH_JS).read_text(encoding="utf-8")
|
|
a = text.index(BEGIN)
|
|
a = text.index("\n", a) + 1
|
|
b = text.index(END, a)
|
|
rules = read_yaml("collection/specs/bot.yaml")["crosswalk"]
|
|
lines = [" const CROSSWALK = ["]
|
|
for i, (rx, col, val) in enumerate(rules):
|
|
sep = "," if i < len(rules) - 1 else ""
|
|
lines.append(f" [/{rx.replace('/', chr(92) + '/')}/, {json.dumps(col)}, {json.dumps(val, ensure_ascii=False)}]{sep}")
|
|
lines.append(" ];")
|
|
return text[:a] + "\n".join(lines) + "\n" + text[b:]
|