Skip to content

Commit 208a3a3

Browse files
Rewrite to use the Ansible approach
1 parent 45408fd commit 208a3a3

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,45 @@ jobs:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 30
1717
steps:
18+
- name: 'Check out PR head'
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
with:
21+
persist-credentials: false
22+
ref: ${{ github.event.pull_request.head.sha }}
1823
- name: 'Find merge base'
1924
id: merge-base
20-
env:
21-
GH_TOKEN: ${{ github.token }}
2225
run: |
23-
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')
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
2440
echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT"
25-
- name: 'Check out merge base'
26-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27-
with:
28-
persist-credentials: false
29-
ref: ${{ steps.merge-base.outputs.sha }}
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
3045
- name: 'Set up Python'
3146
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3247
with:
3348
python-version: '3'
3449
cache: 'pip'
3550
cache-dependency-path: 'Doc/requirements.txt'
3651
- name: 'Install build dependencies'
37-
run: make -C Doc/ venv
52+
run: make -C /tmp/merge-base/Doc/ venv
3853
- name: 'Build HTML documentation'
39-
run: make -C Doc/ SPHINXOPTS="--quiet" html
40-
- name: 'Check out PR head tools'
41-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
42-
with:
43-
persist-credentials: false
44-
sparse-checkout: |
45-
Doc/tools/check-html-ids.py
46-
Doc/tools/removed-ids.txt
47-
sparse-checkout-cone-mode: false
48-
path: pr-head
49-
- name: 'Use PR head tools'
50-
run: |
51-
cp pr-head/Doc/tools/check-html-ids.py Doc/tools/check-html-ids.py
52-
[ -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
5355
- name: 'Collect HTML IDs'
54-
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
5557
- name: 'Download PR head HTML IDs'
5658
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
5759
with:

0 commit comments

Comments
 (0)