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
11 echo_err() { echo "$@" 1>&2 ; }
13 tstamp() { echo -n "[$(date '+%H:%M:%S')]" ; }
16 echo_err -n "$(tstamp) $1 ... "
18 LASTOUT=$( bash -c "$2" 2>&1)
20 if [[ "$LASTEXIT" != "0" ]] ; then
21 echo_err -e "FAILED !!!\nCommand executed:\n$2\nSTDOUT+STDERR:\n$LASTOUT"
28 if [[ "$TRAVIS" != "true" ]] ; then
29 echo_err "Running this script makes no sense outside of travis-ci"
34 # Current dir is the root of the DBIC checkout (make sure to
35 # come back there if moving around before end of this script)
37 # envvars available for us:
39 # NUMTHREADS = { number}
40 # dynamically determined amount of threads we want to run on this
43 # CLEANTEST = [ true | false ]
44 # controls whether we simulate a "user-side" install experience
45 # that is - no author deps and no M::I installation
47 # BREWVER = { tripple dotted perl version, e.g. 5.8.3 }
48 # brew a custom perl version such and such
50 # BREWOPTS = { string to be fed unquoted to perlbrew, e.g. -Duseithreads }
51 # build options for perlbrew
54 echo_err "$(tstamp) Smoke preconfiguration starting $(date)"
56 TRAVIS_CPAN_MIRROR=$(echo "$PERL_CPANM_OPT" | grep -oP -- '--mirror\s+\S+' | head -n 1 | cut -d ' ' -f 2)
57 if ! [[ "$TRAVIS_CPAN_MIRROR" =~ "http://" ]] ; then
58 echo_err "Unable to extract primary cpan mirror from PERL_CPANM_OPT - something is wrong"
59 echo_err "PERL_CPANM_OPT: $PERL_CPANM_OPT"
63 export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 PERLBREW_CPAN_MIRROR="$TRAVIS_CPAN_MIRROR"
65 # Fixup CPANM_OPT to behave more like a traditional cpan client
66 export PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )"
68 if [[ -n "$BREWVER" ]] ; then
69 # if this is not master and not a smoke/ branch - cancel all testing
70 if [[ "$TRAVIS_BRANCH" =~ "topic/" ]]; then
71 export SHORT_CIRCUIT_SMOKE=1
72 echo_err "$(tstamp) non-smoke branch and custom perl compilation requested - bailing out"
73 sleep 20 # give the console time to attach, otherwise it hangs
74 return # this is like an `exit 0` in sourcing
77 run_or_err "Compiling/installing Perl $BREWVER (without testing, may take up to 5 minutes)" \
78 "perlbrew install --as $BREWVER --notest $BREWOPTS -j $NUMTHREADS perl-$BREWVER"
83 # configure CPAN.pm - older versions go into an endless loop
84 # when trying to autoconf themselves
87 require CPAN::FirstTime;
88 *CPAN::FirstTime::conf_sites = sub {};
90 \$CPAN::Config->{urllist} = [qw{ $TRAVIS_CPAN_MIRROR }];
91 \$CPAN::Config->{halt_on_failure} = 1;
94 run_or_err "Configuring CPAN.pm" "perl -e '$CPAN_CFG_SCRIPT'"
98 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \
101 OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!}
102 ERR=$(grep -v " is up to date." <<< "${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}")
104 [[ -n "$LASTEXIT" ]] || LASTEXIT=0
105 if [[ "$LASTEXIT" != "0" ]] || [[ -n "$ERR" ]] ; then
106 echo_err "$(echo -e "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:\n$ERR\n$OUT")"
110 # throw away non-children (what was in $@), throw away ascii art, convert to modnames
111 perl -p -e 's/^\s*[^\\].+//; s/^[^A-Za-z]+//; s/\-[^\-]+$/ /; s/\-/::/g' <<< "$OUT"
114 parallel_installdeps_notest() {
115 if [[ -z "$@" ]] ; then return; fi
117 # flatten list into one string
120 # The reason we do things so "non-interactively" is that xargs -P will have the
121 # latest cpanm instance overwrite the buildlog. There seems to be no way to
122 # specify a custom buildlog, hence we just collect the verbose output
123 # and display it in case of failure
124 run_or_err "Installing (without testing) $MODLIST" \
125 "echo $MODLIST | xargs -n 1 -P $NUMTHREADS cpanm --verbose --no-interactive --notest --no-man-pages"
128 # Install *hard dep* modules that typically appear in more than one dep
130 # *NEVER* add optional depenencies here - will make CLEANTEST=true smokes useless
132 # do it in several passes to minimize amount of cross-deps installing multiple
133 # times, and to avoid module re-architecture breaking another install
134 # (e.g. once Carp is upgraded there's no more Carp::Heavy)
136 parallel_installdeps_notest $(extract_prereqs Module::Build)
137 parallel_installdeps_notest Test::Exception Test::Fatal Module::Runtime Carp
138 parallel_installdeps_notest Sub::Name multidimensional namespace::clean Class::XSAccessor MRO::Compat
139 parallel_installdeps_notest DBI Moo Class::Accessor::Grouped
141 if [[ "$CLEANTEST" = "true" ]]; then
142 # get the last inc/ off cpan - we will get rid of MI
143 # soon enough, but till then this will do
144 # the point is to have a *really* clean perl (the ones
145 # we build are guaranteed to be clean, without side
146 # effects from travis preinstalls)
148 # trick cpanm into executing true as shell - we just need the find+unpack
149 run_or_err "Downloading DBIC inc/ from CPAN" \
150 "SHELL=/bin/true cpanm --look DBIx::Class"
152 mv ~/.cpanm/latest-build/DBIx-Class-*/inc .
154 # we will be running all tests - preinstall MOAR stuff, run basic tests using SQLT
155 # and set up whatever databases necessary
156 parallel_installdeps_notest Module::Install DateTime::Format::Strptime MooseX::Types JSON::Any Class::DBI
158 export DBICTEST_SQLT_DEPLOY=1
160 ### apt-get invocation - faster to grab everything at once
162 # FIXME these debconf lines should automate the firebird config but do not :(((
163 sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/enabled\tboolean\ttrue" | debconf-set-selections'
164 sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/sysdba_password/new_password\tpassword\t123" | debconf-set-selections'
166 APT_PACKAGES="memcached firebird2.5-super firebird2.5-dev expect"
167 run_or_err "Installing packages ($APT_PACKAGES)" "sudo apt-get install -y $APT_PACKAGES"
170 export DBICTEST_MEMCACHED=127.0.0.1:11211
173 run_or_err "Creating MySQL TestDB" "mysql -e 'create database dbic_test;'"
174 export DBICTEST_MYSQL_DSN='dbi:mysql:database=dbic_test;host=127.0.0.1'
175 export DBICTEST_MYSQL_USER=root
178 run_or_err "Creating PostgreSQL TestDB" "psql -c 'create database dbic_test;' -U postgres"
179 export DBICTEST_PG_DSN='dbi:Pg:database=dbic_test;host=127.0.0.1'
180 export DBICTEST_PG_USER=postgres
183 # poor man's deb config
185 spawn dpkg-reconfigure --frontend=text firebird2.5-super
186 expect "Enable Firebird server?"
187 send "\177\177\177\177yes\r"
188 expect "Password for SYSDBA"
194 run_or_err "Re-configuring Firebird" "
196 DEBIAN_FRONTEND=text sudo expect -c '$EXPECT_FB_SCRIPT'
199 # restart the server for good measure
200 sudo /etc/init.d/firebird2.5-super stop || true
203 sudo /etc/init.d/firebird2.5-super start
209 # FIXME - this step still fails from time to time >:(((
210 # has to do with the FB reconfiguration I suppose
211 # for now if it fails - simply skip FB testing
212 if run_or_err "Creating Firebird TestDB" \
213 "echo \"CREATE DATABASE '/var/lib/firebird/2.5/data/dbic_test.fdb';\" | sudo isql-fb -u sysdba -p 123"
215 # the official version is full of 5.10-isms, but works perfectly fine on 5.8
216 # pull in our patched copy
217 run_or_err "Fetching patched DBD::Firebird" \
218 "git clone https://github.com/dbsrgits/perl-dbd-firebird-5.8.git ~/dbd-firebird"
220 # the official version is very much outdated and does not compile on 5.14+
221 # use this rather updated source tree (needs to go to PAUSE):
222 # https://github.com/pilcrow/perl-dbd-interbase
223 run_or_err "Fetching patched DBD::InterBase" \
224 "git clone https://github.com/dbsrgits/perl-dbd-interbase ~/dbd-interbase"
226 parallel_installdeps_notest ~/dbd-interbase/ ~/dbd-firebird/
228 export DBICTEST_FIREBIRD_DSN=dbi:Firebird:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
229 export DBICTEST_FIREBIRD_USER=SYSDBA
230 export DBICTEST_FIREBIRD_PASS=123
232 export DBICTEST_FIREBIRD_INTERBASE_DSN=dbi:InterBase:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
233 export DBICTEST_FIREBIRD_INTERBASE_USER=SYSDBA
234 export DBICTEST_FIREBIRD_INTERBASE_PASS=123
239 #DBICTEST_ORA_DSN=dbi:Oracle:host=localhost;sid=XE
240 #DBICTEST_ORA_USER=dbic_test
241 #DBICTEST_ORA_PASS=123
242 #DBICTEST_ORA_EXTRAUSER_DSN=dbi:Oracle:host=localhost;sid=XE
243 #DBICTEST_ORA_EXTRAUSER_USER=dbic_test_extra
244 #DBICTEST_ORA_EXTRAUSER_PASS=123
245 #ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client
248 # generate the makefile which will have different deps depending on
249 # the runmode and envvars set above
250 run_or_err "Configure on current branch" "perl Makefile.PL"
252 # install the remaining dependencies
253 parallel_installdeps_notest $(make listalldeps)
255 # make sure we got everything we need
256 perl Makefile.PL &> /dev/null
257 if [[ -n "$(make listdeps)" ]] ; then
258 echo_err "$(tstamp) Not all deps installed - something went wrong :("
263 run_or_err "Prepare blib" "make pure_all"
265 # announce what are we running
267 ========================= CONFIGURATION COMPLETE ===========================
268 Configuration phase seems to have taken $(date -ud "@$SECONDS" '+%H:%M:%S') (@$SECONDS)
271 $(perl -0777 -p -e 's/.+\n\n(?!\z)//s' < /proc/cpuinfo)
277 $(env | grep -P 'TEST|TRAVIS|PERL|DBIC' | LC_ALL=C sort | cat -v)
281 ============================================================================
283 $(tstamp) Starting tests using $NUMTHREADS concurrent processes"