7
7
code_formatter :
8
8
runs-on : ubuntu-latest
9
9
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
+
14
15
- name : Get changed files
15
16
id : changed-files
16
17
uses : tj-actions/changed-files@v39
17
18
with :
18
19
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
41
21
42
22
- name : " Listed files"
43
23
run : |
@@ -54,21 +34,21 @@ jobs:
54
34
with :
55
35
python-version : ' 3.11'
56
36
cache : ' pip'
57
- cache-dependency-path : ' llvm-sources/llvm /utils/git/requirements_formatting.txt'
37
+ cache-dependency-path : ' llvm/utils/git/requirements_formatting.txt'
58
38
59
39
- 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
61
41
62
42
- name : Run code formatter
63
43
env :
64
44
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 }}
66
47
CHANGED_FILES : ${{ steps.changed-files.outputs.all_changed_files }}
67
- working-directory : ./pr-sources
68
48
run : |
69
- python ../llvm-sources/ llvm/utils/git/code-format-helper.py \
49
+ python llvm/utils/git/code-format-helper.py \
70
50
--token ${{ secrets.GITHUB_TOKEN }} \
71
51
--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 \
74
54
--changed-files "$CHANGED_FILES"
0 commit comments