6 TEST_STDERR_LOG=/tmp/dbictest.stderr
7 TIMEOUT_CMD="/usr/bin/timeout --kill-after=16m --signal=TERM 15m"
9 echo_err() { echo "$@" 1>&2 ; }
11 if [[ "$TRAVIS" != "true" ]] ; then
12 echo_err "Running this script makes no sense outside of travis-ci"
16 tstamp() { echo -n "[$(date '+%H:%M:%S')]" ; }
20 ========================== CI System information ============================
23 $(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
36 = Network Configuration
39 = Network Sockets Status
40 $( (sudo netstat -an46p || netstat -an46p) | grep -Pv '\s(CLOSING|(FIN|TIME|CLOSE)_WAIT.?|LAST_ACK)\s')
46 $(env | grep -P 'TEST|HARNESS|MAKE|TRAVIS|PERL|DBIC|PATH|SHELL' | LC_ALL=C sort | cat -v)
50 ============================================================================="
54 echo_err -n "$(tstamp) $1 ... "
60 PRMETER_PIDFILE="$(tempfile)_$SECONDS"
61 # the double bash is to hide the job control messages
62 bash -c "bash -c 'echo \$\$ >> $PRMETER_PIDFILE; while true; do sleep 10; echo -n \"\${SECONDS}s ... \"; done' &"
64 LASTOUT=$( eval "$2" 2>&1 ) || LASTEXIT=$?
67 for p in $(cat "$PRMETER_PIDFILE"); do kill $p ; done
69 DELTA_TIME=$(( $SECONDS - $START_TIME ))
71 if [[ "$LASTEXIT" != "0" ]] ; then
72 if [[ -z "$3" ]] ; then
73 echo_err "FAILED !!! (after ${DELTA_TIME}s)"
74 echo_err "Command executed:"
76 echo_err "STDOUT+STDERR:"
78 if [[ "$(dmesg)" =~ $( echo "\\bOOM\\b" ) ]] ; then
79 echo_err "=== dmesg ringbuffer"
86 echo_err "done (took ${DELTA_TIME}s)"
94 run_or_err "Installing Debian APT packages: $pkgs" "sudo apt-get install --allow-unauthenticated --no-install-recommends -y $pkgs"
98 # once --verbose is set, --no-verbose can't disable it
100 local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )"
104 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \
107 OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!}
108 ERR=${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}
110 if [[ "$LASTEXIT" != "0" ]] ; then
111 echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:"
117 # throw away warnings, up-to-date diag, ascii art, convert to modnames
119 s/^.*?is up to date.*$//;
122 s/\-[^\-]+$/ /; # strip version part
126 # throw away what was in $@
128 PQ=$( perl -p -e 's/(?:\s|^)\Q'"$m"'\E(?:\s|$)/ /mg' <<< "$PQ")
135 parallel_installdeps_notest() {
136 if [[ -z "$@" ]] ; then return; fi
138 is_cperl && echo_err "cpanminus is not yet usable on cperl" && exit 1
140 # one module spec per line
141 MODLIST="$(printf '%s\n' "$@" | sort -R)"
143 # We want to trap the output of each process and serially append them to
144 # each other as opposed to just dumping a jumbled up mass-log that would
145 # need careful unpicking by a human
147 # While cpanm does maintain individual buildlogs in more recent versions,
148 # we are not terribly interested in trying to figure out which log is which
149 # dist. The verbose-output + trap STDIO technique is vastly superior in this
152 # Explanation of inline args:
154 # [09:38] <T> you need a $0
155 # [09:38] <G> hence the _
156 # [09:38] <G> bash -c '...' _
157 # [09:39] <T> I like -- because it's the magic that gnu getopts uses for somethign else
158 # [09:39] <G> or --, yes
159 # [09:39] <T> ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well
161 run_or_err "Installing (without testing) $(echo $MODLIST)" \
164 | xargs -d '\\n' -n 1 -P $VCPU_USE bash -c \\
165 'OUT=\$(maint/getstatus $TIMEOUT_CMD cpanm --notest \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\
166 'giant space monkey penises'
170 export -f parallel_installdeps_notest run_or_err echo_err tstamp
173 if [[ -z "$@" ]] ; then return; fi
175 MODLIST=$(printf "%q " "$@" | perl -pe 's/^\s+|\s+$//g')
177 local -x HARNESS_OPTIONS
179 HARNESS_OPTIONS="j$VCPU_USE"
181 if ! run_or_err "Attempting install of $# modules under parallel ($HARNESS_OPTIONS) testing ($MODLIST)" "_dep_inst_with_test $MODLIST" quiet_fail ; then
182 local errlog="failed after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/perl /usr/bin/nopaste -q -s Shadowcat -d "Parallel testfail" <<< "$LASTOUT")"
185 POSTMORTEM="$POSTMORTEM$(
187 echo "Depinstall of $MODLIST under $HARNESS_OPTIONS parallel testing $errlog"
191 run_or_err "Retrying same $# modules without parallel testing" "_dep_inst_with_test $MODLIST"
194 INSTALLDEPS_OUT="${INSTALLDEPS_OUT}${LASTOUT}"
197 _dep_inst_with_test() {
198 if [[ "$DEVREL_DEPS" == "true" ]] ; then
199 is_cperl && echo_err "cpanminus is not yet usable on cperl" && exit 1
201 # --dev is already part of CPANM_OPT
202 LASTCMD="$TIMEOUT_CMD cpanm $@"
203 $LASTCMD 2>&1 || return 1
205 LASTCMD="$TIMEOUT_CMD cpan $@"
206 $LASTCMD 2>&1 || return 1
208 # older perls do not have a CPAN which can exit with error on failed install
212 $ARGV[0] =~ s/-TRIAL\.//;
216 $ARGV[0] =~ m{ / .*? ( [^/]+ ) $ }x
217 ? do { my @p = split (/\-/, $1); pop @p; join "::", @p }
221 # map some install-names to a module/version combo
222 # serves both as a grandfathered title-less tarball, and
223 # as a minimum version check for upgraded core modules
226 # this is temporary, will need something more robust down the road
227 # (perhaps by then Module::CoreList will be dep-free)
228 "Module::Build" => { ver => "0.4214" },
229 "podlators" => { mod => "Pod::Man", ver => "2.17" },
231 "File::Spec" => { ver => "3.47" },
232 "Cwd" => { ver => "3.47" },
234 "List::Util" => { ver => "1.42" },
235 "Scalar::Util" => { ver => "1.42" },
236 "Scalar::List::Utils" => { mod => "List::Util", ver => "1.42" },
239 my $m = $eval_map->{$mod}{mod} || $mod;
246 ($eval_map->{$mod}{ver}
247 ? "; $m->VERSION(\$eval_map->{\$mod}{ver}) "
256 ( print $@ and exit 1)
258 ' "$m" 2> /dev/null ; then
259 echo -e "$m installation seems to have failed"
267 # https://github.com/kentfredric/Dist-Zilla-Plugin-Prereqs-MatchInstalled-All/blob/master/maint-travis-ci/sterilize_env.pl
268 # Only works on 5.12+ (where sitelib was finally properly fixed)
270 echo_err "$(tstamp) Sterilizing the Perl installation (cleaning up sitelib)"
272 if perl -M5.012 -e1 &>/dev/null ; then
274 perl -M5.012 -MConfig -MFile::Find -e '
276 map { $Config{$_} => 1 }
277 grep { $_ =~ /site(lib|arch)exp$/ }
280 find({ bydepth => 1, no_chdir => 1, follow_fast => 1, wanted => sub {
281 ! $sitedirs->{$_} and ( -d _ ? rmdir : unlink )
282 } }, keys %$sitedirs )
286 cl_fn="/tmp/${TRAVIS_BUILD_ID}_Module_CoreList.pm";
288 [[ -s "$cl_fn" ]] || run_or_err \
289 "Downloading latest Module::CoreList" \
290 "curl -s --compress -o '$cl_fn' https://api.metacpan.org/source/Module::CoreList"
292 perl -0777 -Ilib -MDBIx::Class::Optional::Dependencies -e '
294 # this is horrible, but really all we want is "has this ever been used"
295 # so a grep without a load is quite legit (and horrible)
298 my @all_possible_never_been_core_modpaths = map
299 { (my $mp = $_ . ".pm" ) =~ s|::|/|g; $mp }
301 { $mcl_source !~ / ^ \s+ \x27 $_ \x27 \s* \=\> /mx }
306 keys %{ DBIx::Class::Optional::Dependencies->modreq_list_for([
307 keys %{ DBIx::Class::Optional::Dependencies->req_group_list }
312 # now that we have the list we can go ahead and destroy every single one
313 # of these modules without being concerned about breaking the base ability
315 for my $mp ( sort { lc($a) cmp lc($b) } @all_possible_never_been_core_modpaths ) {
316 for my $incdir (@INC) {
321 print "Nuking $incdir/$mp\n"
330 CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; }
332 CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; }
334 have_sudo() { sudo /bin/true &>/dev/null ; }
336 is_cperl() { [[ "$BREWVER" =~ $( echo -n "^cperl-" ) ]] ; }