-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (53 loc) · 1.75 KB
/
Copy pathclang-format.yml
File metadata and controls
60 lines (53 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Clang Format
on:
schedule:
# Run every Sunday at midnight UTC (Sunday night)
- cron: '0 0 * * 0'
workflow_dispatch: # Allow manual triggering for testing
permissions:
contents: write
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format-18
- name: Run clang-format
run: |
# Find all C/C++ files and format them
find . -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) \
-not -path "*/build/*" \
-not -path "*/zephyr/*" \
-not -path "*/.git/*" \
-not -path "*/CMakeFiles/*" \
-not -path "*/tools/autocoders/templates/*" \
-exec clang-format-18 -i {} \;
- name: Check for changes
id: check_changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout -b auto/clang-format-fix
git add .
git commit -m "Apply clang-format formatting"
git push origin auto/clang-format-fix
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
branch: auto/clang-format-fix
title: Clang Format Fix
body: Automated clang-format suggestions