-
Notifications
You must be signed in to change notification settings - Fork 120
44 lines (37 loc) · 1.56 KB
/
Copy pathcheck_clang_format_on_pr.yml
File metadata and controls
44 lines (37 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Check Style in Code
on: [pull_request]
jobs:
clang-format:
name: Check sources by clang-format for added/changed files in PR
runs-on: ubuntu-latest
steps:
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: "18.1.8"
- name: Install parallel for work with check many files
run: |
sudo apt-get update
sudo apt-get install parallel -y
- name: Checkout repository code
uses: actions/checkout@v4
with:
fetch-depth: 0 # for work tj-actions/changed-files
persist-credentials: false # for work tj-actions/changed-files
- name: Get C/C++/Protobuf source files that have added/changed
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: '**/*.{h,H,hpp,hh,h++,hxx,c,C,cpp,cc,c++,cxx,ino,pde,cu,proto}'
files_ignore: 'thirdparty*/**/*.{h,H,hpp,hh,h++,hxx,c,C,cpp,cc,c++,cxx,ino,pde,cu,proto}'
- name: List added/changed C/C++/Protobuf source file(s) for check
if: steps.changed-files.outputs.any_changed == 'true'
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
- name: Check added/changed C/C++/Protobuf source file(s) by clang-format
if: steps.changed-files.outputs.any_changed == 'true'
run: |
parallel clang-format --style=file --Werror --dry-run --verbose ::: \
${{ steps.changed-files.outputs.all_changed_files }}