@@ -16,10 +16,30 @@ jobs:
16
16
name : ' Docs'
17
17
runs-on : ubuntu-latest
18
18
timeout-minutes : 60
19
+ env :
20
+ branch_base : ' origin/${{ github.event.pull_request.base.ref }}'
21
+ branch_pr : ' origin/${{ github.event.pull_request.head.ref }}'
22
+ refspec_base : ' +${{ github.event.pull_request.base.sha }}:remotes/origin/${{ github.event.pull_request.base.ref }}'
23
+ refspec_pr : ' +${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}'
19
24
steps :
20
- - uses : actions/checkout@v3
25
+ - name : ' Check out latest PR branch commit'
26
+ uses : actions/checkout@v3
21
27
with :
22
- fetch-depth : 0
28
+ ref : ${{ github.event.pull_request.head.sha }}
29
+ # Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721
30
+ - name : ' Fetch commits to get branch diff'
31
+ run : |
32
+ # Fetch enough history to find a common ancestor commit (aka merge-base):
33
+ git fetch origin ${{ env.refspec_pr }} --depth=$(( ${{ github.event.pull_request.commits }} + 1 )) \
34
+ --no-tags --prune --no-recurse-submodules
35
+
36
+ # This should get the oldest commit in the local fetched history (which may not be the commit the PR branched from):
37
+ COMMON_ANCESTOR=$( git rev-list --first-parent --max-parents=0 --max-count=1 ${{ env.branch_pr }} )
38
+ DATE=$( git log --date=iso8601 --format=%cd "${COMMON_ANCESTOR}" )
39
+
40
+ # Get all commits since that commit date from the base branch (eg: master or main):
41
+ git fetch origin ${{ env.refspec_base }} --shallow-since="${DATE}" \
42
+ --no-tags --prune --no-recurse-submodules
23
43
- name : ' Set up Python'
24
44
uses : actions/setup-python@v4
25
45
with :
40
60
if : github.event_name == 'pull_request'
41
61
run : |
42
62
python Doc/tools/check-warnings.py \
43
- --annotate-diff 'origin/ ${{ github.base_ref }}' '${{ github.sha }}' \
63
+ --annotate-diff '${{ env.branch_base }}' '${{ env.branch_pr }}' \
44
64
--fail-if-regression \
45
65
--fail-if-improved
46
66
0 commit comments