Skip to content

Commit

Permalink
Add contrib/checkformat.bash to check for clang-formatting (gbdev#1646)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 authored Feb 4, 2025
1 parent 91310c9 commit fbde24e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/checkdiff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
cd rgbds
git remote add upstream "${{ github.event.pull_request.base.repo.clone_url }}"
git fetch upstream
- name: Checkdiff
- name: Check diff
working-directory: rgbds
run: |
make checkdiff "BASE_REF=${{ github.event.pull_request.base.sha }}" Q= | tee log
12 changes: 12 additions & 0 deletions .github/workflows/checkformat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Code format checking
on: pull_request

jobs:
checkformat:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Check format
run: |
./contrib/checkformat.bash
15 changes: 15 additions & 0 deletions contrib/checkformat.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# SPDX-License-Identifier: MIT

clang-format --version

find . -type f \( -iname '*.hpp' -o -iname '*.cpp' \) -exec clang-format -i {} +

if ! git diff-index --quiet HEAD --; then
echo 'Unformatted files:'
git diff-index --name-only HEAD --
echo
git diff HEAD --
return 1
fi

0 comments on commit fbde24e

Please sign in to comment.