Skip to content

Commit 2898c3e

Browse files
[Github] Simplify Getting Changed Files in Code Formatting Workflow (#133023)
This patch changes getting changed files in the pr code format job to just checking out the previous two commits (the merge commit and its porent, the current commit latest in main), which allows us to just diff the merge commit. This means we do not have to checkout the ref through the merge base, which should save approximately a minute per job (or much more in some cases where the PR is particularly out of date).
1 parent 31fe0d2 commit 2898c3e

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

.github/workflows/pr-code-format.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,16 @@ jobs:
2121
- name: Fetch LLVM sources
2222
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2323
with:
24-
ref: ${{ github.event.pull_request.head.sha }}
25-
26-
- name: Checkout through merge base
27-
uses: rmacklin/fetch-through-merge-base@bfe4d03a86f9afa52bc1a70e9814fc92a07f7b75 # v0.3.0
28-
with:
29-
base_ref: ${{ github.event.pull_request.base.ref }}
30-
head_ref: ${{ github.event.pull_request.head.sha }}
31-
deepen_length: 500
24+
fetch-depth: 2
3225

3326
- name: Get changed files
3427
id: changed-files
3528
uses: step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
3629
with:
3730
separator: ","
3831
skip_initial_fetch: true
32+
base_sha: 'HEAD~1'
33+
sha: 'HEAD'
3934

4035
# We need to pull the script from the main branch, so that we ensure
4136
# we get the latest version of this script.
@@ -89,8 +84,8 @@ jobs:
8984
--write-comment-to-file \
9085
--token ${{ secrets.GITHUB_TOKEN }} \
9186
--issue-number $GITHUB_PR_NUMBER \
92-
--start-rev $(git merge-base $START_REV $END_REV) \
93-
--end-rev $END_REV \
87+
--start-rev HEAD~1 \
88+
--end-rev HEAD \
9489
--changed-files "$CHANGED_FILES"
9590
9691
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0

0 commit comments

Comments
 (0)