Skip to content

Commit 96410a6

Browse files
Revert "[Github] Fetch all commits in PR for code formatting checks (#69766)"
This reverts commit 4aa12af. This change introduced failures upon checking out the PR source code. Pulling this out of tree while I investigate further.
1 parent 4aa12af commit 96410a6

File tree

1 file changed

+13
-33
lines changed

1 file changed

+13
-33
lines changed

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

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,17 @@ jobs:
77
code_formatter:
88
runs-on: ubuntu-latest
99
steps:
10-
# Get changed files before checking out the repository to force the action
11-
# to analyze the diff from the Github API rather than looking at the
12-
# shallow clone and erroring out, which is significantly more prone to
13-
# failure.
10+
- name: Fetch LLVM sources
11+
uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 2
14+
1415
- name: Get changed files
1516
id: changed-files
1617
uses: tj-actions/changed-files@v39
1718
with:
1819
separator: ","
19-
20-
- name: Calculate number of commits to fetch
21-
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
22-
23-
- name: Fetch PR sources
24-
uses: actions/checkout@v4
25-
with:
26-
ref: ${{ github.event.pull_request.head.ref }}
27-
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
28-
path: pr-sources
29-
30-
# We need to make sure that we aren't executing/using any code from the
31-
# PR for security reasons as we're using pull_request_target. Checkout
32-
# the target branch with the necessary files.
33-
- name: Fetch LLVM Sources
34-
uses: actions/checkout@v4
35-
with:
36-
sparse-checkout: |
37-
llvm/utils/git/requirements_formatting.txt
38-
llvm/utils/git/code-format-helper.py
39-
sparse-checkout-cone-mode: false
40-
path: llvm-sources
20+
fetch_depth: 100 # Fetches only the last 10 commits
4121

4222
- name: "Listed files"
4323
run: |
@@ -54,21 +34,21 @@ jobs:
5434
with:
5535
python-version: '3.11'
5636
cache: 'pip'
57-
cache-dependency-path: 'llvm-sources/llvm/utils/git/requirements_formatting.txt'
37+
cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
5838

5939
- name: Install python dependencies
60-
run: pip install -r llvm-sources/llvm/utils/git/requirements_formatting.txt
40+
run: pip install -r llvm/utils/git/requirements_formatting.txt
6141

6242
- name: Run code formatter
6343
env:
6444
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
65-
PR_DEPTH: ${{ github.event.pull_request.commits }}
45+
START_REV: ${{ github.event.pull_request.base.sha }}
46+
END_REV: ${{ github.event.pull_request.head.sha }}
6647
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
67-
working-directory: ./pr-sources
6848
run: |
69-
python ../llvm-sources/llvm/utils/git/code-format-helper.py \
49+
python llvm/utils/git/code-format-helper.py \
7050
--token ${{ secrets.GITHUB_TOKEN }} \
7151
--issue-number $GITHUB_PR_NUMBER \
72-
--start-rev HEAD~$PR_DEPTH \
73-
--end-rev HEAD \
52+
--start-rev $START_REV \
53+
--end-rev $END_REV \
7454
--changed-files "$CHANGED_FILES"

0 commit comments

Comments
 (0)