Skip to content

Commit

Permalink
add check-format
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpintarelli committed Jun 6, 2024
1 parent 3041824 commit c74f83b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Check source code formatting

on:
push: {}
pull_request: {}

jobs:
check:
runs-on: ubuntu-latest
container: zhongruoyu/llvm-ports:17.0.4-slim-focal
steps:
- uses: actions/checkout@v4
- name: Check .cpp and .hpp files
run: |
./check_format.sh
15 changes: 15 additions & 0 deletions check_format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

check_diff() {
local status=0
for file in "$@"; do
if ! diff -q "$file" <(clang-format "$file"); then
status=1
fi
done
return $status
}

export -f check_diff

find . -type f \( -name "*.cpp" -o -name "*.hpp" \) ! -path "./build-env/*" ! -path "./.*" -exec bash -c 'check_diff "$@"' sh {} +

0 comments on commit c74f83b

Please sign in to comment.