Pagghiu / SaneCppLibraries

Sane C++ Libraries
https://pagghiu.github.io/SaneCppLibraries
MIT License
507 stars 11 forks source link

Create GitHub pipeline to reject code not formatted with clang-format #4

Closed Pagghiu closed 7 months ago

Pagghiu commented 8 months ago

We should really add a GitHub pipeline that fails if the code is not formatted with clang-format.

The script should be along these lines:

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ROOT_DIR="${SCRIPT_DIR}/.."
SOURCE_DIR="${ROOT_DIR}/../SC"
HOST_TOOLS="${ROOT_DIR}/_Build/HostTools"
CLANG_FORMAT="$HOST_TOOLS/clang/bin/clang-format"
cd "${SOURCE_DIR}" && find . \( -iname \*.h -o -iname \*.cpp -o -iname \*.mm -o -iname \*.m -o -iname \*.inl \) -not \( -path "*/Dependencies/*" -o -path "*/Build/Windows/resource.h"  \) | xargs "${CLANG_FORMAT}" -i
Pagghiu commented 7 months ago

This is actually now being done by the linux CI job see

https://github.com/Pagghiu/SaneCppLibraries/blob/main/.github/workflows/linux.yml#L20