diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..d1f0fa4993 --- /dev/null +++ b/.clang-format @@ -0,0 +1,7 @@ +--- +BasedOnStyle: Google +--- +Language: Cpp +IndentWidth: 2 +SortIncludes: Never +--- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b160dd3766..3d43e1ae9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,12 @@ name: Build on: - push: - branches: [ "dev" ] pull_request: - branches: [ "dev" ] + branches: [dev] + workflow_run: + workflows: [Formatter] + types: + - completed + branches: [dev] workflow_dispatch: jobs: build: diff --git a/.github/workflows/formatter.yml b/.github/workflows/formatter.yml new file mode 100644 index 0000000000..8b06e9df32 --- /dev/null +++ b/.github/workflows/formatter.yml @@ -0,0 +1,28 @@ +# This workflow uses clang-format to force the right coding style. +name: Formatter + +on: + push: + branches: [ "dev" ] + workflow_dispatch: +jobs: + formatter: + runs-on: ubuntu-latest + + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository. + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run formatter + run: find ./src ./include/ -type f \( -name '*.cpp' -o -name '*.h' \) -exec clang-format --style=file -i '{}' \; + + # Commit the changes when pushing to a remote branch + - name: Commit + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_user_name: clang-format-bot + commit_message: 'Automated commit of clang-format CI changes.'