From ade7eb1b37efc22e7cc0b961eb381110edd17a7b Mon Sep 17 00:00:00 2001 From: tomer doron Date: Wed, 7 Mar 2018 18:39:21 +0900 Subject: [PATCH] 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 --- scripts/sanity.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/sanity.sh b/scripts/sanity.sh index a9c210ae..d01422a8 100755 --- a/scripts/sanity.sh +++ b/scripts/sanity.sh @@ -2,15 +2,24 @@ set -eu -# check linux tests - +printf "=> Checking linux tests... " FIRST_OUT="$(git status --porcelain)" ruby scripts/generate_linux_tests.rb > /dev/null SECOND_OUT="$(git status --porcelain)" 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 exit 1 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