From 22588a32ca3e28428b51c1651b4ff3c5feb71988 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Wed, 1 Apr 2026 18:08:38 +0200 Subject: [PATCH 1/3] gh-146488: find correct merge base in check-html-ids --- .github/workflows/reusable-check-html-ids.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-check-html-ids.yml b/.github/workflows/reusable-check-html-ids.yml index 4a1d321a8ce83e..23666a60687aed 100644 --- a/.github/workflows/reusable-check-html-ids.yml +++ b/.github/workflows/reusable-check-html-ids.yml @@ -15,11 +15,18 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - name: 'Check out base commit' + - name: 'Find merge base' + id: merge-base + env: + GH_TOKEN: ${{ github.token }} + run: | + MERGE_BASE=$(gh api repos/${{ github.repository }}/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} --jq '.merge_base_commit.sha') + echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT" + - name: 'Check out merge base' uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - ref: ${{ github.event.pull_request.base.sha }} + ref: ${{ steps.merge-base.outputs.sha }} - name: 'Set up Python' uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: From 45408fd60042bba218079d74a8ae7284bbc9692e Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Wed, 1 Apr 2026 18:19:01 +0200 Subject: [PATCH 2/3] Trigger docs CI on changes --- Tools/build/compute-changes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/build/compute-changes.py b/Tools/build/compute-changes.py index c15dc599f993f3..2cb8cb6fbb49d4 100644 --- a/Tools/build/compute-changes.py +++ b/Tools/build/compute-changes.py @@ -235,7 +235,7 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: run_tests = run_ci_fuzz = run_ci_fuzz_stdlib = run_windows_tests = True has_platform_specific_change = False continue - if file.name == "reusable-docs.yml": + if file.name in ("reusable-docs.yml", "reusable-check-html-ids.yml"): run_docs = True continue if file.name == "reusable-windows.yml": From 208a3a3d01c2cc2ccf963fdd228933d11931ae96 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 2 Apr 2026 21:27:31 +0200 Subject: [PATCH 3/3] Rewrite to use the Ansible approach --- .github/workflows/reusable-check-html-ids.yml | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/.github/workflows/reusable-check-html-ids.yml b/.github/workflows/reusable-check-html-ids.yml index 23666a60687aed..4f827c55cacd06 100644 --- a/.github/workflows/reusable-check-html-ids.yml +++ b/.github/workflows/reusable-check-html-ids.yml @@ -15,18 +15,33 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: + - name: 'Check out PR head' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + ref: ${{ github.event.pull_request.head.sha }} - name: 'Find merge base' id: merge-base - env: - GH_TOKEN: ${{ github.token }} run: | - MERGE_BASE=$(gh api repos/${{ github.repository }}/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} --jq '.merge_base_commit.sha') + BASE="${{ github.event.pull_request.base.sha }}" + HEAD="${{ github.event.pull_request.head.sha }}" + git fetch --depth=$((${{ github.event.pull_request.commits }} + 10)) --no-tags origin "$BASE" "$HEAD" + + if ! MERGE_BASE=$(git merge-base "$BASE" "$HEAD" 2>/dev/null); then + git fetch --deepen=1 --no-tags origin "$BASE" "$HEAD" + + OLDEST=$(git rev-list --reflog --max-parents=0 --reverse "${BASE}^" "${HEAD}^" | head -1) + TIMESTAMP=$(git show --format=%at --no-patch "$OLDEST") + + git fetch --shallow-since="$TIMESTAMP" --no-tags origin "$BASE" "$HEAD" + + MERGE_BASE=$(git merge-base "$BASE" "$HEAD") + fi echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT" - - name: 'Check out merge base' - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - ref: ${{ steps.merge-base.outputs.sha }} + - name: 'Create worktree at merge base' + env: + MERGE_BASE: ${{ steps.merge-base.outputs.sha }} + run: git worktree add /tmp/merge-base "$MERGE_BASE" --detach - name: 'Set up Python' uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: @@ -34,24 +49,11 @@ jobs: cache: 'pip' cache-dependency-path: 'Doc/requirements.txt' - name: 'Install build dependencies' - run: make -C Doc/ venv + run: make -C /tmp/merge-base/Doc/ venv - name: 'Build HTML documentation' - run: make -C Doc/ SPHINXOPTS="--quiet" html - - name: 'Check out PR head tools' - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - sparse-checkout: | - Doc/tools/check-html-ids.py - Doc/tools/removed-ids.txt - sparse-checkout-cone-mode: false - path: pr-head - - name: 'Use PR head tools' - run: | - cp pr-head/Doc/tools/check-html-ids.py Doc/tools/check-html-ids.py - [ -f pr-head/Doc/tools/removed-ids.txt ] && cp pr-head/Doc/tools/removed-ids.txt Doc/tools/removed-ids.txt + run: make -C /tmp/merge-base/Doc/ SPHINXOPTS="--quiet" html - name: 'Collect HTML IDs' - run: python Doc/tools/check-html-ids.py collect Doc/build/html -o /tmp/html-ids-base.json.gz + run: python Doc/tools/check-html-ids.py collect /tmp/merge-base/Doc/build/html -o /tmp/html-ids-base.json.gz - name: 'Download PR head HTML IDs' uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: