24e405a8f1602c603b67f668745241d17d59c8f7
[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 # try Schwern's latest offering on a stock perl and a threaded blead
7 # can't do this with CLEANTEST=true yet because a lot of our deps fail
8 # tests left and right under T::B 1.5
9 if [[ "$CLEANTEST" != "true" ]] && ( [[ -z "$BREWVER" ]] || [[ "$BREWVER" = "blead" ]] ) ; then
10   # FIXME - there got to be a way to ask metacpan for this dynamically
11   TEST_BUILDER_BETA_CPAN_TARBALL="M/MS/MSCHWERN/Test-Simple-1.005000_005.tar.gz"
12 fi
13
14
15 if [[ "$CLEANTEST" = "true" ]]; then
16   # get the last inc/ off cpan - we will get rid of MI
17   # soon enough, but till then this will do
18   # the point is to have a *really* clean perl (the ones
19   # we build are guaranteed to be clean, without side
20   # effects from travis preinstalls)
21
22   # trick cpanm into executing true as shell - we just need the find+unpack
23   run_or_err "Downloading DBIC inc/ from CPAN" \
24     "SHELL=/bin/true cpanm --look DBIx::Class"
25
26   mv ~/.cpanm/latest-build/DBIx-Class-*/inc .
27
28   # this should be installable anywhere, regardles of prereqs
29   if [[ -n "$TEST_BUILDER_BETA_CPAN_TARBALL" ]] ; then
30     run_or_err "Pre-installing dev-beta of Test::Builder ($TEST_BUILDER_BETA_CPAN_TARBALL)" \
31       "cpan $TEST_BUILDER_BETA_CPAN_TARBALL"
32   fi
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
44   CPAN_is_sane || \
45     run_or_err "Pre-installing ExtUtils::MakeMaker and Module::Build" \
46       "cpan ExtUtils::MakeMaker Module::Build"
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   #
71   parallel_installdeps_notest ExtUtils::MakeMaker
72   parallel_installdeps_notest Carp
73   parallel_installdeps_notest Module::Build
74   parallel_installdeps_notest Module::Runtime ExtUtils::Depends File::Spec Data::Dumper
75   parallel_installdeps_notest Test::Exception LWP
76   parallel_installdeps_notest Test::Fatal Test::Warn bareword::filehandles
77   parallel_installdeps_notest namespace::clean Class::XSAccessor MRO::Compat
78   parallel_installdeps_notest DBD::SQLite Moo Class::Accessor::Grouped
79   parallel_installdeps_notest Module::Install DateTime::Format::Strptime
80   parallel_installdeps_notest JSON::DWIW JSON JSON::XS Test::Pod::Coverage Test::EOL
81   parallel_installdeps_notest MooseX::Types JSON::Any Class::DBI
82
83   if [[ -n "DBICTEST_FIREBIRD_DSN" ]] ; then 
84     # the official version is full of 5.10-isms, but works perfectly fine on 5.8
85     # pull in our patched copy
86     run_or_err "Fetching patched DBD::Firebird" \
87       "git clone https://github.com/dbsrgits/perl-dbd-firebird-5.8.git ~/dbd-firebird"
88
89     # the official version is very much outdated and does not compile on 5.14+
90     # use this rather updated source tree (needs to go to PAUSE):
91     # https://github.com/pilcrow/perl-dbd-interbase
92     run_or_err "Fetching patched DBD::InterBase" \
93       "git clone https://github.com/dbsrgits/perl-dbd-interbase ~/dbd-interbase"
94
95     parallel_installdeps_notest ~/dbd-interbase/ ~/dbd-firebird/
96   fi
97
98 fi
99
100 # generate the makefile which will have different deps depending on
101 # the runmode and envvars set above
102 run_or_err "Configure on current branch" "perl Makefile.PL"
103
104 # install (remaining) dependencies, sometimes with a gentle push
105 if [[ "$CLEANTEST" = "true" ]]; then
106   # we may need to prepend some stuff to that list
107   HARD_DEPS="$(echo $(make listdeps))"
108
109   # this is a fucked CPAN - won't understand configure_requires of
110   # various pieces we may run into
111   CPAN_is_sane || HARD_DEPS="ExtUtils::Depends B::Hooks::OP::Check $HARD_DEPS"
112
113 ##### TEMPORARY WORKAROUNDS
114
115   # The unicode-in-yaml bug on older cpan clients
116   # FIXME there got to be a saner way to fix this...
117   perl -M5.008008 -e 1 &> /dev/null || \
118      run_or_err "Installing multidimensional and bareword::filehandles via cpanm" \
119         "cpanm multidimensional bareword::filehandles"
120
121   # work around Params::Validate not having a Makefile.PL so really old
122   # toolchains can not figure out what the prereqs are ;(
123   # Need to do more research before filing a bug requesting Makefile inclusion
124   perl -M5.008008 -e 1 &> /dev/null || \
125     HARD_DEPS="$(extract_prereqs Params::Validate) $HARD_DEPS"
126
127 ##### END TEMPORARY WORKAROUNDS
128
129   run_or_err "Installing/testing dependencies (may take up to 3 minutes): $HARD_DEPS" "cpan $HARD_DEPS"
130
131   # this is a fucked CPAN - save the log as we may need it
132   CPAN_is_sane || INSTALLDEPS_OUT="$LASTOUT"
133
134 else
135   # listalldeps is deliberate - will upgrade everything it can find
136   parallel_installdeps_notest $(make listalldeps)
137
138   if [[ -n "$TEST_BUILDER_BETA_CPAN_TARBALL" ]] ; then
139     parallel_installdeps_notest $TEST_BUILDER_BETA_CPAN_TARBALL
140   fi
141 fi
142
143 echo_err "$(tstamp) Dependency configuration finished"
144 # this will display list of available versions
145 perl Makefile.PL
146
147 # make sure we got everything we need
148 if [[ -n "$(make listdeps)" ]] ; then
149   echo_err "$(tstamp) Not all deps installed - something went wrong :("
150   sleep 1 # without this the echo below confuses the console listener >.<
151   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:"
152   sleep 3 # without this the above echo confuses the console listener >.<
153   make listdeps
154   exit 1
155 fi
156
157 # announce what are we running
158 echo_err "
159 ===================== DEPENDENCY CONFIGURATION COMPLETE =====================
160 $(tstamp) Configuration phase seems to have taken $(date -ud "@$SECONDS" '+%H:%M:%S') (@$SECONDS)
161
162 = CPUinfo
163 $(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
164
165 = Meminfo
166 $(free -m -t)
167
168 = Environment
169 $(env | grep -P 'TEST|TRAVIS|PERL|DBIC' | LC_ALL=C sort | cat -v)
170
171 = Perl in use
172 $(perl -V)
173 ============================================================================="