mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 01:15:50 +08:00
We've gotten ~750 commits in the last 7 days. Upping the fetch depth to 2000 will make it more likely that PRs up to 2 weeks old will have enough fetch history to find a common parent. This _might_ address some of the failures we're seeing in the clang-format action where it cannot find a common base commit.
55 lines
1.7 KiB
YAML
55 lines
1.7 KiB
YAML
name: "Check code formatting"
|
|
on: pull_request_target
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
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
|
|
|
|
- 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: "Listed files"
|
|
run: |
|
|
echo "Formatting files:"
|
|
echo "${{ steps.changed-files.outputs.all_changed_files }}"
|
|
|
|
- name: Install clang-format
|
|
uses: aminya/setup-cpp@v1
|
|
with:
|
|
clangformat: 17.0.1
|
|
|
|
- name: Setup Python env
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
|
|
|
|
- name: Install python dependencies
|
|
run: pip install -r 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 }}
|
|
run: |
|
|
python llvm/utils/git/code-format-helper.py \
|
|
--token ${{ secrets.GITHUB_TOKEN }} \
|
|
--issue-number $GITHUB_PR_NUMBER \
|
|
--start-rev $START_REV \
|
|
--end-rev $END_REV \
|
|
--changed-files "$CHANGED_FILES"
|