Add clang-format to ci

This commit is contained in:
Konstantinos Sideris 2017-09-24 17:08:11 +03:00
parent f351b00075
commit 37ff1398b7
3 changed files with 17 additions and 6 deletions

14
.ci/format.sh Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Runs the Clang Formatter
# Return codes:
# - 1 there are files to be formatted
# - 0 everything looks fine
set -o errexit
set -o pipefail
set -o nounset
FILES=`find include src tests -type f -type f \( -iname "*.cc" -o -iname "*.h" \)`
clang-format -i $FILES && git diff --exit-code

View file

@ -17,7 +17,7 @@ matrix:
before_install: before_install:
- if [ $TRAVIS_OS_NAME == linux ]; then ./.ci/linux/gtest.sh; fi - if [ $TRAVIS_OS_NAME == linux ]; then ./.ci/linux/gtest.sh; fi
install: install:
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install qt5 lmdb; fi - if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install qt5 lmdb clang-format; fi
- if [ $TRAVIS_OS_NAME == osx ]; then export CMAKE_PREFIX_PATH=/usr/local/opt/qt5; fi - if [ $TRAVIS_OS_NAME == osx ]; then export CMAKE_PREFIX_PATH=/usr/local/opt/qt5; fi
- if [ $TRAVIS_OS_NAME == linux ]; then ./.ci/linux/install-deps.sh; fi - if [ $TRAVIS_OS_NAME == linux ]; then ./.ci/linux/install-deps.sh; fi
before_script: before_script:
@ -26,3 +26,4 @@ before_script:
script: script:
- make -C build -j2 - make -C build -j2
- if [ $TRAVIS_OS_NAME == linux ]; then ./.ci/linux/run-tests.sh; fi - if [ $TRAVIS_OS_NAME == linux ]; then ./.ci/linux/run-tests.sh; fi
- if [ $TRAVIS_OS_NAME == osx ]; then make lint; fi

View file

@ -3,9 +3,6 @@ APP_NAME = nheko
MAC_DIST_DIR = dist/MacOS MAC_DIST_DIR = dist/MacOS
APP_TEMPLATE = $(MAC_DIST_DIR)/Nheko.app APP_TEMPLATE = $(MAC_DIST_DIR)/Nheko.app
SRC := $(shell find include src -type f -type f \( -iname "*.cc" -o -iname "*.h" \))
# Linux specific helpers # Linux specific helpers
debug: debug:
@cmake -DBUILD_TESTS=OFF -H. -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Debug @cmake -DBUILD_TESTS=OFF -H. -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Debug
@ -38,8 +35,7 @@ run:
@./build/nheko @./build/nheko
lint: lint:
@clang-format -i $(SRC) @./.ci/format.sh
clean: clean:
rm -rf build rm -rf build