update #2
This file contains hidden or 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
| name: Clang Format Check | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| clang-format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Install clang-format | |
| run: sudo apt-get install clang-format -y | |
| - name: Run clang-format | |
| run: | | |
| find . -name '*.cpp' -o -name '*.hpp' -o -name '*.h' | xargs clang-format -i | |
| git diff --exit-code | |
| - name: Check for unformatted code | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Code is not formatted. Please run clang-format." | |
| exit 1 | |
| fi |