X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=.travis_do.sh;h=2dd1c1c8d771129f9934a24c22c02aba44fbf1e6;hb=83a03d31cfe83da8cbd6bf937c449c439fb1475e;hp=ae75458f1e417f7138f88ebf7f8f15b1771741ae;hpb=860abd4f9b8de9ed2e0795f4b6a2e26c25ec62a5;p=feed%2Fpackages.git diff --git a/.travis_do.sh b/.travis_do.sh index ae75458f1e..2dd1c1c8d7 100755 --- a/.travis_do.sh +++ b/.travis_do.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # MIT Alexander Couzens @@ -9,6 +9,30 @@ SDK_PATH=https://downloads.lede-project.org/snapshots/targets/ar71xx/generic/ SDK=lede-sdk-ar71xx-generic_gcc-5.4.0_musl.Linux-x86_64 PACKAGES_DIR="$PWD" +echo_red() { printf "\033[1;31m$*\033[m\n"; } +echo_green() { printf "\033[1;32m$*\033[m\n"; } +echo_blue() { printf "\033[1;34m$*\033[m\n"; } + +exec_status() { + PATTERN="$1" + shift + while :;do sleep 590;echo "still running (please don't kill me Travis)";done & + ("$@" 2>&1) | tee logoutput + R=${PIPESTATUS[0]} + kill $! && wait $! 2>/dev/null + 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 # The travis cache will be used (all files under $HOME/sdk/). Meaning # We don't have to download the file again @@ -16,7 +40,7 @@ download_sdk() { mkdir -p "$SDK_HOME" cd "$SDK_HOME" - echo "=== download SDK" + echo_blue "=== download SDK" wget "$SDK_PATH/sha256sums" -O sha256sums wget "$SDK_PATH/sha256sums.gpg" -O sha256sums.asc @@ -34,60 +58,138 @@ download_sdk() { # check again and fail here if the file is still bad sha256sum -c ./sha256sums.small - echo "=== SDK is up-to-date" + echo_blue "=== SDK is up-to-date" } # test_package will run on the `script` step. -# test_package call make download check for very new/modified package in it's -# own clean sdk directory -test_packages() { +# test_package call make download check for very new/modified package +test_packages2() { # search for new or modified packages. PKGS will hold a list of package like 'admin/muninlite admin/monit ...' - PKGS=$(git diff --stat "$TRAVIS_COMMIT_RANGE" | grep Makefile | grep -v '/files/' | awk '{ print $1}' | awk -F'/Makefile' '{ print $1 }') + PKGS=$(git diff --diff-filter=d --name-only "$TRAVIS_COMMIT_RANGE" | grep 'Makefile$' | grep -v '/files/' | awk -F'/Makefile' '{ print $1 }') if [ -z "$PKGS" ] ; then - echo "No new or modified packages found!" >&2 - exit 0 + echo_blue "No new or modified packages found!" + return 0 fi - echo "=== Found new/modified packages:" + echo_blue "=== Found new/modified packages:" for pkg in $PKGS ; do echo "===+ $pkg" done + echo_blue "=== Setting up SDK" + tmp_path=$(mktemp -d) + cd "$tmp_path" + tar Jxf "$SDK_HOME/$SDK.tar.xz" --strip=1 + + # use github mirrors to spare lede servers + cat > feeds.conf < /dev/null + ./scripts/feeds install -a > /dev/null + make defconfig > /dev/null + echo_blue "=== Setting up SDK done" + + RET=0 # E.g: pkg_dir => admin/muninlite - # pkg_name => muninlite + # pkg_name => muninlite for pkg_dir in $PKGS ; do pkg_name=$(echo "$pkg_dir" | awk -F/ '{ print $NF }') - tmp_path=$HOME/tmp/$pkg_name/ + echo_blue "=== $pkg_name: Starting quick tests" - echo "=== $pkg_name Testing package" + 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 - # create a clean sdk for every package - mkdir -p "$tmp_path" - cd "$tmp_path" - tar Jxf "$SDK_HOME/$SDK.tar.xz" - cd "$SDK" + echo_blue "=== $pkg_name: quick tests done" + done - cat > feeds.conf </dev/null >/dev/null - ./scripts/feeds install "$pkg_name" - - make defconfig - make "package/$pkg_name/download" V=s - make "package/$pkg_name/check" V=s | tee -a logoutput - grep WARNING logoutput && exit 1 - rm -rf "$tmp_path" - echo "=== $pkg_name Finished package" + [ $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" + + # we can't enable verbose built else we often hit Travis limits + # on log size and the job get killed + exec_status '^ERROR' make "package/$pkg_name/compile" -j3 || RET=1 + + echo_blue "=== $pkg_name: compile test done" + + echo_blue "=== $pkg_name: begin compile logs" + for f in $(find logs/package/feeds/packages/$pkg_name/ -type f); do + echo_blue "Printing last 200 lines of $f" + tail -n200 "$f" + done + echo_blue "=== $pkg_name: end compile logs" + + echo_blue "=== $pkg_name: begin packages sizes" + du -ba bin/ + echo_blue "=== $pkg_name: end packages sizes" done + + return $RET +} + +test_commits() { + RET=0 + for commit in $(git rev-list ${TRAVIS_COMMIT_RANGE/.../..}); do + echo_blue "=== Checking commit '$commit'" + if git show --format='%P' -s $commit | grep -qF ' '; then + echo_red "Pull request should not include merge commits" + RET=1 + fi + + author="$(git show -s --format=%aN $commit)" + if echo $author | grep -q '\S\+\s\+\S\+'; then + echo_green "Author name ($author) seems ok" + else + echo_red "Author name ($author) need to be your real name 'firstname lastname'" + RET=1 + fi + + subject="$(git show -s --format=%s $commit)" + if echo "$subject" | grep -q -e '^[0-9A-Za-z,/-]\+: ' -e '^Revert '; then + echo_green "Commit subject line seems ok ($subject)" + else + echo_red "Commit subject line MUST start with ': ' ($subject)" + RET=1 + fi + + body="$(git show -s --format=%b $commit)" + sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)" + if echo "$body" | grep -qF "$sob"; then + echo_green "Signed-off-by match author" + else + echo_red "Signed-off-by is missing or doesn't match author (should be '$sob')" + RET=1 + fi + done + + return $RET +} + +test_packages() { + test_commits && test_packages2 || return 1 } -export +echo_blue "=== Travis ENV" +env +echo_blue "=== Travis ENV" + +while true; do + # if clone depth is too small, git rev-list / diff return incorrect or empty results + C="$(git rev-list ${TRAVIS_COMMIT_RANGE/.../..} | tail -n1)" 2>/dev/null + [ -n "$C" -a "$C" != "a22de9b74cf9579d1ce7e6cf1845b4afa4277b00" ] && break + echo_blue "Fetching 50 commits more" + git fetch origin --deepen=50 +done if [ "$TRAVIS_PULL_REQUEST" = false ] ; then echo "Only Pull Requests are supported at the moment." >&2