Skip to content

Commit

Permalink
Clang format in the CI
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Mazur <[email protected]>
  • Loading branch information
Mazurel committed Nov 11, 2024
1 parent 96661a0 commit 2eabdee
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
Expand All @@ -26,7 +25,6 @@ AlignConsecutiveDeclarations:
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Clang formatting checker

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
build:
runs-on: ubuntu-latest
env:
DRY: "TRUE"

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

# Dependecies needed only for Linux - Modbus Communication
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Build
run: DRY=TRUE bash reformat-all.sh
12 changes: 11 additions & 1 deletion reformat-all.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/bin/sh

find . -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i -style=file
ALL_FORMATABLE_FILES=$(find src include tests example -name '*.cpp' -o -name '*.hpp')
CLANG_FORMAT_ARGS="-i -style=file"

echo "*** Modbus Clang Format Wrapper **"
echo "DRY RUN: $DRY"

if [[ "$DRY" = "TRUE" ]]; then
exec clang-format --dry-run $CLANG_FORMAT_ARGS $ALL_FORMATABLE_FILES
else
exec clang-format $CLANG_FORMAT_ARGS $ALL_FORMATABLE_FILES
fi

0 comments on commit 2eabdee

Please sign in to comment.