Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / .github / workflows / pr-code-format.yml
blobfa0e69211b14788a9003d831d841c019c0551d70
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     steps:
10       - name: Fetch LLVM sources
11         uses: actions/checkout@v4
12         with:
13           fetch-depth: 2 # Fetches only the last 2 commits
15       - name: Get changed files
16         id: changed-files
17         uses: tj-actions/changed-files@v39
18         with:
19           separator: ","
20           fetch_depth: 2000 # Fetches only the last 2000 commits
22       - name: "Listed files"
23         run: |
24           echo "Formatting files:"
25           echo "${{ steps.changed-files.outputs.all_changed_files }}"
27       - name: Install clang-format
28         uses: aminya/setup-cpp@v1
29         with:
30           clangformat: 17.0.1
32       - name: Setup Python env
33         uses: actions/setup-python@v4
34         with:
35           python-version: '3.11'
36           cache: 'pip'
37           cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
39       - name: Install python dependencies
40         run: pip install -r llvm/utils/git/requirements_formatting.txt
42       - name: Run code formatter
43         env:
44           GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
45           START_REV: ${{ github.event.pull_request.base.sha }}
46           END_REV: ${{ github.event.pull_request.head.sha }}
47           CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
48         run: |
49           python llvm/utils/git/code-format-helper.py \
50             --token ${{ secrets.GITHUB_TOKEN }} \
51             --issue-number $GITHUB_PR_NUMBER \
52             --start-rev $START_REV \
53             --end-rev $END_REV \
54             --changed-files "$CHANGED_FILES"