Add cmake-format config

Improve formatting.
Use Tabs.
Make copyright one whole comment block.
Remove spaces inside of functions and after if.
Remove excessive whitespace.
Add github action to validate formatting.
This commit is contained in:
Sandy Carter
2023-01-06 14:41:57 -05:00
committed by Sandy
parent c53792d472
commit 471da90712
17 changed files with 1041 additions and 631 deletions

55
.github/workflows/format.yml vendored Normal file
View File

@@ -0,0 +1,55 @@
# https://github.com/openblack/bgfx.cmake/blob/master/.github/workflows/format.yml
name: Format
on:
push:
branches: [ master ]
pull_request_target:
branches: [ master ]
jobs:
job:
cmake-format-check:
name: cmake-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Add base repo to git config
run: git remote add upstream ${{ github.event.pull_request.base.repo.html_url }}
if: startsWith(github.event_name, 'pull_request')
- name: Format CMake files
id: cmake-format
uses: PuneetMatharu/cmake-format-lint-action@main
with:
args: --config-files .cmake-format.py --check
# Run only if a PR and cmake-format has failed
cmake-format-action-suggester:
name: cmake-format fix suggester
runs-on: ubuntu-latest
needs: cmake-format-check
if: always() && startsWith(github.event_name, 'pull_request') && needs.cmake-format-check.result == 'failure'
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Add base repo to git config
run: git remote add upstream ${{ github.event.pull_request.base.repo.html_url }}
if: startsWith(github.event_name, 'pull_request')
- name: Format CMake files
id: cmake-format
uses: PuneetMatharu/cmake-format-lint-action@v1.0.0
with:
args: --config-files .cmake-format.py --in-place
- run: |
git diff > cmake-format.patch
- uses: actions/upload-artifact@v2
with:
name: formatting-fix-${{github.sha}}
path: cmake-format.patch
- uses: reviewdog/action-suggester@v1
with:
tool_name: cmake-format