Only smoke blead-pan on allowed-to-fail runs
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 30_before_script.bash
1 #!/bin/bash
2
3 source maint/travis-ci_scripts/common.bash
4 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
5
6 # poison the environment - basically look through lib, find all mentioned
7 # ENVvars and set them to true and see if anything explodes
8 if [[ "$POISON_ENV" = "true" ]] ; then
9   for var in $(grep -P '\$ENV\{' -r lib/ | grep -oP 'DBIC_\w+' | sort -u | grep -v DBIC_TRACE) ; do
10     export $var=1
11   done
12
13   export DBI_DSN="dbi:ODBC:server=NonexistentServerAddress"
14   export DBI_DRIVER="ADO"
15
16   export DBICTEST_SQLITE_REVERSE_DEFAULT_ORDER=1
17 fi
18
19 if [[ "$CLEANTEST" = "true" ]]; then
20   # get the last inc/ off cpan - we will get rid of MI
21   # soon enough, but till then this will do
22   # the point is to have a *really* clean perl (the ones
23   # we build are guaranteed to be clean, without side
24   # effects from travis preinstalls)
25
26   # trick cpanm into executing true as shell - we just need the find+unpack
27   run_or_err "Downloading DBIC inc/ from CPAN" \
28     "SHELL=/bin/true cpanm --look DBIx::Class"
29
30   mv ~/.cpanm/latest-build/DBIx-Class-*/inc .
31
32   # older perls do not have a CPAN which understands configure_requires
33   # properly and what is worse a `cpan Foo` run exits with 0 even if some
34   # modules failed to install
35   # The first CPAN which is somewhat sane is around 1.94_56 (perl 5.12)
36   # The problem is that the first sane version also brings a *lot* of
37   # deps with it, notably things like YAML and HTTP::Tiny
38   # The goal of CLEANTEST is to have as little extra stuff installed as
39   # possible, mainly to catch "but X is perl core" mistakes
40   # So instead we still use our stock (possibly old) CPAN, and add some
41   # handholding
42   if ! CPAN_is_sane ; then
43     for m in B/BI/BINGOS/ExtUtils-MakeMaker-6.72.tar.gz ExtUtils::CBuilder Module::Build ; do
44       run_or_err "Pre-installing $m" "cpan $m"
45     done
46   fi
47
48   if ! perl -MModule::Build -e 1 &> /dev/null ; then
49     echo_err -e "Module::Build installation failed\n$LASTOUT"
50     exit 1
51   fi
52
53   # DBI has by far the longest test runtime - run less tests
54   # FIXME horrible horrible hack, need to implement in DBI itself
55   run_or_err "Downloading latest DBI distdir from CPAN" \
56     "SHELL=/bin/true cpanm --look DBI"
57   cd ~/.cpanm/latest-build/DBI-*/
58   perl -p -i -e 's/(create_.+?_tests) => 1/$1 => 0/' Makefile.PL
59   run_or_err "Pre-installing DBI, but running less tests" "perl Makefile.PL && make && make test && make install"
60   cd - &>/dev/null
61
62 else
63   # we will be running all dbic tests - preinstall lots of stuff, run basic tests
64   # using SQLT and set up whatever databases necessary
65   export DBICTEST_SQLT_DEPLOY=1
66
67   # do the preinstall in several passes to minimize amount of cross-deps installing
68   # multiple times, and to avoid module re-architecture breaking another install
69   # (e.g. once Carp is upgraded there's no more Carp::Heavy,
70   # while a File::Path upgrade may cause a parallel EUMM run to fail)
71   #
72   parallel_installdeps_notest B/BI/BINGOS/ExtUtils-MakeMaker-6.72.tar.gz
73   parallel_installdeps_notest File::Path
74   parallel_installdeps_notest Carp
75   parallel_installdeps_notest Module::Build ExtUtils::Depends
76   parallel_installdeps_notest Module::Runtime File::Spec Data::Dumper
77   parallel_installdeps_notest Test::Exception Encode::Locale Test::Fatal
78   parallel_installdeps_notest Test::Warn bareword::filehandles B::Hooks::EndOfScope Test::Differences HTTP::Status
79   parallel_installdeps_notest Test::Pod::Coverage Test::EOL Devel::GlobalDestruction Sub::Name MRO::Compat Class::XSAccessor URI::Escape HTML::Entities
80   parallel_installdeps_notest YAML LWP Class::Trigger JSON::XS DBI DateTime::Format::Builder Class::Accessor::Grouped Package::Variant
81   parallel_installdeps_notest Moose Module::Install JSON SQL::Translator
82
83   if [[ -n "DBICTEST_FIREBIRD_DSN" ]] ; then
84     # pull in patched unreleased copy with restored 5.8 compat
85     run_or_err "Fetching patched DBD::Firebird" \
86       "git clone https://github.com/mariuz/perl-dbd-firebird ~/dbd-firebird"
87
88     # the official version is very much outdated and does not compile on 5.14+
89     # use this rather updated source tree (needs to go to PAUSE):
90     # https://github.com/pilcrow/perl-dbd-interbase
91     run_or_err "Fetching patched DBD::InterBase" \
92       "git clone https://github.com/dbsrgits/perl-dbd-interbase ~/dbd-interbase"
93
94     # Now part of DBD::Firebird configure_requires, which are not present
95     # in the cloned repo (no META.*)
96     # FIXME - need to get this off metacpan or something instead
97     parallel_installdeps_notest File::Which
98
99     parallel_installdeps_notest ~/dbd-interbase/ ~/dbd-firebird/
100   fi
101
102 fi
103
104 # generate the makefile which will have different deps depending on
105 # the runmode and envvars set above
106 run_or_err "Configure on current branch" "perl Makefile.PL"
107
108 # install (remaining) dependencies, sometimes with a gentle push
109 if [[ "$CLEANTEST" = "true" ]]; then
110   # we may need to prepend some stuff to that list
111   HARD_DEPS="$(echo $(make listdeps))"
112
113
114 ##### TEMPORARY WORKAROUNDS
115
116   # this is a fucked CPAN - won't understand configure_requires of
117   # various pieces we may run into
118   # FIXME - need to get these off metacpan or something instead
119   CPAN_is_sane || HARD_DEPS="ExtUtils::Depends B::Hooks::OP::Check $HARD_DEPS"
120
121   # The unicode-in-yaml bug on older cpan clients
122   # FIXME there got to be a saner way to fix this...
123   perl -M5.008008 -e 1 &> /dev/null || \
124      run_or_err "Installing multidimensional and bareword::filehandles via cpanm" \
125         "cpanm multidimensional bareword::filehandles"
126
127   # work around Params::Validate not having a Makefile.PL so really old
128   # toolchains can not figure out what the prereqs are ;(
129   # Need to do more research before filing a bug requesting Makefile inclusion
130   perl -M5.008008 -e 1 &> /dev/null || \
131     HARD_DEPS="$(extract_prereqs Params::Validate) $HARD_DEPS"
132
133 ##### END TEMPORARY WORKAROUNDS
134
135   run_or_err "Installing/testing dependencies (may take up to 3 minutes): $HARD_DEPS" "cpan $HARD_DEPS"
136
137   # this is a fucked CPAN - save the log as we may need it
138   CPAN_is_sane || INSTALLDEPS_OUT="$LASTOUT"
139
140 else
141   # listalldeps is deliberate - will upgrade everything it can find
142   parallel_installdeps_notest $(make listalldeps)
143
144   if [[ -n "$TEST_BUILDER_BETA_CPAN_TARBALL" ]] ; then
145     parallel_installdeps_notest $TEST_BUILDER_BETA_CPAN_TARBALL
146   fi
147 fi
148
149 echo_err "$(tstamp) Dependency configuration finished"
150 # this will display list of available versions
151 perl Makefile.PL
152
153 # make sure we got everything we need
154 if [[ -n "$(make listdeps)" ]] ; then
155   echo_err "$(tstamp) Not all deps installed - something went wrong :("
156   sleep 1 # without this the echo below confuses the console listener >.<
157   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:"
158   sleep 3 # without this the above echo confuses the console listener >.<
159   make listdeps
160   exit 1
161 fi
162
163 # announce what are we running
164 echo_err "
165 ===================== DEPENDENCY CONFIGURATION COMPLETE =====================
166 $(tstamp) Configuration phase seems to have taken $(date -ud "@$SECONDS" '+%H:%M:%S') (@$SECONDS)
167
168 = CPUinfo
169 $(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
170
171 = Meminfo
172 $(free -m -t)
173
174 = Environment
175 $(env | grep -P 'TEST|TRAVIS|PERL|DBIC' | LC_ALL=C sort | cat -v)
176
177 = Perl in use
178 $(perl -V)
179 ============================================================================="