More extensive travis testing plan
[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
38 perlbrew install --as $BREWVER --notest $BREWOPTS -j $NUMTHREADS perl-$BREWVER
39 perlbrew use $BREWVER
40fi
41
42export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1
43
44# configure CPAN.pm - older versions get tickled by M::AI and
45# go into an endless loop when trying to autoconf themselves
46perl -e '
47 require CPAN;
48 require CPAN::FirstTime;
49 *CPAN::FirstTime::conf_sites = sub {};
50 CPAN::Config->load;
51 $CPAN::Config->{urllist} = [ "http://cpan.cpantesters.org/" ];
52 CPAN::Config->commit;
53' &> /dev/null
54
55# if this won't be a CLEANTEST (i.e. no deps) - run basic tests using SQLT
56# and set up whatever databases necessary
57if [[ "$CLEANTEST" != "true" ]]; then
58 # extra debian stuff
59 sudo apt-get -y install memcached firebird2.5-super
60 echo -e '\v'
61 echo
62
63 export DBICTEST_SQLT_DEPLOY=1
64
65 # memcached
66 export DBICTEST_MEMCACHED=127.0.0.1:11211
67
68 # mysql
69 mysql -e 'create database dbic_test;'
70 export DBICTEST_MYSQL_DSN='dbi:mysql:database=dbic_test;host=127.0.0.1'
71 export DBICTEST_MYSQL_USER=root
72
73 # pg
74 psql -c 'create database dbic_test;' -U postgres
75 export DBICTEST_PG_DSN='dbi:Pg:database=dbic_test;host=127.0.0.1'
76 export DBICTEST_PG_USER=postgres
77
78 # firebird
79 sudo perl -pi -e 's/\=no/=yes/' /etc/default/firebird2.5
80 sudo /etc/init.d/firebird2.5-super start
81 # FIXME: todo
82 #sudo gsec -add dbic_test -pw 123
83 #export DBICTEST_FIREBIRD_DSN=dbi:Firebird:dbname=/var/lib/firebird/2.5/data/dbic_test
84 #export DBICTEST_FIREBIRD_USER=dbic_test
85 #export DBICTEST_FIREBIRD_PASS=123
86 #export DBICTEST_FIREBIRD_INTERBASE_DSN=dbi:InterBase:dbname=/var/lib/firebird/2.5/data/dbic_test
87 #export DBICTEST_FIREBIRD_INTERBASE_USER=dbic_test
88 #export DBICTEST_FIREBIRD_INTERBASE_PASS=123
89
90 # oracle
91 # FIXME: todo
92 #DBICTEST_ORA_DSN=dbi:Oracle:host=localhost;sid=XE
93 #DBICTEST_ORA_USER=dbic_test
94 #DBICTEST_ORA_PASS=123
95 #DBICTEST_ORA_EXTRAUSER_DSN=dbi:Oracle:host=localhost;sid=XE
96 #DBICTEST_ORA_EXTRAUSER_USER=dbic_test_extra
97 #DBICTEST_ORA_EXTRAUSER_PASS=123
98 #ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client
99fi
100
101installdeps() {
102 if [[ -z "$@" ]] ; then return; fi
103
104 echo -n "Installing $@... "
105 # FIXME
106 # the --reinstall is here because for some reason e.g. `cpanm Carp` does
107 # not install a newer Carp since it already exists on the system
108 # investigation pending
109 if ! OUT=$( echo "$@" | xargs -n 1 -P $NUMTHREADS cpanm --reinstall --verbose --notest 2>&1 ) ; then
110 EX=$?
111 echo "FAILED !!!"
112 echo "$OUT"
113 exit $?
114 else
115 echo "done."
116 fi
117}
118
119# Install *hard dep* modules that typically appear in more than one dep
120#
121# *NEVER* add optional depenencies here - will make CLEANTEST=true smokes useless
122#
123# do it in several passes to minimize amount of cross-deps installing multiple
124# times, and to avoid module re-architecture breaking another install
125# (e.g. once Carp is upgraded there's no more Carp::Heavy)
126#
127installdeps $(cpanm --notest --quiet --showdeps Module::Build)
128installdeps Test::Exception Test::Fatal Module::Runtime Carp
129installdeps Sub::Name multidimensional namespace::clean Class::XSAccessor MRO::Compat
130installdeps DBI Moo Class::Accessor::Grouped
131
132if [[ "$CLEANTEST" = "true" ]]; then
133 # get the last inc/ off cpan - we will get rid of MI
134 # soon enough, but till then this will do
135 # the point is to have a *really* clean perl (the ones
136 # we build are guaranteed to be clean, without side
137 # effects from travis preinstalls)
138 #
139 # FIXME - not yet implemented - not sure how to reliably
140 # feed to wget this location: http://cpansearch.perl.org/src/GETTY/DBIx-Class-0.08204/inc/
141 echo TODOOOO - M::I is not supposed to be installed here - this test is useless now
142 installdeps Module::Install
143else
144 # we will be running all tests, preinstall MOAR stuff
145 installdeps Module::Install DateTime::Format::Strptime MooseX::Types JSON::Any Class::DBI
146fi
147
148# install the rest
149perl Makefile.PL
150installdeps $(make listalldeps)
151
152# FIXME - for some reason the above invocation does not upgrade outdated
153# core libs - just punt and install the remainder by hand (these run tests)
154# This snippet should not be here at all
155perl Makefile.PL &> /dev/null
156make installdeps
157
158# announce what are we running
159perl -V
160echo "Using $NUMTHREADS Travis-CI concurrent processes"
161
162# make sure we got everything we need
163perl Makefile.PL &> /dev/null
164if [[ -n "$(make listdeps)" ]] ; then
165 echo "Not all deps installed - something went wrong :("
166 make listdeps
167 exit 1
168fi