Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New feature] Add check style in code for only changed/added files in PR #362

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9560087
add GitHub Actions for check sources by clang-format
den-patrakeev Dec 11, 2024
1913ef3
add get list changed files
den-patrakeev Dec 11, 2024
a08351e
test install llvm and clang
den-patrakeev Dec 17, 2024
c6fd905
fix version llvm
den-patrakeev Dec 17, 2024
d7ae77e
fix version llvm from asset action
den-patrakeev Dec 17, 2024
8514d6c
test new logic with parallel
den-patrakeev Dec 17, 2024
9aacc78
test sudo
den-patrakeev Dec 17, 2024
20ef704
final view
den-patrakeev Dec 17, 2024
832804b
test on source file
den-patrakeev Dec 17, 2024
aaa0731
test change style
den-patrakeev Dec 17, 2024
f395651
test Chromium styles
den-patrakeev Dec 26, 2024
d308b18
add ignore thirdparty src and test it
den-patrakeev Dec 26, 2024
b3e3a00
add ignore thirdparty src and test it 2
den-patrakeev Dec 26, 2024
0d47851
add ignore thirdparty src and test it 3
den-patrakeev Dec 26, 2024
2f760e0
test Mozilla codestyle
den-patrakeev Dec 26, 2024
67fb601
test WebKit codestyle
den-patrakeev Dec 26, 2024
8c53575
test Microsoft codestyle
den-patrakeev Dec 26, 2024
c7f7109
test GNU codestyle
den-patrakeev Dec 26, 2024
46ded40
test LLVM codestyle
den-patrakeev Dec 26, 2024
7f513d7
test Google codestyle
den-patrakeev Dec 26, 2024
cde3187
test Mozilla codestyle
den-patrakeev Dec 26, 2024
bb8ae6f
set C++11 standart
den-patrakeev Dec 26, 2024
e6ff72b
test use default official default example
den-patrakeev Dec 26, 2024
313b50c
test use default official default example 2
den-patrakeev Dec 26, 2024
52163bd
test use default official default example 3
den-patrakeev Dec 26, 2024
054ee8b
test use default official default example 4
den-patrakeev Dec 26, 2024
5b712af
test use default official default example 5
den-patrakeev Dec 26, 2024
5b96dd0
final test
den-patrakeev Dec 26, 2024
0e230ea
final test 2
den-patrakeev Dec 26, 2024
e2cd04f
final version
den-patrakeev Dec 26, 2024
191f82c
final version 2
den-patrakeev Dec 26, 2024
c002e13
fix file name
den-patrakeev Dec 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
Standard: c++11
Cpp11BracedListStyle: true
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
---
Language: Proto
# Don't format .proto files.
DisableFormat: true
2 changes: 2 additions & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
thirdparty/*
thirdparty_unman/*
44 changes: 44 additions & 0 deletions .github/workflows/check_clang_format_on_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 }}