@@ -3,8 +3,7 @@ name: Reusable check HTML IDs
33on :
44 workflow_call :
55
6- permissions :
7- contents : read
6+ permissions : {}
87
98env :
109 FORCE_COLOR : 1
@@ -15,36 +14,45 @@ jobs:
1514 runs-on : ubuntu-latest
1615 timeout-minutes : 30
1716 steps :
18- - name : ' Check out base commit '
17+ - name : ' Check out PR head '
1918 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2019 with :
2120 persist-credentials : false
22- ref : ${{ github.event.pull_request.base.sha }}
21+ ref : ${{ github.event.pull_request.head.sha }}
22+ - name : ' Find merge base'
23+ id : merge-base
24+ run : |
25+ BASE="${{ github.event.pull_request.base.sha }}"
26+ HEAD="${{ github.event.pull_request.head.sha }}"
27+ git fetch --depth=$((${{ github.event.pull_request.commits }} + 10)) --no-tags origin "$BASE" "$HEAD"
28+
29+ if ! MERGE_BASE=$(git merge-base "$BASE" "$HEAD" 2>/dev/null); then
30+ git fetch --deepen=1 --no-tags origin "$BASE" "$HEAD"
31+
32+ OLDEST=$(git rev-list --reflog --max-parents=0 --reverse "${BASE}^" "${HEAD}^" | head -1)
33+ TIMESTAMP=$(git show --format=%at --no-patch "$OLDEST")
34+
35+ git fetch --shallow-since="$TIMESTAMP" --no-tags origin "$BASE" "$HEAD"
36+
37+ MERGE_BASE=$(git merge-base "$BASE" "$HEAD")
38+ fi
39+ echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT"
40+ - name : ' Create worktree at merge base'
41+ env :
42+ MERGE_BASE : ${{ steps.merge-base.outputs.sha }}
43+ run : git worktree add /tmp/merge-base "$MERGE_BASE" --detach
2344 - name : ' Set up Python'
2445 uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2546 with :
2647 python-version : ' 3'
2748 cache : ' pip'
2849 cache-dependency-path : ' Doc/requirements.txt'
2950 - name : ' Install build dependencies'
30- run : make -C Doc/ venv
51+ run : make -C /tmp/merge-base/ Doc/ venv
3152 - 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
53+ run : make -C /tmp/merge-base/Doc/ SPHINXOPTS="--quiet" html
4654 - name : ' Collect HTML IDs'
47- run : python Doc/tools/check-html-ids.py collect Doc/build/html -o /tmp/html-ids-base.json.gz
55+ run : python Doc/tools/check-html-ids.py collect /tmp/merge-base/ Doc/build/html -o /tmp/html-ids-base.json.gz
4856 - name : ' Download PR head HTML IDs'
4957 uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
5058 with :
0 commit comments