Engage nuclear option of travis testing
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 30_before_script.bash
CommitLineData
b58ecb01 1#!/bin/bash
2
3source maint/travis-ci_scripts/common.bash
4if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
5
eed5492f 6# poison the environment - basically look through lib, find all mentioned
7# ENVvars and set them to true and see if anything explodes
8if [[ "$POISON_ENV" = "true" ]] ; then
9 for var in $(grep -P '\$ENV\{' -r lib/ | grep -oP 'DBIC_\w+' | sort -u | grep -v DBIC_TRACE) ; do
7c1a09fc 10 if [[ -z "${!var}" ]] ; then
11 export $var=1
12 fi
eed5492f 13 done
fb88ca2c 14
444f799b 15 export DBI_DSN="dbi:ODBC:server=NonexistentServerAddress"
16 export DBI_DRIVER="ADO"
17
fb88ca2c 18 export DBICTEST_SQLITE_REVERSE_DEFAULT_ORDER=1
992a24f6 19fi
20
b58ecb01 21if [[ "$CLEANTEST" = "true" ]]; then
22 # get the last inc/ off cpan - we will get rid of MI
23 # soon enough, but till then this will do
24 # the point is to have a *really* clean perl (the ones
25 # we build are guaranteed to be clean, without side
26 # effects from travis preinstalls)
27
28 # trick cpanm into executing true as shell - we just need the find+unpack
29 run_or_err "Downloading DBIC inc/ from CPAN" \
30 "SHELL=/bin/true cpanm --look DBIx::Class"
31
32 mv ~/.cpanm/latest-build/DBIx-Class-*/inc .
33
34 # older perls do not have a CPAN which understands configure_requires
35 # properly and what is worse a `cpan Foo` run exits with 0 even if some
36 # modules failed to install
37 # The first CPAN which is somewhat sane is around 1.94_56 (perl 5.12)
38 # The problem is that the first sane version also brings a *lot* of
39 # deps with it, notably things like YAML and HTTP::Tiny
40 # The goal of CLEANTEST is to have as little extra stuff installed as
41 # possible, mainly to catch "but X is perl core" mistakes
42 # So instead we still use our stock (possibly old) CPAN, and add some
43 # handholding
726501ac 44 if ! CPAN_is_sane ; then
72cd4007 45 for m in \
46ExtUtils::MakeMaker \
47ExtUtils::CBuilder \
72cd4007 48Module::Build \
72cd4007 49; do
726501ac 50 run_or_err "Pre-installing $m" "cpan $m"
2b8f2982 51 if ! perl -e '
52
53eval ( q{require } . (
54 $ARGV[0] =~ m{ \/ .*? ([^\/]+) $ }x
55 ? do { my @p = split (/\-/, $1); pop @p; join "::", @p }
56 : $ARGV[0]
57) ) or ( print $@ and exit 1)' "$m" 2> /dev/null ; then
58
59 echo_err -e "$m installation failed\n$LASTOUT"
60 exit 1
61 fi
726501ac 62 done
63 fi
b58ecb01 64
b58ecb01 65 # DBI has by far the longest test runtime - run less tests
66 # FIXME horrible horrible hack, need to implement in DBI itself
67 run_or_err "Downloading latest DBI distdir from CPAN" \
68 "SHELL=/bin/true cpanm --look DBI"
69 cd ~/.cpanm/latest-build/DBI-*/
70 perl -p -i -e 's/(create_.+?_tests) => 1/$1 => 0/' Makefile.PL
71 run_or_err "Pre-installing DBI, but running less tests" "perl Makefile.PL && make && make test && make install"
72 cd - &>/dev/null
73
74else
75 # we will be running all dbic tests - preinstall lots of stuff, run basic tests
76 # using SQLT and set up whatever databases necessary
77 export DBICTEST_SQLT_DEPLOY=1
78
79 # do the preinstall in several passes to minimize amount of cross-deps installing
80 # multiple times, and to avoid module re-architecture breaking another install
91d48c58 81 # (e.g. once Carp is upgraded there's no more Carp::Heavy,
82 # while a File::Path upgrade may cause a parallel EUMM run to fail)
b58ecb01 83 #
2b885e5f 84 parallel_installdeps_notest ExtUtils::MakeMaker
91d48c58 85 parallel_installdeps_notest File::Path
b58ecb01 86 parallel_installdeps_notest Carp
e1ab2f7a 87 parallel_installdeps_notest Module::Build Module::Runtime
88 parallel_installdeps_notest File::Spec Data::Dumper
655d80dd 89 parallel_installdeps_notest Test::Exception Encode::Locale Test::Fatal R/RS/RSAVAGE/Tree-DAG_Node-1.13.tgz
e1ab2f7a 90 parallel_installdeps_notest Test::Warn B::Hooks::EndOfScope Test::Differences HTTP::Status
f5616614 91 parallel_installdeps_notest Test::Pod::Coverage Test::EOL Devel::GlobalDestruction Sub::Name MRO::Compat Class::XSAccessor URI::Escape HTML::Entities
2cf93a3d 92 parallel_installdeps_notest YAML LWP Class::Trigger JSON::XS DBI DateTime::Format::Builder Class::Accessor::Grouped Package::Variant
37ab4b67 93 parallel_installdeps_notest Moose Module::Install JSON SQL::Translator File::Which
b58ecb01 94
f5616614 95 if [[ -n "DBICTEST_FIREBIRD_DSN" ]] ; then
b58ecb01 96 # the official version is very much outdated and does not compile on 5.14+
97 # use this rather updated source tree (needs to go to PAUSE):
98 # https://github.com/pilcrow/perl-dbd-interbase
99 run_or_err "Fetching patched DBD::InterBase" \
100 "git clone https://github.com/dbsrgits/perl-dbd-interbase ~/dbd-interbase"
101
37ab4b67 102 parallel_installdeps_notest ~/dbd-interbase/
b58ecb01 103 fi
104
105fi
106
107# generate the makefile which will have different deps depending on
108# the runmode and envvars set above
109run_or_err "Configure on current branch" "perl Makefile.PL"
110
111# install (remaining) dependencies, sometimes with a gentle push
112if [[ "$CLEANTEST" = "true" ]]; then
113 # we may need to prepend some stuff to that list
114 HARD_DEPS="$(echo $(make listdeps))"
115
4e338f1b 116##### TEMPORARY WORKAROUNDS
f207111d 117 if ! CPAN_is_sane ; then
118 # combat dzillirium on harness-wide level, otherwise breakage happens weekly
119 echo_err "$(tstamp) Ancient CPAN.pm: engaging TAP::Harness::IgnoreNonessentialDzilAutogeneratedTests during dep install"
120 perl -MTAP::Harness=3.18 -e1 &>/dev/null || run_or_err "Upgrading TAP::Harness for HARNESS_SUBCLASS support" "cpan TAP::Harness"
121 export PERL5LIB="$(pwd)/maint/travis-ci_scripts/lib:$PERL5LIB"
122 export HARNESS_SUBCLASS="TAP::Harness::IgnoreNonessentialDzilAutogeneratedTests"
123 # sanity check, T::H does not report sensible errors when the subclass fails to load
124 perl -MTAP::Harness::IgnoreNonessentialDzilAutogeneratedTests -e1
125
126 # FIXME
127 # parent is temporary due to Carp https://rt.cpan.org/Ticket/Display.html?id=88494
128 HARD_DEPS="parent $HARD_DEPS"
129
130 if CPAN_supports_BUILDPL ; then
131 # We will invoke a posibly MBT based BUILD-file, but we do not support
132 # configure requires. So we not only need to install MBT but its prereqs
133 # FIXME This is madness
134 HARD_DEPS="$(extract_prereqs Module::Build::Tiny) Module::Build::Tiny $HARD_DEPS"
135 else
136 # FIXME
137 # work around Params::Validate not having a Makefile.PL so really old
138 # toolchains can not figure out what the prereqs are ;(
139 # Need to do more research before filing a bug requesting Makefile inclusion
140 HARD_DEPS="$(extract_prereqs Params::Validate) $HARD_DEPS"
141 fi
142 fi
143##### END TEMPORARY WORKAROUNDS
4e338f1b 144
f207111d 145 run_or_err "Installing/testing dependencies (may take up to 5 minutes): $HARD_DEPS" "cpan $HARD_DEPS"
b58ecb01 146
f207111d 147 # save the log as we may need it
148 INSTALLDEPS_OUT="$LASTOUT"
b58ecb01 149
f207111d 150### FIXME in case we set it earlier in a workaround
151 if [[ -n "$HARNESS_SUBCLASS" ]] ; then
b58ecb01 152
f207111d 153 INSTALLDEPS_SKIPPED_TESTLIST=$(perl -0777 -e '
154my $in = <>;
155my $re = qr(
156 ^ (?: \QBuilding and testing\E | \s* CPAN\.pm: .+? (?i:build)\S* ) \s+ (\S+)
157 .*?
158 ^ === \s \QSkipping nonessential autogenerated tests: \E([^\n]+)
159)msx;
160while ( $in =~ /$re/g ) {
161 print "!!! Skipped nonessential tests while installing $1: $2\n"
162}
163' <<< "$LASTOUT")
b58ecb01 164
f207111d 165 unset HARNESS_SUBCLASS
166 fi
992a24f6 167
f207111d 168else
992a24f6 169 if [[ -n "$TEST_BUILDER_BETA_CPAN_TARBALL" ]] ; then
170 parallel_installdeps_notest $TEST_BUILDER_BETA_CPAN_TARBALL
171 fi
f207111d 172
173 # listalldeps is deliberate - will upgrade everything it can find
174 parallel_installdeps_notest $(make listalldeps)
b58ecb01 175fi
176
f207111d 177echo_err "$(tstamp) Dependency installation finished"
b58ecb01 178# this will display list of available versions
179perl Makefile.PL
180
181# make sure we got everything we need
182if [[ -n "$(make listdeps)" ]] ; then
183 echo_err "$(tstamp) Not all deps installed - something went wrong :("
184 sleep 1 # without this the echo below confuses the console listener >.<
185 CPAN_is_sane || echo_err -e "Outdated CPAN.pm used - full logs follows\n$INSTALLDEPS_OUT\n\nSearch for 'NOT OK' in the text above\n\nDeps still missing:"
186 sleep 3 # without this the above echo confuses the console listener >.<
187 make listdeps
188 exit 1
189fi
190
191# announce what are we running
192echo_err "
193===================== DEPENDENCY CONFIGURATION COMPLETE =====================
194$(tstamp) Configuration phase seems to have taken $(date -ud "@$SECONDS" '+%H:%M:%S') (@$SECONDS)
195
196= CPUinfo
197$(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
198
199= Meminfo
200$(free -m -t)
201
202= Environment
203$(env | grep -P 'TEST|TRAVIS|PERL|DBIC' | LC_ALL=C sort | cat -v)
204
205= Perl in use
206$(perl -V)
207============================================================================="