diff --git a/.github/workflows/llgo-binary-size-pages.yml b/.github/workflows/llgo-binary-size-pages.yml index 130dc2b..f634198 100644 --- a/.github/workflows/llgo-binary-size-pages.yml +++ b/.github/workflows/llgo-binary-size-pages.yml @@ -39,11 +39,28 @@ jobs: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail + set -a + source ci/llgo-size/llgo-version.env + set +a + + # Rebuild every stored run's main position from the complete LLGo + # first-parent history. Result jobs may have been created from old or + # shallow checkouts, so their embedded index is only a hint. + git clone --filter=blob:none --no-checkout --single-branch --branch main \ + "https://github.com/${LLGO_REPOSITORY}.git" \ + "$GITHUB_WORKSPACE/.ci/llgo-history" + git -C "$GITHUB_WORKSPACE/.ci/llgo-history" \ + rev-list --first-parent --reverse origin/main \ + > "$GITHUB_WORKSPACE/.ci/llgo-main-history.txt" + pages_dir="$GITHUB_WORKSPACE/.ci/pages" bash ci/llgo-size/prepare-pages-branch.sh \ "$pages_dir" \ "https://x-access-token:${PAGES_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - ci/llgo-size/publish-site.sh "$pages_dir" ci/llgo-size/site + ci/llgo-size/publish-site.sh \ + "$pages_dir" \ + ci/llgo-size/site \ + "$GITHUB_WORKSPACE/.ci/llgo-main-history.txt" deploy-pages: if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' diff --git a/.github/workflows/llgo-binary-size.yml b/.github/workflows/llgo-binary-size.yml index 821acc8..635f7db 100644 --- a/.github/workflows/llgo-binary-size.yml +++ b/.github/workflows/llgo-binary-size.yml @@ -281,7 +281,10 @@ jobs: git -C .ci/llgo fetch --progress --no-tags --depth=1 origin "$LLGO_COMMIT" time_command "Check out pinned LLGo commit" \ git -C .ci/llgo checkout --detach "$LLGO_COMMIT" - git -C .ci/llgo fetch --no-tags origin main + # The commit-specific depth-1 fetch above makes this repository + # shallow. Unshallow it before assigning first-parent positions; + # otherwise every run appears to be main index 1. + git -C .ci/llgo fetch --no-tags --unshallow origin main git -C .ci/llgo rev-list --first-parent --reverse origin/main > .ci/llgo-main-history.txt llgo_main_index="$(awk -v commit="$LLGO_COMMIT" '$0 == commit { print NR; exit }' \ .ci/llgo-main-history.txt)" diff --git a/ci/llgo-size/publish-site.sh b/ci/llgo-size/publish-site.sh index 56b15a9..f12dc82 100755 --- a/ci/llgo-size/publish-site.sh +++ b/ci/llgo-size/publish-site.sh @@ -4,8 +4,9 @@ set -euo pipefail script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" pages_dir="$1" site_dir="$2" +main_history="${3:-}" if [[ -z "$pages_dir" || -z "$site_dir" ]]; then - echo "usage: publish-site.sh PAGES_DIR SITE_DIR" >&2 + echo "usage: publish-site.sh PAGES_DIR SITE_DIR [LLGO_MAIN_HISTORY]" >&2 exit 2 fi @@ -14,7 +15,11 @@ for file in index.html app.js performance.html performance.js compatibility.html done rm -f "$pages_dir/.nojekyll" if [[ -s "$pages_dir/data/index.json" ]]; then - python3 "$script_dir/enrich_pull_requests.py" "$pages_dir/data/index.json" + enrich_args=("$pages_dir/data/index.json") + if [[ -n "$main_history" && -s "$main_history" ]]; then + enrich_args+=(--main-history "$main_history") + fi + python3 "$script_dir/enrich_pull_requests.py" "${enrich_args[@]}" fi git -C "$pages_dir" config user.name "github-actions[bot]" diff --git a/ci/llgo-size/test_enrich_pull_requests.py b/ci/llgo-size/test_enrich_pull_requests.py index d92be80..e67b218 100644 --- a/ci/llgo-size/test_enrich_pull_requests.py +++ b/ci/llgo-size/test_enrich_pull_requests.py @@ -87,11 +87,13 @@ def test_orders_runs_by_llgo_main_history_instead_of_build_completion(self): { "key": second, "llgoCommit": second, + "llgoMainIndex": 1, "createdAt": "2026-08-21T01:00:00Z", }, { "key": first, "llgoCommit": first, + "llgoMainIndex": 1, "createdAt": "2026-08-21T02:00:00Z", }, ]