Skip to content

Commit

Permalink
Split .travis.yml actions into shell scripts
Browse files Browse the repository at this point in the history
Travis CI recommends to keep all extensive steps in shell scripts and
keep .travis.yml minimal.
It is easy to syntactically break .yml file.
  • Loading branch information
mloskot committed Feb 28, 2013
1 parent 8ee89f9 commit c7b309a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 30 deletions.
37 changes: 7 additions & 30 deletions .travis.yml
@@ -1,5 +1,7 @@
# .travis.yml - config file SOCI CI at https://travis-ci.org/

# .travis.yml
# Configure Travis CI service to build SOCI library
# Mateusz Loskot <mateusz@loskot.net>, http://github.com/SOCI
#
language: cpp

compiler:
Expand All @@ -13,34 +15,9 @@ services:
- mysql
- postgresql

before_install:
#- cat /proc/cpuinfo
- sudo apt-get update -qq
- sudo apt-get install -qq libboost-dev libboost-date-time-dev libmyodbc unixodbc-dev odbc-postgresql firebird2.5-super firebird2.5-dev
- sudo odbcinst -i -d -f /usr/share/libmyodbc/odbcinst.ini
# See: Non-interactive setup for travis-ci.org
# http://tech.groups.yahoo.com/group/firebird-support/message/120883
#- sudo dpkg-reconfigure -f noninteractive firebird2.5-super
- sudo sed /ENABLE_FIREBIRD_SERVER=/s/no/yes/ -i /etc/default/firebird2.5
- cat /etc/default/firebird2.5 | grep ENABLE_FIREBIRD_SERVER
- sudo service firebird2.5-super start

before_script:
- mysql --version
- mysql -e 'create database soci_test;'
- psql --version
- psql -c 'create database soci_test;' -U postgres
- isql-fb -z -q -i /dev/null # --version
- echo 'CREATE DATABASE "LOCALHOST:/tmp/soci_test.fdb" PAGE_SIZE = 16384;' > /tmp/create_soci_test.sql
- isql-fb -u SYSDBA -p masterkey -i /tmp/create_soci_test.sql -q
- cat /tmp/create_soci_test.sql

script:
- mkdir -p src/_build
- cd src/_build
- cmake -DSOCI_TESTS=ON -DSOCI_EMPTY_TEST_CONNSTR:STRING="dummy connection" -DSOCI_FIREBIRD_TEST_CONNSTR:STRING="service=LOCALHOST:/tmp/soci_test.fdb user=SYSDBA password=masterkey" -DSOCI_MYSQL_TEST_CONNSTR:STRING="db=soci_test" -DSOCI_POSTGRESQL_TEST_CONNSTR:STRING="dbname=soci_test user=postgres" -DSOCI_SQLITE3_TEST_CONNSTR:STRING="soci_test.db" -DSOCI_ODBC_TEST_POSTGRESQL_CONNSTR="FILEDSN=${PWD}/../backends/odbc/test/test-postgresql.dsn;" -DSOCI_ODBC_TEST_MYSQL_CONNSTR="FILEDSN=${PWD}/../backends/odbc/test/test-mysql.dsn;" ..
- cmake --build .
- ctest -V --output-on-failure .
before_install: ./bin/ci/before_install.sh
before_script: ./bin/ci/before_script.sh
script: ./bin/ci/script.sh

notifications:
email:
Expand Down
22 changes: 22 additions & 0 deletions bin/ci/before_install.sh
@@ -0,0 +1,22 @@
#!/bin/sh
# Run before_intsall actions for SOCI build at travis-ci.org
# Mateusz Loskot <mateusz@loskot.net>, http://github.com/SOCI
#
# Install dependencies
sudo apt-get update -qq
sudo apt-get install -qq \
libboost-dev libboost-date-time-dev \
libmyodbc unixodbc-dev odbc-postgresql \
firebird2.5-super firebird2.5-dev
#
# Configure Firebird
# See: Non-interactive setup for travis-ci.org
# http://tech.groups.yahoo.com/group/firebird-support/message/120883
#sudo dpkg-reconfigure -f noninteractive firebird2.5-super
sudo sed /ENABLE_FIREBIRD_SERVER=/s/no/yes/ -i /etc/default/firebird2.5
cat /etc/default/firebird2.5 | grep ENABLE_FIREBIRD_SERVER
sudo service firebird2.5-super start
#
# Configure ODBC
sudo odbcinst -i -d -f /usr/share/libmyodbc/odbcinst.ini
#
16 changes: 16 additions & 0 deletions bin/ci/before_script.sh
@@ -0,0 +1,16 @@
#!/bin/sh
# Run before_script actions for SOCI build at travis-ci.org
# Mateusz Loskot <mateusz@loskot.net>, http://github.com/SOCI
#
# Create local databases
# MySQL (service provided)
mysql --version
mysql -e 'create database soci_test;'
# PostgreSQL (service provided)
psql --version
psql -c 'create database soci_test;' -U postgres
# Firebird (installed manually, see before_install.sh)
isql-fb -z -q -i /dev/null # --version
echo 'CREATE DATABASE "LOCALHOST:/tmp/soci_test.fdb" PAGE_SIZE = 16384;' > /tmp/create_soci_test.sql
isql-fb -u SYSDBA -p masterkey -i /tmp/create_soci_test.sql -q
cat /tmp/create_soci_test.sql
20 changes: 20 additions & 0 deletions bin/ci/script.sh
@@ -0,0 +1,20 @@
#!/bin/sh
# Run script actions for SOCI build at travis-ci.org
# Mateusz Loskot <mateusz@loskot.net>, http://github.com/SOCI
#
# Build SOCI using CMake (primary build configuration)
mkdir -p src/_build
cd src/_build
cmake \
-DSOCI_TESTS=ON \
-DSOCI_EMPTY_TEST_CONNSTR:STRING="dummy connection" \
-DSOCI_FIREBIRD_TEST_CONNSTR:STRING="service=LOCALHOST:/tmp/soci_test.fdb user=SYSDBA password=masterkey" \
-DSOCI_MYSQL_TEST_CONNSTR:STRING="db=soci_test" \
-DSOCI_POSTGRESQL_TEST_CONNSTR:STRING="dbname=soci_test user=postgres" \
-DSOCI_SQLITE3_TEST_CONNSTR:STRING="soci_test.db" \
-DSOCI_ODBC_TEST_POSTGRESQL_CONNSTR="FILEDSN=${PWD}/../backends/odbc/test/test-postgresql.dsn;" \
-DSOCI_ODBC_TEST_MYSQL_CONNSTR="FILEDSN=${PWD}/../backends/odbc/test/test-mysql.dsn;" \
..
cmake --build .
# Run tests
ctest -V --output-on-failure .

0 comments on commit c7b309a

Please sign in to comment.