diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 942e185eac..ce21cc3631 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -27,3 +27,5 @@ imports: - javascript - php +tools: + external_code_coverage: true diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..02876ee59d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,58 @@ +language: php +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + +matrix: + include: + - php: 5.4 + env: DB=oracle + - php: 5.4 + env: DB=pgsql + - php: 5.4 + env: DB=mysql + allow_failures: + - php: hhvm + fast_finish: true + +env: + matrix: + - DB=sqlite + +before_script: + # setup databases + - wget https://raw.githubusercontent.com/owncloud/administration/master/travis-ci/setup_databases.sh + - bash ./setup_databases.sh $DB + + # Additional PHP config + - if [[ $HHVM == false ]] ; then phpenv config-add build/travis.php.ini ; fi + + # fetch Ocular (for test coverage upload) + - wget https://scrutinizer-ci.com/ocular.phar + + # call setup for tests + - build/prepareTests.sh $DB + +script: + - phpunit --version + # Run PHP lint for each PHP version + - if [[ $DB == 'sqlite' ]] ; then ant -f build/build.xml -Dbasedir=. prepare lint ; fi + + # Run tests + - phpunit --configuration tests/phpunit-autotest.xml --coverage-clover tests/autotest-clover-$DB.xml --verbose --debug + + # Run JS tests just once (see test matrix - mysql is just run once) + - if [[ $DB == 'mysql' ]] ; then ./autotest-js.sh ; fi + + # Upload coverage report + - php ocular.phar code-coverage:upload --format=php-clover tests/autotest-clover-$DB.xml + +branches: + only: + - master + - stable5 + - stable6 + - stable7 diff --git a/build/prepareTests.sh b/build/prepareTests.sh new file mode 100755 index 0000000000..84bbfd40f6 --- /dev/null +++ b/build/prepareTests.sh @@ -0,0 +1,141 @@ +#!/bin/bash +# +# ownCloud +# +# @author Thomas Müller +# @author Morris Jobke +# @copyright 2012, 2013 Thomas Müller thomas.mueller@tmit.eu +# @copyright 2014 Morris Jobke hey@morrisjobke.de +# + +DATABASENAME=oc_autotest +DATABASEUSER=oc_autotest +ADMINLOGIN=admin +BASEDIR=$PWD + +# check for database parameter +if [ $1 ]; then + DBCONFIGS="sqlite mysql pgsql oracle" + FOUND=0 + for DBCONFIG in $DBCONFIGS; do + if [ $1 = $DBCONFIG ]; then + FOUND=1 + break + fi + done + if [ $FOUND = 0 ]; then + echo -e "Unknown database config name \"$1\"\n" >&2 + exit 2 + fi +else + echo "Please pass in a database to use as first parameter" >&2 + exit 1 +fi + +# check if config dir and file is writable +if ! [[ -w config && ( !( -e config/config.php ) || -w config/config.php ) ]]; then + echo "Please enable write permissions on config and config/config.php" >&2 + exit 1 +fi + +# use tmpfs for datadir - should speedup unit test execution +if [ -d /dev/shm ]; then + DATADIR=/dev/shm/data-autotest +else + DATADIR=$BASEDIR/data-autotest +fi + +echo "Setup environment for $1 testing ..." +# revert changes to tests/data +git checkout tests/data/* + +# reset data directory +rm -rf $DATADIR +mkdir $DATADIR + +cp tests/preseed-config.php config/config.php + +# # # # # # +# SQLite # +# # # # # # +if [ "$1" == "sqlite" ] ; then + cat > ./config/autoconfig.php < false, + 'dbtype' => 'sqlite', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', +); +DELIM +fi + +# # # # # +# MySQL # +# # # # # +if [ "$1" == "mysql" ] ; then + cat > ./config/autoconfig.php < false, + 'dbtype' => 'mysql', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', + 'dbuser' => '$DATABASEUSER', + 'dbname' => '$DATABASENAME', + 'dbhost' => 'localhost', + 'dbpass' => 'owncloud', +); +DELIM +fi + +# # # # # # # # +# PostgreSQL # +# # # # # # # # +if [ "$1" == "pgsql" ] ; then + cat > ./config/autoconfig.php < false, + 'dbtype' => 'pgsql', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', + 'dbuser' => '$DATABASEUSER', + 'dbname' => '$DATABASENAME', + 'dbhost' => 'localhost', + 'dbpass' => 'owncloud', +); +DELIM + +fi + +# # # # # # +# Oracle # +# # # # # # +if [ "$1" == "oracle" ] ; then + build/prepareTestsOracle.sh $DATABASENAME $DATABASEUSER $ADMINLOGIN $DATADIR +fi + +echo "Trigger ownCloud installation" +php -f index.php | grep -i -C9999 error && echo "Error during setup" && exit 101 + +echo "Enable apps ..." +cd tests +php -f enable_all.php | grep -i -C9999 error && echo "Error during setup" && exit 101 +cd $BASEDIR + +# show environment +echo "ownCloud configuration:" +cat $BASEDIR/config/config.php + +echo "ownCloud data directory:" +ls -ll $DATADIR + +echo "owncloud.log:" +cat $DATADIR/owncloud.log diff --git a/build/prepareTestsOracle.sh b/build/prepareTestsOracle.sh new file mode 100755 index 0000000000..65a5903665 --- /dev/null +++ b/build/prepareTestsOracle.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# ownCloud - prepareTestOracle.sh +# +# @author Morris Jobke +# @copyright 2014 Morris Jobke hey@morrisjobke.de +# + +DATABASENAME=$1 +DATABASEUSER=$2 +ADMINLOGIN=$3 +DATADIR=$4 + +# set oracle home if it is not set +TRAVIS_ORACLE_HOME="/usr/lib/oracle/xe/app/oracle/product/10.2.0/server" +[ -z "$ORACLE_HOME" ] && ORACLE_HOME=$TRAVIS_ORACLE_HOME + +echo "Load Oracle environment variables so that we can run 'sqlplus'." + . $ORACLE_HOME/bin/oracle_env.sh + +echo "drop the database" +sqlplus64 -s -l / as sysdba < ./config/autoconfig.php < false, + 'dbtype' => 'oci', + 'dbtableprefix' => 'oc_', + 'adminlogin' => '$ADMINLOGIN', + 'adminpass' => 'admin', + 'directory' => '$DATADIR', + 'dbuser' => '$DATABASEUSER', + 'dbname' => 'XE', + 'dbhost' => 'localhost', + 'dbpass' => 'owncloud', +); +DELIM + diff --git a/build/travis.php.ini b/build/travis.php.ini new file mode 100644 index 0000000000..5e5483e2d6 --- /dev/null +++ b/build/travis.php.ini @@ -0,0 +1 @@ +memory_limit = 1024M