Move generated POD to its own dir
[dbsrgits/DBIx-Class.git] / maint / travis-ci_prepare_env
CommitLineData
d70070c9 1#!/bin/bash
2
3# * The way .travis.yml is fed to the command controller is idiotic - it
4# makes using multiline `bash -c` statements impossible. Therefore to
5# aid readability (our travis logic is rather complex), the bulk of
6# functionality is moved to a script. More about the problem here:
7# https://github.com/travis-ci/travis-ci/issues/497
8
9set -e
10
11if [[ "$TRAVIS" != "true" ]] ; then
12 echo "Running this script makes no sense outside of travis-ci"
13 exit 1
14fi
15
16#
17# Current dir is the root of the DBIC checkout (make sure to
18# come back there if moving around before end of this script)
19#
20# envvars available for us:
21#
22# NUMTHREADS = { number}
23# dynamically determined amount of threads we want to run on this
24# smoker concurrently
25#
26# CLEANTEST = [ true | false ]
27# controls whether we simulate a "user-side" install experience
28# that is - no author deps and no M::I installation
29#
30# BREWVER = { tripple dotted perl version, e.g. 5.8.3 }
31# brew a custom perl version such and such
32#
33# BREWOPTS = { string to be fed unquoted to perlbrew, e.g. -Duseithreads }
34# build options for perlbrew
35#
36
37if [[ -n "$BREWVER" ]] ; then
c299fd65 38 # if this is not master and not a smoke/ branch - cancel all testing
39 if [[ "$TRAVIS_BRANCH" =~ "topic/" ]]; then
40 export SHORT_CIRCUIT_SMOKE=1
e8e2b3bf 41 sleep 20 # give the console time to attach, otherwise it hangs
c299fd65 42 return # this is like an `exit 0` in sourcing
43 fi
44
d70070c9 45 perlbrew install --as $BREWVER --notest $BREWOPTS -j $NUMTHREADS perl-$BREWVER
46 perlbrew use $BREWVER
47fi
48
49export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1
c299fd65 50export PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )"
d70070c9 51
e8e2b3bf 52installdeps() {
53 if [[ -z "$@" ]] ; then return; fi
54
55 # The reason we do things so "non-interactively" is that xargs -P will have the
56 # latest cpanm instance overwrite the buildlog. There seems to be no way to
57 # specify a custom buildlog, hence we just collect the verbose output
58 # and display it in case of failure
59 echo -n "Installing $@... "
60 if ! OUT=$( echo "$@" | xargs -n 1 -P $NUMTHREADS cpanm --verbose --no-interactive --notest --no-man-pages 2>&1 ) ; then
61 EX=$?
62 echo "FAILED !!!"
63 echo "$OUT"
64 exit $?
65 else
66 echo "done."
67 fi
68}
69
70# Install *hard dep* modules that typically appear in more than one dep
71#
72# *NEVER* add optional depenencies here - will make CLEANTEST=true smokes useless
73#
74# do it in several passes to minimize amount of cross-deps installing multiple
75# times, and to avoid module re-architecture breaking another install
76# (e.g. once Carp is upgraded there's no more Carp::Heavy)
77#
78installdeps $(cpanm --notest --quiet --showdeps Module::Build)
79installdeps Test::Exception Test::Fatal Module::Runtime Carp
80installdeps Sub::Name multidimensional namespace::clean Class::XSAccessor MRO::Compat
81installdeps DBI Moo Class::Accessor::Grouped
82
d70070c9 83# configure CPAN.pm - older versions get tickled by M::AI and
84# go into an endless loop when trying to autoconf themselves
e8e2b3bf 85# we are not *supposed* to actually use it, this is just a
86# precaution
d70070c9 87perl -e '
88 require CPAN;
89 require CPAN::FirstTime;
90 *CPAN::FirstTime::conf_sites = sub {};
91 CPAN::Config->load;
92 $CPAN::Config->{urllist} = [ "http://cpan.cpantesters.org/" ];
93 CPAN::Config->commit;
94' &> /dev/null
95
e8e2b3bf 96if [[ "$CLEANTEST" = "true" ]]; then
97 # get the last inc/ off cpan - we will get rid of MI
98 # soon enough, but till then this will do
99 # the point is to have a *really* clean perl (the ones
100 # we build are guaranteed to be clean, without side
101 # effects from travis preinstalls)
e352dd9a 102
103 # trick cpanm into executing true as shell - we just need the find+unpack
104 SHELL=/bin/true cpanm --look DBIx::Class
105 mv ~/.cpanm/latest-build/*/inc .
e8e2b3bf 106else
107 # we will be running all tests - preinstall MOAR stuff, run basic tests using SQLT
108 # and set up whatever databases necessary
109 installdeps Module::Install DateTime::Format::Strptime MooseX::Types JSON::Any Class::DBI
110
111 export DBICTEST_SQLT_DEPLOY=1
112
2b28f530 113### apt-get invocation - faster to grab everything at once
114 #
115 # FIXME these debconf lines should automate the firebird config but do not :(((
116 sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/enabled\tboolean\ttrue" | debconf-set-selections'
117 sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/sysdba_password/new_password\tpassword\t123" | debconf-set-selections'
118
119 sudo apt-get install -y memcached firebird2.5-super firebird2.5-dev expect
d70070c9 120
2b28f530 121### memcached
d70070c9 122 export DBICTEST_MEMCACHED=127.0.0.1:11211
123
2b28f530 124### mysql
d70070c9 125 mysql -e 'create database dbic_test;'
126 export DBICTEST_MYSQL_DSN='dbi:mysql:database=dbic_test;host=127.0.0.1'
127 export DBICTEST_MYSQL_USER=root
128
2b28f530 129### pg
d70070c9 130 psql -c 'create database dbic_test;' -U postgres
131 export DBICTEST_PG_DSN='dbi:Pg:database=dbic_test;host=127.0.0.1'
132 export DBICTEST_PG_USER=postgres
133
2b28f530 134### firebird
135 # poor man's deb config
136 echo -n "Re-configuring firebird... "
137 if ! OUT=$(
138 sync
139 DEBIAN_FRONTEND=text sudo expect -c '
140 spawn dpkg-reconfigure --frontend=text firebird2.5-super
141 expect "Enable Firebird server?"
142 send "\177\177\177\177yes\r"
143 expect "Password for SYSDBA"
144 send "123\r"
145 sleep 1
146 wait
147 sleep 1
148 '
47d391d5 149 sync
2b28f530 150 # restart the server for good measure
151 sudo /etc/init.d/firebird2.5-super stop || true
47d391d5 152 sleep 3
2b28f530 153 sudo /etc/init.d/firebird2.5-super start
154 ) ; then
155 EX=$?
156 echo "FAILED !!!"
157 echo "$OUT"
158 exit $?
159 else
160 echo "done."
161 fi
162
163 # creating testdb
164 sudo isql-fb -u sysdba -p 123 <<< "CREATE DATABASE '/var/lib/firebird/2.5/data/dbic_test.fdb';"
165
166 # the official version is full of 5.10-isms, but works perfectly fine on 5.8
167 # pull in our patched copy
168 git clone https://github.com/dbsrgits/perl-dbd-firebird-5.8.git ~/dbd-firebird
169
170 # the official version is very much outdated and does not compile on 5.14+
171 # use this rather updated source tree (needs to go to PAUSE):
172 # https://github.com/pilcrow/perl-dbd-interbase
173 git clone https://github.com/dbsrgits/perl-dbd-interbase ~/dbd-interbase
174
175 installdeps ~/dbd-interbase/ ~/dbd-firebird/
176
177 export DBICTEST_FIREBIRD_DSN=dbi:Firebird:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
178 export DBICTEST_FIREBIRD_USER=SYSDBA
179 export DBICTEST_FIREBIRD_PASS=123
180
181 export DBICTEST_FIREBIRD_INTERBASE_DSN=dbi:InterBase:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
182 export DBICTEST_FIREBIRD_INTERBASE_USER=SYSDBA
183 export DBICTEST_FIREBIRD_INTERBASE_PASS=123
184
185### oracle
d70070c9 186 # FIXME: todo
187 #DBICTEST_ORA_DSN=dbi:Oracle:host=localhost;sid=XE
188 #DBICTEST_ORA_USER=dbic_test
189 #DBICTEST_ORA_PASS=123
190 #DBICTEST_ORA_EXTRAUSER_DSN=dbi:Oracle:host=localhost;sid=XE
191 #DBICTEST_ORA_EXTRAUSER_USER=dbic_test_extra
192 #DBICTEST_ORA_EXTRAUSER_PASS=123
193 #ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client
194fi
195
e352dd9a 196# install the remaining dependencies
d70070c9 197perl Makefile.PL
198installdeps $(make listalldeps)
199
d70070c9 200# announce what are we running
201perl -V
202echo "Using $NUMTHREADS Travis-CI concurrent processes"
203
204# make sure we got everything we need
205perl Makefile.PL &> /dev/null
206if [[ -n "$(make listdeps)" ]] ; then
207 echo "Not all deps installed - something went wrong :("
208 make listdeps
209 exit 1
210fi