forked from organicmaps/organicmaps
[CI] Add cpp codestyle check
Signed-off-by: Andrew Shkrob <andrew.shkrob.social@yandex.by>
This commit is contained in:
parent
ce2720826e
commit
4fd01921e4
1 changed files with 47 additions and 0 deletions
47
.github/workflows/cpp-code-check.yaml
vendored
Normal file
47
.github/workflows/cpp-code-check.yaml
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
name: Cpp code check
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/cpp-code-check.yaml
|
||||
- .clang-format
|
||||
- '**/*.c'
|
||||
- '**/*.cpp'
|
||||
- '**/*.h'
|
||||
- '**/*.hpp'
|
||||
- '**/*.m'
|
||||
- '**/*.mm'
|
||||
- '!3party/**'
|
||||
|
||||
jobs:
|
||||
clang-format-check:
|
||||
name: Clang-format check
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Calculate PR fetch depth
|
||||
env:
|
||||
COMMITS_COUNT: ${{ github.event.pull_request.commits }}
|
||||
run: echo "PR_FETCH_DEPTH=$(($COMMITS_COUNT + 1))" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout PR branch and all PR commits
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
|
||||
|
||||
- name: Install clang-format tool
|
||||
run: sudo apt install -y clang-format
|
||||
|
||||
- name: Check codestyle
|
||||
env:
|
||||
COMMITS_COUNT: ${{ github.event.pull_request.commits }}
|
||||
run: |
|
||||
git clang-format HEAD~$COMMITS_COUNT HEAD --extensions 'c,cpp,h,hpp,m,mm' --diff >> clang-format.diff
|
||||
|
||||
- name: Show clang-format diff
|
||||
if: failure()
|
||||
run: |
|
||||
echo "Some files are not formatted correctly:"
|
||||
echo "::group::clang-format.diff"
|
||||
cat clang-format.diff
|
||||
echo "::endgroup::"
|
Loading…
Add table
Reference in a new issue