-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Clang Format Check | ||
|
||
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 | ||
|
||
- name: Set up clang-format | ||
run: sudo apt-get install clang-format | ||
|
||
- name: Check code formatting | ||
run: | | ||
git-clang-format --style=firmware/.clang-format --binary=clang-format --diff $(git merge-base origin/main HEAD) 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." |