X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=maint%2Ftravis-ci_scripts%2Fcommon.bash;h=d50aebb439a9bd97b5aca2f419981c6f47368851;hb=777447e927d828478debc4e011aa2f28707bc008;hp=230d140f7c892b87fd140cfaced9cf28135dd5e3;hpb=c86519d7c54ad69e5da97f6c2ccb469d50f49129;p=dbsrgits%2FDBIx-Class.git diff --git a/maint/travis-ci_scripts/common.bash b/maint/travis-ci_scripts/common.bash index 230d140..d50aebb 100755 --- a/maint/travis-ci_scripts/common.bash +++ b/maint/travis-ci_scripts/common.bash @@ -3,6 +3,7 @@ set -e TEST_STDERR_LOG=/tmp/dbictest.stderr +TIMEOUT_CMD="/usr/bin/timeout --kill-after=9.5m --signal=TERM 9m" echo_err() { echo "$@" 1>&2 ; } @@ -18,6 +19,8 @@ run_or_err() { LASTEXIT=0 START_TIME=$SECONDS + # the tee is a handy debugging tool when stumpage is exceedingly strong + #LASTOUT=$( bash -c "$2" 2>&1 | tee /dev/stderr) || LASTEXIT=$? LASTOUT=$( bash -c "$2" 2>&1 ) || LASTEXIT=$? DELTA_TIME=$(( $SECONDS - $START_TIME )) @@ -34,6 +37,16 @@ run_or_err() { fi } +apt_install() { + # flatten + pkgs="$@" + + # Need to do this at every step, the sources list may very well have changed + run_or_err "Updating APT available package list" "sudo apt-get update" + + run_or_err "Installing Debian APT packages: $pkgs" "sudo apt-get install --allow-unauthenticated --no-install-recommends -y $pkgs" +} + extract_prereqs() { # once --verbose is set, --no-verbose can't disable it # do this by hand @@ -45,7 +58,7 @@ extract_prereqs() { || LASTEXIT=$? OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!} - ERR=$(grep -v " is up to date." <<< "${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}") + ERR=${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*} if [[ "$LASTEXIT" != "0" ]] ; then echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:" @@ -54,8 +67,14 @@ extract_prereqs() { exit 1 fi - # throw away ascii art, convert to modnames - PQ=$(perl -p -e 's/^[^a-z]+//i; s/\-[^\-]+$/ /; s/\-/::/g' <<< "$OUT") + # throw away warnings, up-to-date diag, ascii art, convert to modnames + PQ=$(perl -p -e ' + s/^.*?is up to date.*$//; + s/^\!.*//; + s/^[^a-z]+//i; + s/\-[^\-]+$/ /; # strip version part + s/\-/::/g + ' <<< "$OUT") # throw away what was in $@ for m in "$@" ; do @@ -72,10 +91,14 @@ parallel_installdeps_notest() { # one module spec per line MODLIST="$(printf '%s\n' "$@")" - # The reason we do things so "non-interactively" is that xargs -P will have the - # latest cpanm instance overwrite the buildlog. There seems to be no way to - # specify a custom buildlog, hence we just collect the verbose output - # and display it in case of "worker" failure + # We want to trap the output of each process and serially append them to + # each other as opposed to just dumping a jumbled up mass-log that would + # need careful unpicking by a human + # + # While cpanm does maintain individual buildlogs in more recent versions, + # we are not terribly interested in trying to figure out which log is which + # dist. The verbose-output + trap STDIO technique is vastly superior in this + # particular case # # Explanation of inline args: # @@ -90,7 +113,7 @@ parallel_installdeps_notest() { "echo \\ \"$MODLIST\" \\ | xargs -d '\\n' -n 1 -P $NUMTHREADS bash -c \\ - 'OUT=\$(cpanm --notest --no-man-pages \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\ + 'OUT=\$($TIMEOUT_CMD cpanm --notest \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\ 'giant space monkey penises' " } @@ -108,18 +131,26 @@ installdeps() { LASTEXIT=0 START_TIME=$SECONDS - LASTOUT=$( cpan_inst "$@" ) || LASTEXIT=$? + LASTOUT=$( _dep_inst_with_test "$@" ) || LASTEXIT=$? DELTA_TIME=$(( $SECONDS - $START_TIME )) if [[ "$LASTEXIT" = "0" ]] ; then echo_err "done (took ${DELTA_TIME}s)" else - echo_err -n "failed (after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/nopaste -q -s Shadowcat -d "Parallel installfail" <<< "$LASTOUT")) retrying with sequential testing ... " + local errlog="after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/nopaste -q -s Shadowcat -d "Parallel testfail" <<< "$LASTOUT")" + echo_err -n "failed ($errlog) retrying with sequential testing ... " + POSTMORTEM="$POSTMORTEM$( + echo + echo "Depinstall under $HARNESS_OPTIONS parallel testing failed $errlog" + echo "=============================================================" + echo "Attempted installation of: $@" + echo "=============================================================" + )" HARNESS_OPTIONS="" LASTEXIT=0 START_TIME=$SECONDS - LASTOUT=$( cpan_inst "$@" ) || LASTEXIT=$? + LASTOUT=$( _dep_inst_with_test "$@" ) || LASTEXIT=$? DELTA_TIME=$(( $SECONDS - $START_TIME )) if [[ "$LASTEXIT" = "0" ]] ; then @@ -135,23 +166,33 @@ installdeps() { INSTALLDEPS_OUT="${INSTALLDEPS_OUT}${LASTOUT}" } -cpan_inst() { - /usr/bin/timeout --kill-after=9.5m --signal=TERM 9m cpan "$@" 2>&1 +_dep_inst_with_test() { + if [[ "$DEVREL_DEPS" == "true" ]] ; then + # --dev is already part of CPANM_OPT + $TIMEOUT_CMD cpanm "$@" 2>&1 + else + $TIMEOUT_CMD cpan "$@" 2>&1 - # older perls do not have a CPAN which can exit with error on failed install - for m in "$@"; do - if ! perl -e ' + # older perls do not have a CPAN which can exit with error on failed install + for m in "$@"; do + if ! perl -e ' -eval ( q{require } . ( +my $mod = ( $ARGV[0] =~ m{ \/ .*? ([^\/]+) $ }x ? do { my @p = split (/\-/, $1); pop @p; join "::", @p } : $ARGV[0] -) ) or ( print $@ and exit 1)' "$m" 2> /dev/null ; then +); - echo -e "$m installation seems to have failed" - return 1 - fi - done +$mod = q{List::Util} if $mod eq q{Scalar::List::Utils}; + +eval qq{require($mod)} or ( print $@ and exit 1) + + ' "$m" 2> /dev/null ; then + echo -e "$m installation seems to have failed" + return 1 + fi + done + fi } CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; }