Skip to content

Commit c43b490

Browse files
gh-145000: Find correct merge base in reusable-check-html-ids.yml workflow (#147975)
1 parent 8bf8bf9 commit c43b490

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

.github/workflows/reusable-check-html-ids.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,45 @@ jobs:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 30
1717
steps:
18-
- name: 'Check out base commit'
18+
- name: 'Check out PR head'
1919
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2020
with:
2121
persist-credentials: false
22-
ref: ${{ github.event.pull_request.base.sha }}
22+
ref: ${{ github.event.pull_request.head.sha }}
23+
- name: 'Find merge base'
24+
id: merge-base
25+
run: |
26+
BASE="${{ github.event.pull_request.base.sha }}"
27+
HEAD="${{ github.event.pull_request.head.sha }}"
28+
git fetch --depth=$((${{ github.event.pull_request.commits }} + 10)) --no-tags origin "$BASE" "$HEAD"
29+
30+
if ! MERGE_BASE=$(git merge-base "$BASE" "$HEAD" 2>/dev/null); then
31+
git fetch --deepen=1 --no-tags origin "$BASE" "$HEAD"
32+
33+
OLDEST=$(git rev-list --reflog --max-parents=0 --reverse "${BASE}^" "${HEAD}^" | head -1)
34+
TIMESTAMP=$(git show --format=%at --no-patch "$OLDEST")
35+
36+
git fetch --shallow-since="$TIMESTAMP" --no-tags origin "$BASE" "$HEAD"
37+
38+
MERGE_BASE=$(git merge-base "$BASE" "$HEAD")
39+
fi
40+
echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT"
41+
- name: 'Create worktree at merge base'
42+
env:
43+
MERGE_BASE: ${{ steps.merge-base.outputs.sha }}
44+
run: git worktree add /tmp/merge-base "$MERGE_BASE" --detach
2345
- name: 'Set up Python'
2446
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2547
with:
2648
python-version: '3'
2749
cache: 'pip'
2850
cache-dependency-path: 'Doc/requirements.txt'
2951
- name: 'Install build dependencies'
30-
run: make -C Doc/ venv
52+
run: make -C /tmp/merge-base/Doc/ venv
3153
- name: 'Build HTML documentation'
32-
run: make -C Doc/ SPHINXOPTS="--quiet" html
33-
- name: 'Check out PR head tools'
34-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35-
with:
36-
persist-credentials: false
37-
sparse-checkout: |
38-
Doc/tools/check-html-ids.py
39-
Doc/tools/removed-ids.txt
40-
sparse-checkout-cone-mode: false
41-
path: pr-head
42-
- name: 'Use PR head tools'
43-
run: |
44-
cp pr-head/Doc/tools/check-html-ids.py Doc/tools/check-html-ids.py
45-
[ -f pr-head/Doc/tools/removed-ids.txt ] && cp pr-head/Doc/tools/removed-ids.txt Doc/tools/removed-ids.txt
54+
run: make -C /tmp/merge-base/Doc/ SPHINXOPTS="--quiet" html
4655
- name: 'Collect HTML IDs'
47-
run: python Doc/tools/check-html-ids.py collect Doc/build/html -o /tmp/html-ids-base.json.gz
56+
run: python Doc/tools/check-html-ids.py collect /tmp/merge-base/Doc/build/html -o /tmp/html-ids-base.json.gz
4857
- name: 'Download PR head HTML IDs'
4958
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
5059
with:

Tools/build/compute-changes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
238238
run_tests = run_ci_fuzz = run_ci_fuzz_stdlib = run_windows_tests = True
239239
has_platform_specific_change = False
240240
continue
241-
if file.name == "reusable-docs.yml":
241+
if file.name in ("reusable-docs.yml", "reusable-check-html-ids.yml"):
242242
run_docs = True
243243
continue
244244
if file.name == "reusable-windows.yml":

0 commit comments

Comments
 (0)