X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=maint%2Ftravis-ci_scripts%2Fcommon.bash;h=48fb7c1d118feb4c2eda3f6b5e142377ca288a34;hb=89d5e36fd191c1e303f91f15cd8c7c3d55fe6715;hp=f8909651892049436817aa99708cb98905e39c79;hpb=113087b70fdd216a3ac53afcd0e5e691c5223224;p=dbsrgits%2FDBIx-Class.git diff --git a/maint/travis-ci_scripts/common.bash b/maint/travis-ci_scripts/common.bash old mode 100755 new mode 100644 index f890965..48fb7c1 --- a/maint/travis-ci_scripts/common.bash +++ b/maint/travis-ci_scripts/common.bash @@ -1,5 +1,10 @@ #!/bin/bash +if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then + echo "This script can not be executed standalone - it can only be source()d" 1>&2 + exit 1 +fi + # "autodie" set -e @@ -15,6 +20,14 @@ fi tstamp() { echo -n "[$(date '+%H:%M:%S')]" ; } +CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; } + +CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; } + +have_sudo() { sudo /bin/true &>/dev/null ; } + +is_cperl() { [[ "$BREWVER" =~ $( echo -n "^cperl-" ) ]] ; } + ci_vm_state_text() { echo " ========================== CI System information ============================ @@ -26,7 +39,7 @@ $(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo) $(free -m -t) = Diskinfo -$(sudo df -h) +$(df -h) $(mount | grep '^/') @@ -37,13 +50,13 @@ $(uname -a) $(ip addr) = Network Sockets Status -$(sudo netstat -an46p | grep -Pv '\s(CLOSING|(FIN|TIME|CLOSE)_WAIT.?|LAST_ACK)\s') +$( (sudo netstat -an46p || netstat -an46p) | grep -Pv '\s(CLOSING|(FIN|TIME|CLOSE)_WAIT.?|LAST_ACK)\s') = Processlist -$(sudo ps fuxa) +$(ps fuxa) = Environment -$(env | grep -P 'TEST|HARNESS|MAKE|TRAVIS|PERL|DBIC' | LC_ALL=C sort | cat -v) +$(env | grep -P 'TEST|HARNESS|MAKE|TRAVIS|PERL|DBIC|PATH|SHELL' | LC_ALL=C sort | cat -v) = Perl in use $(perl -V) @@ -75,6 +88,10 @@ run_or_err() { echo_err "$LASTCMD" echo_err "STDOUT+STDERR:" echo_err "$LASTOUT" + if [[ "$(dmesg)" =~ $( echo "\\bOOM\\b" ) ]] ; then + echo_err "=== dmesg ringbuffer" + echo_err "$(dmesg)" + fi fi return $LASTEXIT @@ -87,7 +104,7 @@ apt_install() { # flatten pkgs="$@" - run_or_err "Installing Debian APT packages: $pkgs" "sudo apt-get install --allow-unauthenticated --no-install-recommends -y $pkgs" + run_or_err "Installing APT packages: $pkgs" "sudo apt-get install --allow-unauthenticated --no-install-recommends -y $pkgs" } extract_prereqs() { @@ -131,6 +148,8 @@ extract_prereqs() { parallel_installdeps_notest() { if [[ -z "$@" ]] ; then return; fi + is_cperl && echo_err "cpanminus is not yet usable on cperl" && exit 1 + # one module spec per line MODLIST="$(printf '%s\n' "$@" | sort -R)" @@ -161,6 +180,8 @@ parallel_installdeps_notest() { " } +export -f parallel_installdeps_notest run_or_err echo_err tstamp is_cperl have_sudo CPAN_is_sane CPAN_supports_BUILDPL + installdeps() { if [[ -z "$@" ]] ; then return; fi @@ -171,7 +192,7 @@ installdeps() { HARNESS_OPTIONS="j$VCPU_USE" if ! run_or_err "Attempting install of $# modules under parallel ($HARNESS_OPTIONS) testing ($MODLIST)" "_dep_inst_with_test $MODLIST" quiet_fail ; then - local errlog="failed after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/nopaste -q -s Shadowcat -d "Parallel testfail" <<< "$LASTOUT")" + local errlog="failed after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/perl /usr/bin/nopaste -q -s Shadowcat -d "Parallel testfail" <<< "$LASTOUT")" echo "$errlog" POSTMORTEM="$POSTMORTEM$( @@ -188,6 +209,8 @@ installdeps() { _dep_inst_with_test() { if [[ "$DEVREL_DEPS" == "true" ]] ; then + is_cperl && echo_err "cpanminus is not yet usable on cperl" && exit 1 + # --dev is already part of CPANM_OPT LASTCMD="$TIMEOUT_CMD cpanm $@" $LASTCMD 2>&1 || return 1 @@ -199,15 +222,51 @@ _dep_inst_with_test() { for m in "$@"; do if ! perl -e ' +$ARGV[0] =~ s/-TRIAL\.//; + my $mod = ( - $ARGV[0] =~ m{ \/ .*? ([^\/]+) $ }x + # abuse backtrack + $ARGV[0] =~ m{ / .*? ( [^/]+ ) $ }x ? do { my @p = split (/\-/, $1); pop @p; join "::", @p } : $ARGV[0] ); -$mod = q{List::Util} if $mod eq q{Scalar::List::Utils}; +# map some install-names to a module/version combo +# serves both as a grandfathered title-less tarball, and +# as a minimum version check for upgraded core modules +my $eval_map = { -eval qq{require($mod)} or ( print $@ and exit 1) + # this is temporary, will need something more robust down the road + # (perhaps by then Module::CoreList will be dep-free) + "Module::Build" => { ver => "0.4214" }, + "podlators" => { mod => "Pod::Man", ver => "2.17" }, + + "File::Spec" => { ver => "3.47" }, + "Cwd" => { ver => "3.47" }, + + "List::Util" => { ver => "1.42" }, + "Scalar::Util" => { ver => "1.42" }, + "Scalar::List::Utils" => { mod => "List::Util", ver => "1.42" }, +}; + +my $m = $eval_map->{$mod}{mod} || $mod; + +eval( + "require $m" + + . + + ($eval_map->{$mod}{ver} + ? "; $m->VERSION(\$eval_map->{\$mod}{ver}) " + : "" + ) + + . + + "; 1" +) + or +( print $@ and exit 1) ' "$m" 2> /dev/null ; then echo -e "$m installation seems to have failed" @@ -279,8 +338,3 @@ purge_sitelib() { fi } - - -CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; } - -CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; }