X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=maint%2Ftravis-ci_scripts%2Fcommon.bash;h=1f4df7873c9b790ed7e7d66729a48699b2456f37;hb=2c657cb2de22d57b304d5965cd99ccbd8a59441a;hp=ee447e367f1c056d9e759a0b1c4f505e62ae8460;hpb=afeb40d23677e897d27b843b8d976d7c8945e6ce;p=dbsrgits%2FDBIx-Class.git diff --git a/maint/travis-ci_scripts/common.bash b/maint/travis-ci_scripts/common.bash index ee447e3..1f4df78 100755 --- a/maint/travis-ci_scripts/common.bash +++ b/maint/travis-ci_scripts/common.bash @@ -4,7 +4,7 @@ set -e TEST_STDERR_LOG=/tmp/dbictest.stderr -TIMEOUT_CMD="/usr/bin/timeout --kill-after=9.5m --signal=TERM 9m" +TIMEOUT_CMD="/usr/bin/timeout --kill-after=16m --signal=TERM 15m" echo_err() { echo "$@" 1>&2 ; } @@ -87,9 +87,6 @@ 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" } @@ -135,7 +132,7 @@ parallel_installdeps_notest() { if [[ -z "$@" ]] ; then return; fi # one module spec per line - MODLIST="$(printf '%s\n' "$@")" + MODLIST="$(printf '%s\n' "$@" | sort -R)" # 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 @@ -158,7 +155,7 @@ parallel_installdeps_notest() { run_or_err "Installing (without testing) $(echo $MODLIST)" \ "echo \\ \"$MODLIST\" \\ - | xargs -d '\\n' -n 1 -P $NUMTHREADS bash -c \\ + | xargs -d '\\n' -n 1 -P $VCPU_USE bash -c \\ 'OUT=\$(maint/getstatus $TIMEOUT_CMD cpanm --notest \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\ 'giant space monkey penises' " @@ -171,7 +168,7 @@ installdeps() { local -x HARNESS_OPTIONS - HARNESS_OPTIONS="j$NUMTHREADS" + 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")" @@ -193,17 +190,20 @@ _dep_inst_with_test() { if [[ "$DEVREL_DEPS" == "true" ]] ; then # --dev is already part of CPANM_OPT LASTCMD="$TIMEOUT_CMD cpanm $@" - $LASTCMD 2>&1 + $LASTCMD 2>&1 || return 1 else LASTCMD="$TIMEOUT_CMD cpan $@" - $LASTCMD 2>&1 + $LASTCMD 2>&1 || return 1 # older perls do not have a CPAN which can exit with error on failed install 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] ); @@ -220,6 +220,70 @@ eval qq{require($mod)} or ( print $@ and exit 1) fi } +# Idea stolen from +# https://github.com/kentfredric/Dist-Zilla-Plugin-Prereqs-MatchInstalled-All/blob/master/maint-travis-ci/sterilize_env.pl +# Only works on 5.12+ (where sitelib was finally properly fixed) +purge_sitelib() { + echo_err "$(tstamp) Sterilizing the Perl installation (cleaning up sitelib)" + + if perl -M5.012 -e1 &>/dev/null ; then + + perl -M5.012 -MConfig -MFile::Find -e ' + my $sitedirs = { + map { $Config{$_} => 1 } + grep { $_ =~ /site(lib|arch)exp$/ } + keys %Config + }; + find({ bydepth => 1, no_chdir => 1, follow_fast => 1, wanted => sub { + ! $sitedirs->{$_} and ( -d _ ? rmdir : unlink ) + } }, keys %$sitedirs ) + ' + else + + cl_fn="/tmp/${TRAVIS_BUILD_ID}_Module_CoreList.pm"; + + [[ -s "$cl_fn" ]] || run_or_err \ + "Downloading latest Module::CoreList" \ + "curl -s --compress -o '$cl_fn' https://api.metacpan.org/source/Module::CoreList" + + perl -0777 -Ilib -MDBIx::Class::Optional::Dependencies -e ' + + # this is horrible, but really all we want is "has this ever been used" + # so a grep without a load is quite legit (and horrible) + my $mcl_source = <>; + + my @all_possible_never_been_core_modpaths = map + { (my $mp = $_ . ".pm" ) =~ s|::|/|g; $mp } + grep + { $mcl_source !~ / ^ \s+ \x27 $_ \x27 \s* \=\> /mx } + ( + qw( + Module::Build::Tiny + ), + keys %{ DBIx::Class::Optional::Dependencies->modreq_list_for([ + keys %{ DBIx::Class::Optional::Dependencies->req_group_list } + ])} + ) + ; + + # now that we have the list we can go ahead and destroy every single one + # of these modules without being concerned about breaking the base ability + # to install things + for my $mp ( sort { lc($a) cmp lc($b) } @all_possible_never_been_core_modpaths ) { + for my $incdir (@INC) { + -e "$incdir/$mp" + and + unlink "$incdir/$mp" + and + print "Nuking $incdir/$mp\n" + } + } + ' "$cl_fn" + + fi +} + + CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; } CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; }