Skip to content

Commit f89641d

Browse files
committed
[workflows] Always pull code-format-helper.py from the main branch
After bc06cd5 we started pulling code-fromat-helper.py from the pull request branch, but if the pull request branch is not up-to-date, then the job will fail, because this workflow is incompatible with the old version of the script. In order to fix this, we need to pull the script from the main branch like we were doing before to ensure that it always gets the latest version of the script.
1 parent dd0356d commit f89641d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ jobs:
2525
separator: ","
2626
skip_initial_fetch: true
2727

28+
# We need to pull the script from the main branch, so that we ensure
29+
# we get a version of the script that supports the --wirte-comment-to-file
30+
# option.
31+
- name: Fetch code formatting utils
32+
uses: actions/checkout@v4
33+
with:
34+
reository: ${{ github.repository }}
35+
ref: ${{ github.base_ref }}
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: code-format-tools
41+
2842
- name: "Listed files"
2943
env:
3044
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
@@ -42,10 +56,10 @@ jobs:
4256
with:
4357
python-version: '3.11'
4458
cache: 'pip'
45-
cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
59+
cache-dependency-path: 'code-format-tools/llvm/utils/git/requirements_formatting.txt'
4660

4761
- name: Install python dependencies
48-
run: pip install -r llvm/utils/git/requirements_formatting.txt
62+
run: pip install -r code-format-tools/llvm/utils/git/requirements_formatting.txt
4963

5064
- name: Run code formatter
5165
env:
@@ -58,7 +72,7 @@ jobs:
5872
# explicitly in code-format-helper.py and not have to diff starting at
5973
# the merge base.
6074
run: |
61-
python ./llvm/utils/git/code-format-helper.py \
75+
python ./code-format-tools/llvm/utils/git/code-format-helper.py \
6276
--write-comment-to-file \
6377
--token ${{ secrets.GITHUB_TOKEN }} \
6478
--issue-number $GITHUB_PR_NUMBER \

0 commit comments

Comments
 (0)