Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: create checks.yml #75

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
#
# check that all code complies w/ the clang-format specification
#
# if all is well, returns w/o errors and does not print anything.
# otherwise, return an error and print offending changes

set -e # abort on error

INCLUDE_DIRS=("core data meta tests web")

if [ $# -ne 1 ]; then
echo "wrong number of arguments"
echo ""
echo "usage: check_format <DIR>"
exit 1
fi

_binary=${CLANG_FORMAT_BINARY:-clang-format}

$_binary --version

cd $1
$_binary -i -style=file $(find ${INCLUDE_DIRS} \( -iname '*.cpp' -or -iname '*.hpp' -or -iname '*.ipp' \))

if ! [ -z $CI ] || ! [ -z $GITHUB_ACTIONS ]; then
mkdir changed
for f in $(git diff --name-only -- ${INCLUDE_DIRS[@]/#/:/}); do
cp --parents $f changed
done
fi

echo "clang-format done"

set +e
git diff --exit-code --stat -- ${INCLUDE_DIRS[@]/#/:/}
result=$?

if [ "$result" -eq "128" ]; then
echo "Format was successfully applied"
echo "Could not create summary of affected files"
echo "Are you in a submodule?"

fi

exit $result
Loading