diff --git a/.github/workflows/llgo-binary-size.yml b/.github/workflows/llgo-binary-size.yml
index 0a180ce..4f48fef 100644
--- a/.github/workflows/llgo-binary-size.yml
+++ b/.github/workflows/llgo-binary-size.yml
@@ -261,7 +261,9 @@ jobs:
"$pages_dir" \
ci/llgo-size/site
deploy-pages:
- if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
+ if: >-
+ always() && github.ref == 'refs/heads/main' &&
+ github.event_name != 'pull_request' && needs.binary-size.result == 'success'
needs: binary-size
runs-on: ubuntu-24.04
permissions:
diff --git a/ci/llgo-size/README.md b/ci/llgo-size/README.md
index 322f2ee..da9810d 100644
--- a/ci/llgo-size/README.md
+++ b/ci/llgo-size/README.md
@@ -69,6 +69,9 @@ variants. A PR that changes the committed LLGo version runs the full five-way
matrix and uploads the `llgo-binary-size` artifact for review, but still does
not publish history.
+Published history is keyed by the full LLGo commit, so rerunning one commit
+updates its existing entry instead of adding another build-round entry.
+
### First-time repository setup
The first publisher run creates the `pages` branch automatically. Before that
diff --git a/ci/llgo-size/publish.sh b/ci/llgo-size/publish.sh
index f7eb7f9..85e28df 100755
--- a/ci/llgo-size/publish.sh
+++ b/ci/llgo-size/publish.sh
@@ -23,6 +23,46 @@ for legacy in "$pages_dir"/data/runs/*.json; do
mkdir -p "$legacy_dir"
mv "$legacy" "$legacy_dir/results.json"
done
+
+# Consolidate historical runs under the LLGo commit that produced them. This
+# keeps reruns of the same commit as one comparable history entry instead of
+# creating a new entry for every Actions run number.
+python3 - "$pages_dir/data/runs" <<'PY'
+import json
+import os
+import re
+import shutil
+import sys
+
+runs_dir = sys.argv[1]
+for source in sorted(os.listdir(runs_dir)):
+ source_dir = os.path.join(runs_dir, source)
+ result_path = os.path.join(source_dir, "results.json")
+ if not os.path.isdir(source_dir) or not os.path.isfile(result_path):
+ continue
+ try:
+ with open(result_path, encoding="utf-8") as f:
+ run = json.load(f).get("run", {})
+ except (OSError, ValueError):
+ continue
+ key = run.get("llgoCommit") or run.get("sourceCommit") or source
+ if not re.fullmatch(r"[A-Za-z0-9._-]+", str(key)) or str(key) == source:
+ continue
+ target_dir = os.path.join(runs_dir, str(key))
+ if os.path.exists(target_dir):
+ existing_path = os.path.join(target_dir, "results.json")
+ try:
+ with open(existing_path, encoding="utf-8") as f:
+ existing = json.load(f).get("run", {})
+ except (OSError, ValueError):
+ existing = {}
+ if str(run.get("createdAt", "")) >= str(existing.get("createdAt", "")):
+ shutil.rmtree(target_dir)
+ else:
+ shutil.rmtree(source_dir)
+ continue
+ os.rename(source_dir, target_dir)
+PY
cp "$site_dir/index.html" "$pages_dir/index.html"
cp "$site_dir/app.js" "$pages_dir/app.js"
cp "$site_dir/style.css" "$pages_dir/style.css"
@@ -36,9 +76,7 @@ import sys
with open(sys.argv[1], encoding="utf-8") as f:
run = json.load(f)["run"]
-run_id = str(run.get("id") or "manual")
-attempt = run.get("attempt")
-key = run_id if not attempt else run_id + "-" + str(attempt)
+key = str(run.get("llgoCommit") or run.get("sourceCommit") or run.get("id") or "manual")
if not re.fullmatch(r"[A-Za-z0-9._-]+", key):
raise SystemExit("invalid run key: " + repr(key))
print(key)
diff --git a/ci/llgo-size/site/app.js b/ci/llgo-size/site/app.js
index 01cae1f..8f2915a 100644
--- a/ci/llgo-size/site/app.js
+++ b/ci/llgo-size/site/app.js
@@ -80,8 +80,12 @@ function runNumber(run) {
return run.number == null ? run.key : "#" + run.number;
}
+function commitLabel(run) {
+ return shortSha(run.llgoCommit || run.sourceCommit || run.key);
+}
+
function runLabel(run) {
- return runNumber(run) + " · " + dateLabel(run.createdAt);
+ return commitLabel(run) + " · " + dateLabel(run.createdAt);
}
async function loadRun(meta) {
@@ -154,8 +158,8 @@ function renderComparison(newer, baseline) {
const baselineByName = baseline ? benchmarkMap(baseline) : new Map();
const benchmarkNames = Array.from(new Set(Array.from(newerByName.keys()).concat(Array.from(baselineByName.keys())))).sort();
- const newerHeading = "Newer · " + runNumber(newer.run);
- const baselineHeading = baseline ? "Older · " + runNumber(baseline.run) : "Older";
+ const newerHeading = "Newer · " + commitLabel(newer.run);
+ const baselineHeading = baseline ? "Older · " + commitLabel(baseline.run) : "Older";
grid.innerHTML = benchmarkNames.map(function (name) {
const newerBenchmark = newerByName.get(name);
const baselineBenchmark = baselineByName.get(name);
@@ -178,13 +182,10 @@ function renderHistoryTable(runs) {
const body = document.querySelector("#history-body");
body.replaceChildren();
for (const run of runs) {
- const link = run.workflowUrl
- ? '' + escapeHtml(runNumber(run)) + ""
- : escapeHtml(runNumber(run));
const row = document.createElement("tr");
row.innerHTML =
- "
" + link + "" + escapeHtml(dateLabel(run.createdAt)) + " | " +
- "" + escapeHtml(shortSha(run.llgoCommit)) + " | " +
+ "" + (run.workflowUrl ? '' : "") + escapeHtml(commitLabel(run)) + (run.workflowUrl ? "" : "") + " | " +
+ "" + escapeHtml(dateLabel(run.createdAt)) + " | " +
"" + escapeHtml(run.goVersion || "—") + " | " +
"" + escapeHtml(run.llvmVersion || "—") + " | " +
"" + escapeHtml(run.ref || "—") + " | ";
@@ -238,11 +239,11 @@ function renderHistoryChart(name, documents) {
const color = seriesColors[configIndex % seriesColors.length];
return '' + points.map(function (point) {
return '' +
- escapeHtml(name + " · " + config + " · " + runNumber(point.document.run) + ": " + formatBytes(point.value)) + "";
+ escapeHtml(name + " · " + config + " · " + commitLabel(point.document.run) + ": " + formatBytes(point.value)) + "";
}).join("");
}).join("");
const labels = documents.map(function (document, index) {
- return '' + escapeHtml(runNumber(document.run)) + "";
+ return '' + escapeHtml(commitLabel(document.run)) + "";
}).join("");
const legend = configs.map(function (config, index) {
return '' + escapeHtml(configLabels[config] || config) + "";
diff --git a/ci/llgo-size/site/index.html b/ci/llgo-size/site/index.html
index 90d158d..a0f44fd 100644
--- a/ci/llgo-size/site/index.html
+++ b/ci/llgo-size/site/index.html
@@ -4,7 +4,7 @@
LLGo binary-size history
-
+
@@ -47,7 +47,7 @@ Size history
- | Run | LLGo commit | Go | LLVM | Workflow |
+ | LLGo commit | Created | Go | LLVM | Workflow |
@@ -59,6 +59,6 @@ Size history
Raw run index
-
+