From 45b88fc5d73f554f4becbddc73002edfdbc432cb Mon Sep 17 00:00:00 2001 From: Etienne Champetier Date: Sat, 12 Aug 2017 18:30:15 -0700 Subject: [PATCH] build,travis: test build PRs (but don't fail for now) Rework exec_status to use "tee" to continuously output logs (so we don't trigger travis timeouts) Only launch the compile test if everything else is ok (spare Travis builders a bit) Signed-off-by: Etienne Champetier --- .travis_do.sh | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/.travis_do.sh b/.travis_do.sh index ff07a6caac..719c29ea0f 100755 --- a/.travis_do.sh +++ b/.travis_do.sh @@ -14,16 +14,21 @@ echo_green() { printf "\033[1;32m$*\033[m\n"; } echo_blue() { printf "\033[1;34m$*\033[m\n"; } exec_status() { - ("$@" 2>&1) > logoutput && status=0 || status=1 - grep -qE 'WARNING|ERROR' logoutput && status=1 - cat logoutput - if [ $status -eq 0 ]; then - echo_green "=> $* successful" - return 0 - else - echo_red "=> $* failed" + PATTERN="$1" + shift + ("$@" 2>&1) | tee logoutput + R=${PIPESTATUS[0]} + if [ $R -ne 0 ]; then + echo_red "=> '$*' failed (return code $R)" return 1 fi + if grep -qE "$PATTERN" logoutput; then + echo_red "=> '$*' failed (log matched '$PATTERN')" + return 1 + fi + + echo_green "=> '$*' successful" + return 0 } # download will run on the `before_script` step @@ -92,15 +97,26 @@ EOF # pkg_name => muninlite for pkg_dir in $PKGS ; do pkg_name=$(echo "$pkg_dir" | awk -F/ '{ print $NF }') - echo_blue "=== $pkg_name Testing package" + echo_blue "=== $pkg_name: Starting quick tests" - exec_status make "package/$pkg_name/download" V=s || RET=1 - exec_status make "package/$pkg_name/check" V=s || RET=1 + exec_status 'WARNING|ERROR' make "package/$pkg_name/download" V=s || RET=1 + exec_status 'WARNING|ERROR' make "package/$pkg_name/check" V=s || RET=1 - echo_blue "=== $pkg_name Finished package" + echo_blue "=== $pkg_name: quick tests done" done - return $RET + [ $RET -ne 0 ] && return $RET + + for pkg_dir in $PKGS ; do + pkg_name=$(echo "$pkg_dir" | awk -F/ '{ print $NF }') + echo_blue "=== $pkg_name: Starting compile test" + + exec_status '^ERROR' make "package/$pkg_name/compile" V=s -j3 + + echo_blue "=== $pkg_name: compile test done" + done + + return 0 } test_commits() { @@ -142,10 +158,7 @@ test_commits() { } test_packages() { - GRET=0 - test_commits || GRET=1 - test_packages2 || GRET=1 - return $GRET + test_commits && test_packages2 || return 1 } echo_blue "=== Travis ENV"