-
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.
Create pr-format-check.yml action (#70)
* Create pr-format-check.yml
- Loading branch information
Showing
1 changed file
with
32 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,32 @@ | ||
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 | ||
id: check_formatting | ||
run: | | ||
git clang-format --style=file:firmware/.clang-format --diff $(git merge-base HEAD main) -v > clang_format_output.txt | ||
if grep -q "clang-format did not modify any files" clang_format_output.txt; then | ||
echo "Code formatting is already correct." | ||
elif grep -q "Running clang-format on the following files" clang_format_output.txt; then | ||
echo "Code formatting changes detected." | ||
exit 1 | ||
fi |