Follow up to d0858bffa11, add missing REQUIRES x86
[llvm-project.git] / .github / workflows / pr-code-format.yml
blobc27c282eb2a19ae5215c9af41eb348006b927c2f
1 name: "Check code formatting"
2 on: pull_request_target
3 permissions:
4   pull-requests: write
6 jobs:
7   code_formatter:
8     runs-on: ubuntu-latest
9     if: github.repository == 'llvm/llvm-project'
10     steps:
11       - name: Fetch LLVM sources
12         uses: actions/checkout@v4
13         with:
14           ref: ${{ github.event.pull_request.head.sha }}
16       - name: Checkout through merge base
17         uses: rmacklin/fetch-through-merge-base@v0
18         with:
19           base_ref: ${{ github.event.pull_request.base.ref }}
20           head_ref: ${{ github.event.pull_request.head.sha }}
21           deepen_length: 500
23       - name: Get changed files
24         id: changed-files
25         uses: tj-actions/changed-files@v39
26         with:
27           separator: ","
28           skip_initial_fetch: true
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 code formatting utils
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: code-format-tools
42       - name: "Listed files"
43         env:
44           CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
45         run: |
46           echo "Formatting files:"
47           echo "$CHANGED_FILES"
49       - name: Install clang-format
50         uses: aminya/setup-cpp@v1
51         with:
52           clangformat: 17.0.1
54       - name: Setup Python env
55         uses: actions/setup-python@v4
56         with:
57           python-version: '3.11'
58           cache: 'pip'
59           cache-dependency-path: 'code-format-tools/llvm/utils/git/requirements_formatting.txt'
61       - name: Install python dependencies
62         run: pip install -r code-format-tools/llvm/utils/git/requirements_formatting.txt
64       - name: Run code formatter
65         env:
66           GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
67           START_REV: ${{ github.event.pull_request.base.sha }}
68           END_REV: ${{ github.event.pull_request.head.sha }}
69           CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
70         run: |
71           python ./code-format-tools/llvm/utils/git/code-format-helper.py \
72             --token ${{ secrets.GITHUB_TOKEN }} \
73             --issue-number $GITHUB_PR_NUMBER \
74             --start-rev $START_REV \
75             --end-rev $END_REV \
76             --changed-files "$CHANGED_FILES"