From bc846e66fe73b6814c9e02d794b6f8cb2a082c26 Mon Sep 17 00:00:00 2001 From: Michael Nasr <44876651+Micnasr@users.noreply.github.com> Date: Wed, 20 Mar 2024 23:28:15 -0400 Subject: [PATCH] Create pr-format-check.yml --- .github/workflows/pr-format-check.yml | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/pr-format-check.yml diff --git a/.github/workflows/pr-format-check.yml b/.github/workflows/pr-format-check.yml new file mode 100644 index 000000000..2a53b5bae --- /dev/null +++ b/.github/workflows/pr-format-check.yml @@ -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."