Skip to content

Commit 3a8f51b

Browse files
authored
[github] Fix checkout of PR base commit in pr.yml (#4601)
1 parent d483bf3 commit 3a8f51b

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

.github/workflows/pr.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ jobs:
1515
permissions:
1616
pull-requests: write
1717
steps:
18-
- uses: actions/checkout@v5
18+
- uses: actions/checkout@v6
1919
with:
2020
persist-credentials: false
21-
- uses: actions/setup-node@v3
21+
# When running a pull_request job, GitHub generates a merge commit that merges the PR
22+
# with the latest commit on the target branch. By default, actions/checkout shallowly
23+
# checks out only the merge commit. We want to fetch the two parent commits as well.
24+
fetch-depth: 2
25+
- uses: actions/setup-node@v6
2226
with:
2327
node-version: '16.x'
2428
- run: npm ci
@@ -28,7 +32,7 @@ jobs:
2832
- name: copy out-wpt to wpt tree
2933
run: |
3034
git clone --depth 2 https://github.com/web-platform-tests/wpt.git
31-
rsync -av out-wpt/ wpt/webgpu
35+
rsync -av out-wpt/ wpt/webgpu
3236
- name: adding wpt lint ignore rule for *.bin
3337
run: 'echo "TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.bin" >> wpt/lint.ignore'
3438
- name: test wpt lint
@@ -38,11 +42,12 @@ jobs:
3842
run: |
3943
tools/validate --print-case-count-report src/webgpu > case-count-report-after.txt
4044
- name: checkout before PR
41-
env:
42-
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
4345
run: |
44-
git fetch origin "${PR_BASE_REF}"
45-
git checkout "${PR_BASE_REF}"
46+
# HEAD will always be a merge commit with 2 parents. HEAD^1 will be the target branch.
47+
# HEAD^2 will be the PR branch. (Log all three, to make it easy to see what's being
48+
# checked out, and also to validate the assumption that there are actually two parents.)
49+
git log --oneline --graph HEAD 'HEAD^1' 'HEAD^2'
50+
git checkout 'HEAD^1'
4651
- name: compute case count before PR and diff
4752
id: case_count_diff
4853
run: |

0 commit comments

Comments
 (0)