Skip to content

Commit 47af467

Browse files
feat: add .clang-format for code format check
This change introduces a .clang-format file based on LLVM style with custom rules, and adds a GitHub Actions CI job that checks on build of formatting code. Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
1 parent 68f70bb commit 47af467

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

.clang-format

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: LLVM
4+
AlignArrayOfStructures: Left
5+
ColumnLimit: 100

.github/workflows/build.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,38 @@ permissions:
1313
contents: read
1414

1515
jobs:
16+
clang-format-check:
17+
name: Clang Format Check
18+
runs-on: macos-15
19+
timeout-minutes: 10
20+
steps:
21+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
22+
with:
23+
fetch-depth: 1
24+
25+
- name: Install Clang Format
26+
run: |
27+
brew update
28+
brew install clang-format
29+
clang-format --version
30+
31+
- name: Run Clang Format Check
32+
run: |
33+
# Format all source - if the source is formatted properly this will do nothing
34+
clang-format -i *.c *.h client/*.c
35+
36+
# Do we have unwanted changes?
37+
if ! git diff-index --quiet HEAD; then
38+
# Show the changes
39+
echo "ERROR: Code is not properly formatted."
40+
echo
41+
git --no-pager diff
42+
43+
echo
44+
echo "Please run clang-format locally and commit the changes."
45+
exit 1
46+
fi
47+
1648
build:
1749
name: Build
1850
strategy:

0 commit comments

Comments
 (0)