diff --git a/.github/workflows/clang_format.yaml b/.github/workflows/clang_format.yaml new file mode 100644 index 00000000..59c0c12b --- /dev/null +++ b/.github/workflows/clang_format.yaml @@ -0,0 +1,63 @@ +name: Clang Format Check + +on: + push: + branches: [ "master" ] + paths-ignore: + - '**/*.md' + - '*.md' + pull_request: + branches: [ "master" ] + paths-ignore: + - '**/*.md' + - '*.md' + +jobs: + clang-format: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install clang-format + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y clang-format-19 + + - name: Fetch base branch + if: github.event_name == 'pull_request' + run: | + echo "Fetching base branch ${{ github.base_ref }}" + git fetch origin ${{ github.base_ref }}:${{ github.base_ref }} + + - name: Get Git Diff + id: diff + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "Getting diff for pull request" + git diff origin/${{ github.base_ref }}...HEAD > diff.patch + else + echo "Getting diff for commit" + git diff ${{ github.event.before }} ${{ github.event.after }} > diff.patch + fi + + - name: Check formatting + shell: bash + run: | + cat diff.patch | clang-format-diff-19 -p 1 > diff_format.patch + + if [ -s diff_format.patch ]; then + echo "❌ Code formatting issues found. See diff_format.patch." + exit 1 + fi + + - name: Upload clang-formatted diff + if: failure() + uses: actions/upload-artifact@v4 + with: + name: clang-format-diff + path: diff_format.patch diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 66d25613..c452235a 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -6,10 +6,12 @@ on: branches: [ "master" ] paths-ignore: - '**/*.md' + - '*.md' pull_request: branches: [ "master" ] paths-ignore: - '**/*.md' + - '*.md' jobs: run-matrix: