add license headers check to sanity script (#106)

Motivation:

prevent adding source that does not include the license header

Modifications:

add a check in sanity script to grep over all swift files and make sure they have the license header

Result:

ci build will fail if/when trying to commit source files that do not include the license header
This commit is contained in:
tomer doron 2018-03-07 18:39:21 +09:00 committed by Cory Benfield
parent 7734506765
commit ade7eb1b37
1 changed files with 13 additions and 4 deletions

View File

@ -2,15 +2,24 @@
set -eu set -eu
# check linux tests printf "=> Checking linux tests... "
FIRST_OUT="$(git status --porcelain)" FIRST_OUT="$(git status --porcelain)"
ruby scripts/generate_linux_tests.rb > /dev/null ruby scripts/generate_linux_tests.rb > /dev/null
SECOND_OUT="$(git status --porcelain)" SECOND_OUT="$(git status --porcelain)"
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
printf "\033[0;31mMissing linux test changes!\033[0m\n" printf "\033[0;31mmissing changes!\033[0m\n"
git --no-pager diff git --no-pager diff
exit 1 exit 1
else else
printf "\033[0;32mLinux tests okay\033[0m\n" printf "\033[0;32mokay.\033[0m\n"
fi
printf "=> Checking license headers... "
NON_LICENSED_FILES="$(grep --include=\*.swift --exclude-dir=.build -rL "Licensed under Apache License v2.0" .)"
if [[ -n "$NON_LICENSED_FILES" ]]; then
printf "\033[0;31mmissing headers!\033[0m\n"
printf "$NON_LICENSED_FILES\n"
exit 1
else
printf "\033[0;32mokay.\033[0m\n"
fi fi