Smoke all branches on travis except for blocked* and wip/*
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 10_before_install.bash
1 #!/bin/bash
2
3 source maint/travis-ci_scripts/common.bash
4 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
5
6 # do some extra short-circuiting here
7
8 # when smoking master do not attempt bleadperl (not release-critical)
9 if [[ "$TRAVIS_BRANCH" = "master" ]] && [[ "$BREWVER" = "blead" ]]; then
10   echo_err "$(tstamp) master branch is not smoked with bleadperl - bailing out"
11   export SHORT_CIRCUIT_SMOKE=1
12 fi
13
14 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
15
16 # Different boxes we run on may have different amount of hw threads
17 # Hence why we need to query
18 # Originally we used to read /sys/devices/system/cpu/online
19 # but it is not available these days (odd). Thus we fall to
20 # the alwas-present /proc/cpuinfo
21 # The oneliner is a tad convoluted - basicaly what we do is
22 # slurp the entire file and get the index off the last
23 # `processor    : XX` line
24 export NUMTHREADS=$(( $(perl -0777 -n -e 'print (/ (?: .+ ^ processor \s+ : \s+ (\d+) ) (?! ^ processor ) /smx)' < /proc/cpuinfo) + 1 ))
25
26 if [[ "$CLEANTEST" != "true" ]]; then
27 ### apt-get invocation - faster to grab everything at once
28   #
29   # FIXME these debconf lines should automate the firebird config but do not :(((
30   sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/enabled\tboolean\ttrue" | debconf-set-selections'
31   sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/sysdba_password/new_password\tpassword\t123" | debconf-set-selections'
32
33   APT_PACKAGES="memcached firebird2.5-super firebird2.5-dev expect"
34   run_or_err "Installing packages ($APT_PACKAGES)" "sudo apt-get install --allow-unauthenticated -y $APT_PACKAGES"
35
36 ### config memcached
37   export DBICTEST_MEMCACHED=127.0.0.1:11211
38
39 ### config mysql
40   run_or_err "Creating MySQL TestDB" "mysql -e 'create database dbic_test;'"
41   export DBICTEST_MYSQL_DSN='dbi:mysql:database=dbic_test;host=127.0.0.1'
42   export DBICTEST_MYSQL_USER=root
43
44 ### config pg
45   run_or_err "Creating PostgreSQL TestDB" "psql -c 'create database dbic_test;' -U postgres"
46   export DBICTEST_PG_DSN='dbi:Pg:database=dbic_test;host=127.0.0.1'
47   export DBICTEST_PG_USER=postgres
48
49 ### conig firebird
50   # poor man's deb config
51   EXPECT_FB_SCRIPT='
52     spawn dpkg-reconfigure --frontend=text firebird2.5-super
53     expect "Enable Firebird server?"
54     send "\177\177\177\177yes\r"
55     expect "Password for SYSDBA"
56     send "123\r"
57     sleep 1
58     wait
59     sleep 1
60   '
61   # creating testdb
62   # FIXME - this step still fails from time to time >:(((
63   # has to do with the FB reconfiguration I suppose
64   # for now if it fails twice - simply skip FB testing
65   for i in 1 2 ; do
66
67     run_or_err "Re-configuring Firebird" "
68       sync
69       DEBIAN_FRONTEND=text sudo expect -c '$EXPECT_FB_SCRIPT'
70       sleep 1
71       sync
72       # restart the server for good measure
73       sudo /etc/init.d/firebird2.5-super stop || true
74       sleep 1
75       sync
76       sudo /etc/init.d/firebird2.5-super start
77       sleep 1
78       sync
79     "
80
81     if run_or_err "Creating Firebird TestDB" \
82       "echo \"CREATE DATABASE '/var/lib/firebird/2.5/data/dbic_test.fdb';\" | sudo isql-fb -u sysdba -p 123"
83     then
84       export DBICTEST_FIREBIRD_DSN=dbi:Firebird:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
85       export DBICTEST_FIREBIRD_USER=SYSDBA
86       export DBICTEST_FIREBIRD_PASS=123
87
88       export DBICTEST_FIREBIRD_INTERBASE_DSN=dbi:InterBase:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
89       export DBICTEST_FIREBIRD_INTERBASE_USER=SYSDBA
90       export DBICTEST_FIREBIRD_INTERBASE_PASS=123
91
92       break
93     fi
94
95   done
96
97 ### oracle
98   # FIXME: todo
99   #DBICTEST_ORA_DSN=dbi:Oracle:host=localhost;sid=XE
100   #DBICTEST_ORA_USER=dbic_test
101   #DBICTEST_ORA_PASS=123
102   #DBICTEST_ORA_EXTRAUSER_DSN=dbi:Oracle:host=localhost;sid=XE
103   #DBICTEST_ORA_EXTRAUSER_USER=dbic_test_extra
104   #DBICTEST_ORA_EXTRAUSER_PASS=123
105   #ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client
106 fi