From 02965a7f10e6155e266e0a30e67b5e11c785155e Mon Sep 17 00:00:00 2001 From: Seungpyo1007 Date: Tue, 15 Sep 2026 11:29:46 +0900 Subject: [PATCH] feat(site): publish history.json with the record count per data commit The build replays every commit that touched data/cpu and writes its date and record count, so TechAPI's dataset-growth chart can plot this repo over time. Pages checkout now fetches full history for it. --- .github/workflows/deploy-pages.yml | 2 ++ .gitignore | 1 + site/build.py | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index fd75840..d56af16 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -19,6 +19,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # history.json replays every data commit - uses: actions/setup-python@v5 with: python-version: "3.12" diff --git a/.gitignore b/.gitignore index 3396d45..da2305e 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ coverage.xml # Generated site catalog (rebuilt in CI) site/catalog.json +site/history.json # Local GitHub setup helpers (not part of the catalog) .github-setup/ diff --git a/site/build.py b/site/build.py index 407097d..a3a05e4 100644 --- a/site/build.py +++ b/site/build.py @@ -3,12 +3,28 @@ from __future__ import annotations import json +import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parent.parent DATA = ROOT / "data" / "cpu" OUT = Path(__file__).resolve().parent / "catalog.json" +HISTORY = Path(__file__).resolve().parent / "history.json" + + +def git(*args: str) -> str: + return subprocess.run(["git", *args], cwd=ROOT, check=True, capture_output=True, text=True).stdout + + +def build_history() -> list[dict]: + """Record count after every commit that touched data/cpu (needs full clone).""" + points = [] + for line in git("log", "--reverse", "--format=%H %cI", "--", "data/cpu").splitlines(): + sha, date = line.split(" ", 1) + names = git("ls-tree", "-r", "--name-only", sha, "--", "data/cpu").splitlines() + points.append({"sha": sha, "date": date, "count": sum(n.endswith(".json") for n in names)}) + return points def main() -> int: @@ -34,6 +50,9 @@ def main() -> int: ) OUT.write_text(json.dumps(records, indent=2) + "\n", encoding="utf-8") print(f"wrote {OUT} ({len(records)} ES records)") + history = build_history() + HISTORY.write_text(json.dumps({"points": history}, indent=2) + "\n", encoding="utf-8") + print(f"wrote {HISTORY} ({len(history)} points)") return 0