-
Notifications
You must be signed in to change notification settings - Fork 3
39 lines (32 loc) · 1.04 KB
/
pr-format-check.yml
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
on:
pull_request:
branches:
- main
jobs:
clang_format_check:
name: Check Clang Format
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up clang-format
run: sudo apt-get install clang-format -y
- name: Fetch main branch
run: git fetch origin main:main
- name: Check code formatting
run: |
git clang-format --style=file:firmware/.clang-format --diff $(git merge-base HEAD main) -v
- name: Check for changes
id: check_changes
run: |
if git diff -v --exit-code -- '*.cpp' '*.h'; then
echo "Code is properly formatted."
else
echo "Code is not formatted properly. Please run clang-format and commit the changes."
exit 1
fi
- name: Complete
if: steps.check_changes.outcome == 'success'
run: echo "Code is properly formatted."