diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml index fa0e69211b14788..acc70c0b5131839 100644 --- a/.github/workflows/pr-code-format.yml +++ b/.github/workflows/pr-code-format.yml @@ -7,17 +7,34 @@ jobs: code_formatter: runs-on: ubuntu-latest steps: - - name: Fetch LLVM sources - uses: actions/checkout@v4 - with: - fetch-depth: 2 # Fetches only the last 2 commits - + # Get changed files before checking out the repository to force the action + # to analyze the diff from the Github API rather than looking at the + # shallow clone and erroring out, which is significantly more prone to + # failure. - name: Get changed files id: changed-files uses: tj-actions/changed-files@v39 with: separator: "," - fetch_depth: 2000 # Fetches only the last 2000 commits + + - name: Fetch PR sources + uses: actions/checkout@v4 + with: + ref: "refs/pull/${{ github.event.number }}/merge" + fetch-depth: 2 + path: pr-sources + + # We need to make sure that we aren't executing/using any code from the + # PR for security reasons as we're using pull_request_target. Checkout + # the target branch with the necessary files. + - name: Fetch LLVM Sources + uses: actions/checkout@v4 + with: + sparse-checkout: | + llvm/utils/git/requirements_formatting.txt + llvm/utils/git/code-format-helper.py + sparse-checkout-cone-mode: false + path: llvm-sources - name: "Listed files" run: | @@ -34,21 +51,20 @@ jobs: with: python-version: '3.11' cache: 'pip' - cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt' + cache-dependency-path: 'llvm-sources/llvm/utils/git/requirements_formatting.txt' - name: Install python dependencies - run: pip install -r llvm/utils/git/requirements_formatting.txt + run: pip install -r llvm-sources/llvm/utils/git/requirements_formatting.txt - name: Run code formatter env: GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} - START_REV: ${{ github.event.pull_request.base.sha }} - END_REV: ${{ github.event.pull_request.head.sha }} CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + working-directory: ./pr-sources run: | - python llvm/utils/git/code-format-helper.py \ + python ../llvm-sources/llvm/utils/git/code-format-helper.py \ --token ${{ secrets.GITHUB_TOKEN }} \ --issue-number $GITHUB_PR_NUMBER \ - --start-rev $START_REV \ - --end-rev $END_REV \ + --start-rev HEAD^ \ + --end-rev HEAD \ --changed-files "$CHANGED_FILES" diff --git a/.github/workflows/pr-code-format2.yml b/.github/workflows/pr-code-format2.yml new file mode 100644 index 000000000000000..abae2292017dda3 --- /dev/null +++ b/.github/workflows/pr-code-format2.yml @@ -0,0 +1,11 @@ +name: "Check code formatting" +on: pull_request + +jobs: + code_formatter: + runs-on: ubuntu-latest + steps: + - name: Fetch PR sources + uses: actions/checkout@v4 + - name: Install python dependencies + run: git log -n 1 diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp index 114e7910dc27bbd..769371680642b15 100644 --- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +// this line is way too fricking long and should definitely be caught by the c++ code formatter if it isn't just dumb as frick + #include "AllocationOrder.h" #include "RegAllocEvictionAdvisor.h" #include "RegAllocGreedy.h" diff --git a/llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp index 422781593a9c6bd..748720b82643968 100644 --- a/llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp +++ b/llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +// this is another test that the code formatter should pick up on and fix, hopefully without too much fuss because gosh dang + #include "AllocationOrder.h" #include "RegAllocGreedy.h" #include "RegAllocPriorityAdvisor.h" diff --git a/test b/test new file mode 100644 index 000000000000000..139597f9cb07c5d --- /dev/null +++ b/test @@ -0,0 +1,2 @@ + + diff --git a/tst b/tst new file mode 100644 index 000000000000000..139597f9cb07c5d --- /dev/null +++ b/tst @@ -0,0 +1,2 @@ + +