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')]" ; }
18 CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; }
20 CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; }
22 have_sudo() { sudo /bin/true &>/dev/null ; }
24 is_cperl() { [[ "$BREWVER" =~ $( echo -n "^cperl-" ) ]] ; }
28 ========================== CI System information ============================
31 $(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
44 = Network Configuration
47 = Network Sockets Status
48 $( (sudo netstat -an46p || netstat -an46p) | grep -Pv '\s(CLOSING|(FIN|TIME|CLOSE)_WAIT.?|LAST_ACK)\s')
54 $(env | grep -P 'TEST|HARNESS|MAKE|TRAVIS|PERL|DBIC|PATH|SHELL' | LC_ALL=C sort | cat -v)
58 ============================================================================="
62 echo_err -n "$(tstamp) $1 ... "
68 PRMETER_PIDFILE="$(tempfile)_$SECONDS"
69 # the double bash is to hide the job control messages
70 bash -c "bash -c 'echo \$\$ >> $PRMETER_PIDFILE; while true; do sleep 10; echo -n \"\${SECONDS}s ... \"; done' &"
72 LASTOUT=$( eval "$2" 2>&1 ) || LASTEXIT=$?
75 for p in $(cat "$PRMETER_PIDFILE"); do kill $p ; done
77 DELTA_TIME=$(( $SECONDS - $START_TIME ))
79 if [[ "$LASTEXIT" != "0" ]] ; then
80 if [[ -z "$3" ]] ; then
81 echo_err "FAILED !!! (after ${DELTA_TIME}s)"
82 echo_err "Command executed:"
84 echo_err "STDOUT+STDERR:"
86 if [[ "$(dmesg)" =~ $( echo "\\bOOM\\b" ) ]] ; then
87 echo_err "=== dmesg ringbuffer"
94 echo_err "done (took ${DELTA_TIME}s)"
102 run_or_err "Installing APT packages: $pkgs" "sudo apt-get install --allow-unauthenticated --no-install-recommends -y $pkgs"
106 # once --verbose is set, --no-verbose can't disable it
108 local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )"
112 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \
115 OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!}
116 ERR=${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}
118 if [[ "$LASTEXIT" != "0" ]] ; then
119 echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:"
125 # throw away warnings, up-to-date diag, ascii art, convert to modnames
127 s/^.*?is up to date.*$//;
130 s/\-[^\-]+$/ /; # strip version part
134 # throw away what was in $@
136 PQ=$( perl -p -e 's/(?:\s|^)\Q'"$m"'\E(?:\s|$)/ /mg' <<< "$PQ")
143 parallel_installdeps_notest() {
144 if [[ -z "$@" ]] ; then return; fi
146 is_cperl && echo_err "cpanminus is not yet usable on cperl" && exit 1
148 # one module spec per line
149 MODLIST="$(printf '%s\n' "$@" | sort -R)"
151 # We want to trap the output of each process and serially append them to
152 # each other as opposed to just dumping a jumbled up mass-log that would
153 # need careful unpicking by a human
155 # While cpanm does maintain individual buildlogs in more recent versions,
156 # we are not terribly interested in trying to figure out which log is which
157 # dist. The verbose-output + trap STDIO technique is vastly superior in this
160 # Explanation of inline args:
162 # [09:38] <T> you need a $0
163 # [09:38] <G> hence the _
164 # [09:38] <G> bash -c '...' _
165 # [09:39] <T> I like -- because it's the magic that gnu getopts uses for somethign else
166 # [09:39] <G> or --, yes
167 # [09:39] <T> ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well
169 run_or_err "Installing (without testing) $(echo $MODLIST)" \
172 | xargs -d '\\n' -n 1 -P $VCPU_USE bash -c \\
173 'OUT=\$(maint/getstatus $TIMEOUT_CMD cpanm --notest \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\
174 'giant space monkey penises'
178 export -f parallel_installdeps_notest run_or_err echo_err tstamp is_cperl have_sudo CPAN_is_sane CPAN_supports_BUILDPL
181 if [[ -z "$@" ]] ; then return; fi
183 MODLIST=$(printf "%q " "$@" | perl -pe 's/^\s+|\s+$//g')
185 local -x HARNESS_OPTIONS
187 HARNESS_OPTIONS="j$VCPU_USE"
189 if ! run_or_err "Attempting install of $# modules under parallel ($HARNESS_OPTIONS) testing ($MODLIST)" "_dep_inst_with_test $MODLIST" quiet_fail ; then
190 local errlog="failed after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/perl /usr/bin/nopaste -q -s Shadowcat -d "Parallel testfail" <<< "$LASTOUT")"
193 POSTMORTEM="$POSTMORTEM$(
195 echo "Depinstall of $MODLIST under $HARNESS_OPTIONS parallel testing $errlog"
199 run_or_err "Retrying same $# modules without parallel testing" "_dep_inst_with_test $MODLIST"
202 INSTALLDEPS_OUT="${INSTALLDEPS_OUT}${LASTOUT}"
205 _dep_inst_with_test() {
206 if [[ "$DEVREL_DEPS" == "true" ]] ; then
207 is_cperl && echo_err "cpanminus is not yet usable on cperl" && exit 1
209 # --dev is already part of CPANM_OPT
210 LASTCMD="$TIMEOUT_CMD cpanm $@"
211 $LASTCMD 2>&1 || return 1
213 LASTCMD="$TIMEOUT_CMD cpan $@"
214 $LASTCMD 2>&1 || return 1
216 # older perls do not have a CPAN which can exit with error on failed install
220 $ARGV[0] =~ s/-TRIAL\.//;
224 $ARGV[0] =~ m{ / .*? ( [^/]+ ) $ }x
225 ? do { my @p = split (/\-/, $1); pop @p; join "::", @p }
229 # map some install-names to a module/version combo
230 # serves both as a grandfathered title-less tarball, and
231 # as a minimum version check for upgraded core modules
234 # this is temporary, will need something more robust down the road
235 # (perhaps by then Module::CoreList will be dep-free)
236 "Module::Build" => { ver => "0.4214" },
237 "podlators" => { mod => "Pod::Man", ver => "2.17" },
239 "File::Spec" => { ver => "3.47" },
240 "Cwd" => { ver => "3.47" },
242 "List::Util" => { ver => "1.42" },
243 "Scalar::Util" => { ver => "1.42" },
244 "Scalar::List::Utils" => { mod => "List::Util", ver => "1.42" },
247 my $m = $eval_map->{$mod}{mod} || $mod;
254 ($eval_map->{$mod}{ver}
255 ? "; $m->VERSION(\$eval_map->{\$mod}{ver}) "
264 ( print $@ and exit 1)
266 ' "$m" 2> /dev/null ; then
267 echo -e "$m installation seems to have failed"
275 # https://github.com/kentfredric/Dist-Zilla-Plugin-Prereqs-MatchInstalled-All/blob/master/maint-travis-ci/sterilize_env.pl
276 # Only works on 5.12+ (where sitelib was finally properly fixed)
278 echo_err "$(tstamp) Sterilizing the Perl installation (cleaning up sitelib)"
280 if perl -M5.012 -e1 &>/dev/null ; then
282 perl -M5.012 -MConfig -MFile::Find -e '
284 map { $Config{$_} => 1 }
285 grep { $_ =~ /site(lib|arch)exp$/ }
288 find({ bydepth => 1, no_chdir => 1, follow_fast => 1, wanted => sub {
289 ! $sitedirs->{$_} and ( -d _ ? rmdir : unlink )
290 } }, keys %$sitedirs )
294 cl_fn="/tmp/${TRAVIS_BUILD_ID}_Module_CoreList.pm";
296 [[ -s "$cl_fn" ]] || run_or_err \
297 "Downloading latest Module::CoreList" \
298 "curl -s --compress -o '$cl_fn' https://api.metacpan.org/source/Module::CoreList"
300 perl -0777 -Ilib -MDBIx::Class::Optional::Dependencies -e '
302 # this is horrible, but really all we want is "has this ever been used"
303 # so a grep without a load is quite legit (and horrible)
306 my @all_possible_never_been_core_modpaths = map
307 { (my $mp = $_ . ".pm" ) =~ s|::|/|g; $mp }
309 { $mcl_source !~ / ^ \s+ \x27 $_ \x27 \s* \=\> /mx }
314 keys %{ DBIx::Class::Optional::Dependencies->modreq_list_for([
315 keys %{ DBIx::Class::Optional::Dependencies->req_group_list }
320 # now that we have the list we can go ahead and destroy every single one
321 # of these modules without being concerned about breaking the base ability
323 for my $mp ( sort { lc($a) cmp lc($b) } @all_possible_never_been_core_modpaths ) {
324 for my $incdir (@INC) {
329 print "Nuking $incdir/$mp\n"