Skip to content

Commit e59360a

Browse files
committed
github: workflows: Add clang-format action
Loosely based on qualcomm#136 Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
1 parent 77b6819 commit e59360a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/clang-format.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Check formatting
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'development'
8+
pull_request:
9+
branches:
10+
- 'main'
11+
- 'development'
12+
13+
jobs:
14+
clang-format:
15+
# The exact version doesn't really matter, as we're getting a build from LLVM repos anyway
16+
runs-on: [ ubuntu-latest ]
17+
18+
env:
19+
CLANG_MAJOR_VERSION: 20
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Install Clang Format
26+
run: |
27+
wget https://apt.llvm.org/llvm.sh
28+
sudo chmod +x llvm.sh
29+
sudo ./llvm.sh $CLANG_MAJOR_VERSION
30+
sudo apt-get install clang-format-$CLANG_MAJOR_VERSION
31+
32+
- name: Print clang-format version
33+
run: clang-format-$CLANG_MAJOR_VERSION --version
34+
35+
- name: Run Clang Format
36+
run: |
37+
find . -name '*.cpp' -o -name '*.hpp' -o -name '*.c' -o -name '*.h' | xargs clang-format-$CLANG_MAJOR_VERSION -i
38+
git diff --exit-code || (echo "The changes are not formatted properly" && exit 1)

0 commit comments

Comments
 (0)