-
Notifications
You must be signed in to change notification settings - Fork 3
39 lines (31 loc) · 1.09 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
- name: Fetch main branch
run: git fetch origin main:main
- name: Get commit ID of main branch
run: |
MAIN_COMMIT=$(git rev-parse origin/main)
echo "Commit ID of main branch: $MAIN_COMMIT"
- name: Check code formatting
run: |
git clang-format --style=firmware/.clang-format --diff $MAIN_COMMIT..HEAD '*.cpp' '*.h'
- name: Check for changes
id: check_changes
run: |
git diff --exit-code || (echo "Code is not formatted properly. Please run clang-format and commit the changes." && exit 1)
- name: Complete
if: steps.check_changes.outcome == 'success'
run: echo "Code is properly formatted."