This patch haspins all actions in most of the LLVM Github workflows. This is something we try to do, but no one has gone through and combed through all of the workflows before this patch. Notably, this patch does not bump any major versions of actions just in case there are subtle breaking changes introduced between versions that could impact us. Also, this patch omits the libc/libc++ workflows so that they can be split into separate PRs for the respective subproject maintainers to review.
102 lines
3.6 KiB
YAML
102 lines
3.6 KiB
YAML
name: "Check code formatting"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- 'users/**'
|
|
|
|
jobs:
|
|
code_formatter:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
if: github.repository == 'llvm/llvm-project'
|
|
steps:
|
|
- name: Fetch LLVM sources
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: Checkout through merge base
|
|
uses: rmacklin/fetch-through-merge-base@bfe4d03a86f9afa52bc1a70e9814fc92a07f7b75 # v0.3.0
|
|
with:
|
|
base_ref: ${{ github.event.pull_request.base.ref }}
|
|
head_ref: ${{ github.event.pull_request.head.sha }}
|
|
deepen_length: 500
|
|
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@fea790cb660e33aef4bdf07304e28fedd77dfa13 # v39.2.4
|
|
with:
|
|
separator: ","
|
|
skip_initial_fetch: true
|
|
|
|
# We need to pull the script from the main branch, so that we ensure
|
|
# we get the latest version of this script.
|
|
- name: Fetch code formatting utils
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
repository: ${{ github.repository }}
|
|
ref: ${{ github.base_ref }}
|
|
sparse-checkout: |
|
|
llvm/utils/git/requirements_formatting.txt
|
|
llvm/utils/git/code-format-helper.py
|
|
sparse-checkout-cone-mode: false
|
|
path: code-format-tools
|
|
|
|
- name: "Listed files"
|
|
env:
|
|
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
|
|
run: |
|
|
echo "Formatting files:"
|
|
echo "$CHANGED_FILES"
|
|
|
|
- name: Install clang-format
|
|
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
|
|
with:
|
|
clangformat: 19.1.6
|
|
|
|
- name: Setup Python env
|
|
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
cache-dependency-path: 'code-format-tools/llvm/utils/git/requirements_formatting.txt'
|
|
|
|
- name: Install python dependencies
|
|
run: pip install -r code-format-tools/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 }}
|
|
# TODO(boomanaiden154): Once clang v18 is released, we should be able
|
|
# to take advantage of the new --diff_from_common_commit option
|
|
# explicitly in code-format-helper.py and not have to diff starting at
|
|
# the merge base.
|
|
# Create an empty comments file so the pr-write job doesn't fail.
|
|
run: |
|
|
echo "[]" > comments &&
|
|
python ./code-format-tools/llvm/utils/git/code-format-helper.py \
|
|
--write-comment-to-file \
|
|
--token ${{ secrets.GITHUB_TOKEN }} \
|
|
--issue-number $GITHUB_PR_NUMBER \
|
|
--start-rev $(git merge-base $START_REV $END_REV) \
|
|
--end-rev $END_REV \
|
|
--changed-files "$CHANGED_FILES"
|
|
|
|
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
|
|
if: always()
|
|
with:
|
|
name: workflow-args
|
|
path: |
|
|
comments
|