Host on Gitea: forge.yaml, Gitea workflows, host-neutral links

- 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
This commit is contained in:
ekcSchiano
2026-11-12 02:46:17 +00:00
co-authored by Claude Opus 5.5
parent 8713ccff1a
commit 614bfcda7c
20 changed files with 479 additions and 47 deletions
+49
View File
@@ -1,6 +1,7 @@
"""The collection pipeline: extract's raw store, every transform, the coders, validation and the generated files."""
import csv
import json
import re
import os
import shutil
import subprocess
@@ -167,6 +168,54 @@ class Handoff(unittest.TestCase):
json.loads((ROOT / "data/public/policy.json").read_text(encoding="utf-8"))["id"])
class Forge(unittest.TestCase):
GITEA = {"kind": "gitea", "url": "https://git.example.net/", "repo": "me/threshing-atlas", "branch": "main"}
GITHUB = {"kind": "github", "url": "https://github.com", "repo": "me/threshing-atlas", "branch": "main"}
def test_links(self):
from collection.etl import forge
self.assertEqual(forge.file_url("data/x.csv", self.GITEA), "https://git.example.net/me/threshing-atlas/raw/branch/main/data/x.csv")
self.assertEqual(forge.file_url("data/x.csv", self.GITHUB), "https://raw.githubusercontent.com/me/threshing-atlas/main/data/x.csv")
self.assertIn("template=.github/ISSUE_TEMPLATE/report-a-run.yml", forge.new_issue_url(".github/ISSUE_TEMPLATE/report-a-run.yml", self.GITEA))
self.assertTrue(forge.new_issue_url(".github/ISSUE_TEMPLATE/report-a-run.yml", self.GITHUB).endswith("template=report-a-run.yml"))
self.assertEqual(forge.api_base(self.GITEA), "https://git.example.net/api/v1/repos/me/threshing-atlas")
def test_gitea_calls(self):
from collection.etl import forge
calls = []
def fake(method, url, body=None, tok=None, f=None):
calls.append((method, url, body, tok))
if url.endswith("/pulls"):
return {"number": 7}
if "/issues?" in url:
page = int(url.rsplit("page=", 1)[1])
return [{"number": 50 * (page - 1) + i, "body": "", "labels": [], "state": "open"} for i in range(50 if page == 1 else 3)]
return None
old = forge._call
forge._call = fake
try:
issues = forge.list_issues("run report", {"ATLAS_BOT_TOKEN": "t"}, self.GITEA)
self.assertEqual(len(issues), 53)
self.assertIsNone(issues[0]["state_reason"])
self.assertIn("type=issues", calls[0][1])
self.assertEqual(forge.open_pr("data/x", "T", "B", True, {"ATLAS_BOT_TOKEN": "t"}, self.GITEA), 7)
merge = calls[-1]
self.assertTrue(merge[1].endswith("/pulls/7/merge") and merge[2]["merge_when_checks_succeed"])
self.assertEqual(merge[3], "t")
finally:
forge._call = old
def test_page_links_follow_forge_yaml(self):
from collection.etl import codegen, forge
links = codegen.links()
self.assertEqual(links["repo"], forge.repo_url())
self.assertTrue(links["report"].startswith(forge.repo_url()))
page = (ROOT / "site/atlas/index.html").read_text(encoding="utf-8")
for key in set(re.findall(r"\{\{(\w+)\}\}", page)):
self.assertIn(key, links)
class Sheets(unittest.TestCase):
def test_privacy_rules(self):
p = TMP / "sheet.csv"