Clarify travis timings
[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 if [[ "$CLEANTEST" = "true" ]]; then
7   # get the last inc/ off cpan - we will get rid of MI
8   # soon enough, but till then this will do
9   # the point is to have a *really* clean perl (the ones
10   # we build are guaranteed to be clean, without side
11   # effects from travis preinstalls)
12
13   # trick cpanm into executing true as shell - we just need the find+unpack
14   run_or_err "Downloading DBIC inc/ from CPAN" \
15     "SHELL=/bin/true cpanm --look DBIx::Class"
16
17   mv ~/.cpanm/latest-build/DBIx-Class-*/inc .
18
19   # older perls do not have a CPAN which understands configure_requires
20   # properly and what is worse a `cpan Foo` run exits with 0 even if some
21   # modules failed to install
22   # The first CPAN which is somewhat sane is around 1.94_56 (perl 5.12)
23   # The problem is that the first sane version also brings a *lot* of
24   # deps with it, notably things like YAML and HTTP::Tiny
25   # The goal of CLEANTEST is to have as little extra stuff installed as
26   # possible, mainly to catch "but X is perl core" mistakes
27   # So instead we still use our stock (possibly old) CPAN, and add some
28   # handholding
29   CPAN_is_sane || \
30     run_or_err "Pre-installing ExtUtils::MakeMaker and Module::Build" \
31       "cpan ExtUtils::MakeMaker Module::Build"
32
33   if ! perl -MModule::Build -e 1 &> /dev/null ; then
34     echo_err -e "Module::Build installation failed\n$LASTOUT"
35     exit 1
36   fi
37
38   # DBI has by far the longest test runtime - run less tests
39   # FIXME horrible horrible hack, need to implement in DBI itself
40   run_or_err "Downloading latest DBI distdir from CPAN" \
41     "SHELL=/bin/true cpanm --look DBI"
42   cd ~/.cpanm/latest-build/DBI-*/
43   perl -p -i -e 's/(create_.+?_tests) => 1/$1 => 0/' Makefile.PL
44   run_or_err "Pre-installing DBI, but running less tests" "perl Makefile.PL && make && make test && make install"
45   cd - &>/dev/null
46
47 else
48   # we will be running all dbic tests - preinstall lots of stuff, run basic tests
49   # using SQLT and set up whatever databases necessary
50   export DBICTEST_SQLT_DEPLOY=1
51
52   # do the preinstall in several passes to minimize amount of cross-deps installing
53   # multiple times, and to avoid module re-architecture breaking another install
54   # (e.g. once Carp is upgraded there's no more Carp::Heavy)
55   #
56   parallel_installdeps_notest ExtUtils::MakeMaker
57   parallel_installdeps_notest Carp
58   parallel_installdeps_notest Module::Build
59   parallel_installdeps_notest Module::Runtime ExtUtils::Depends File::Spec Data::Dumper
60   parallel_installdeps_notest Test::Exception LWP
61   parallel_installdeps_notest Test::Fatal Test::Warn bareword::filehandles
62   parallel_installdeps_notest namespace::clean Class::XSAccessor MRO::Compat
63   parallel_installdeps_notest DBD::SQLite Moo Class::Accessor::Grouped
64   parallel_installdeps_notest Module::Install DateTime::Format::Strptime
65   parallel_installdeps_notest JSON::DWIW JSON JSON::XS Test::Pod::Coverage Test::EOL
66   parallel_installdeps_notest MooseX::Types JSON::Any Class::DBI
67
68   if [[ -n "DBICTEST_FIREBIRD_DSN" ]] ; then 
69     # the official version is full of 5.10-isms, but works perfectly fine on 5.8
70     # pull in our patched copy
71     run_or_err "Fetching patched DBD::Firebird" \
72       "git clone https://github.com/dbsrgits/perl-dbd-firebird-5.8.git ~/dbd-firebird"
73
74     # the official version is very much outdated and does not compile on 5.14+
75     # use this rather updated source tree (needs to go to PAUSE):
76     # https://github.com/pilcrow/perl-dbd-interbase
77     run_or_err "Fetching patched DBD::InterBase" \
78       "git clone https://github.com/dbsrgits/perl-dbd-interbase ~/dbd-interbase"
79
80     parallel_installdeps_notest ~/dbd-interbase/ ~/dbd-firebird/
81   fi
82
83 fi
84
85 # generate the makefile which will have different deps depending on
86 # the runmode and envvars set above
87 run_or_err "Configure on current branch" "perl Makefile.PL"
88
89 # install (remaining) dependencies, sometimes with a gentle push
90 if [[ "$CLEANTEST" = "true" ]]; then
91   # we may need to prepend some stuff to that list
92   HARD_DEPS="$(echo $(make listdeps))"
93
94   # this is a fucked CPAN - won't understand configure_requires of
95   # various pieces we may run into
96   CPAN_is_sane || HARD_DEPS="ExtUtils::Depends B::Hooks::OP::Check $HARD_DEPS"
97
98 ##### TEMPORARY WORKAROUNDS
99
100   # not sure what's going on here yet
101   perl -M5.008008 -e 1 &> /dev/null || \
102     parallel_installdeps_notest multidimensional bareword::filehandles
103
104   # work around Params::Validate not having a Makefile.PL so really old
105   # toolchains can not figure out what the prereqs are ;(
106   # Need to do more research before filing a bug requesting Makefile inclusion
107   perl -M5.008008 -e 1 &> /dev/null || \
108     HARD_DEPS="$(extract_prereqs Params::Validate) $HARD_DEPS"
109
110 ##### END TEMPORARY WORKAROUNDS
111
112   run_or_err "Installing/testing dependencies (may take up to 3 minutes): $HARD_DEPS" "cpan $HARD_DEPS"
113
114   # this is a fucked CPAN - save the log as we may need it
115   CPAN_is_sane || INSTALLDEPS_OUT="$LASTOUT"
116
117 else
118   # listalldeps is deliberate - will upgrade everything it can find
119   parallel_installdeps_notest $(make listalldeps)
120 fi
121
122 echo_err "$(tstamp) Dependency configuration finished"
123 # this will display list of available versions
124 perl Makefile.PL
125
126 # make sure we got everything we need
127 if [[ -n "$(make listdeps)" ]] ; then
128   echo_err "$(tstamp) Not all deps installed - something went wrong :("
129   sleep 1 # without this the echo below confuses the console listener >.<
130   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:"
131   sleep 3 # without this the above echo confuses the console listener >.<
132   make listdeps
133   exit 1
134 fi
135
136 # announce what are we running
137 echo_err "
138 ===================== DEPENDENCY CONFIGURATION COMPLETE =====================
139 $(tstamp) Configuration phase seems to have taken $(date -ud "@$SECONDS" '+%H:%M:%S') (@$SECONDS)
140
141 = CPUinfo
142 $(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
143
144 = Meminfo
145 $(free -m -t)
146
147 = Environment
148 $(env | grep -P 'TEST|TRAVIS|PERL|DBIC' | LC_ALL=C sort | cat -v)
149
150 = Perl in use
151 $(perl -V)
152 ============================================================================="