Skip to content

Commit

Permalink
also test for core stable7+
Browse files Browse the repository at this point in the history
  • Loading branch information
MorrisJobke committed Jul 1, 2015
1 parent 48486cc commit a492d96
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 9 deletions.
26 changes: 17 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ php:

env:
matrix:
- DB=mysql
- DB=mysql OWNCLOUD=master

matrix:
allow_failures:
- php: 7
- php: hhvm
include:
- php: 5.4
env: DB=sqlite
env: DB=sqlite OWNCLOUD=master
- php: 5.4
env: DB=pgsql
env: DB=pgsql OWNCLOUD=master
- php: 5.4
env: DB=mysql OWNCLOUD=stable8
- php: 5.4
env: DB=mysql OWNCLOUD=stable7
fast_finish: true

branches:
Expand All @@ -29,27 +33,31 @@ branches:

before_install:
- cd ..
- git clone https://github.com/owncloud/core.git --depth 1
- git clone https://github.com/owncloud/core.git --depth 1 -b $OWNCLOUD
- mv music core/apps/
- cd core
- git submodule update --init
# startup php server
- php -S localhost:8888 -t . &
# provisioning the database
- mysql -u root -e "CREATE DATABASE oc_autotest; CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY 'oc_autotest'; GRANT ALL ON oc_autotest.* TO 'oc_autotest'@'localhost';"
- psql -U postgres -w -c "CREATE DATABASE oc_autotest;"
- psql -U postgres -w -c "CREATE USER oc_autotest WITH PASSWORD 'oc_autotest'; GRANT ALL PRIVILEGES ON DATABASE oc_autotest TO oc_autotest;"
# setup ownCloud
- ./occ maintenance:install --admin-user admin --admin-pass admin --database $DB --database-name oc_autotest --database-user oc_autotest --database-pass oc_autotest
- apps/music/build/setup.sh $OWNCLOUD $DB oc_autotest oc_autotest oc_autotest admin admin
# TODO remove once stable7 is not supported anymore
- bash -c "if [ '$OWNCLOUD' == 'stable7' ]; then sed -i '461 s/self/#self/' lib/base.php; fi"
- ./occ app:enable music
- OC_PASS=ampache ./occ user:add ampache --password-from-env
- apps/music/build/addUser.sh $OWNCLOUD ampache ampache
# download test data (only if not cached already)
- apps/music/tests/downloadTestData.sh data/ ampache
- ./occ files:scan ampache
- ./occ music:scan ampache
# startup php server
- php -S localhost:8888 -t . &
# TODO remove once stable7 is not supported anymore
- bash -c "if [ '$OWNCLOUD' == 'stable7' ]; then sed -i '461 s/#self/self/' lib/base.php; fi"
# add Ampache API key with ampache as password for user ampache
- bash -c "if [ '$DB' == 'sqlite' ]; then sqlite3 data/owncloud.db 'INSERT INTO oc_music_ampache_users (user_id, hash) VALUES (\"ampache\", \"3e60b24e84cfa047e41b6867efc3239149c54696844fd3a77731d6d8bb105f18\");'; fi"
- bash -c "if [ '$DB' == 'mysql' ]; then mysql -u travis oc_autotest -e 'INSERT INTO oc_music_ampache_users (user_id, hash) VALUES (\"ampache\", \"3e60b24e84cfa047e41b6867efc3239149c54696844fd3a77731d6d8bb105f18\");'; fi"
- bash -c "if [ '$DB' == 'mysql' ]; then mysql -u oc_autotest -poc_autotest oc_autotest -e 'INSERT INTO oc_music_ampache_users (user_id, hash) VALUES (\"ampache\", \"3e60b24e84cfa047e41b6867efc3239149c54696844fd3a77731d6d8bb105f18\");'; fi"
- bash -c "if [ '$DB' == 'pgsql' ]; then psql -U postgres -d oc_autotest -w -c \"INSERT INTO oc_music_ampache_users (user_id, hash) VALUES ('ampache', '3e60b24e84cfa047e41b6867efc3239149c54696844fd3a77731d6d8bb105f18');\"; fi"
- cd apps/music

Expand Down
33 changes: 33 additions & 0 deletions build/addUser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
#
# ownCloud music
#
# @author Morris Jobke
# @copyright 2015 Morris Jobke <[email protected]>
#

OWNCLOUD=$1
USER=$2
PASSWORD=$3

if [[ "$OWNCLOUD" == "master" ]];
then
OC_PASS=$PASSWORD ./occ user:add $USER --password-from-env
exit $?
fi

if [[ "$OWNCLOUD" == "stable8" ]];
then
curl -X POST -u admin:admin -d "userid=$USER&password=$PASSWORD" http://localhost:8888/ocs/v1.php/cloud/users
exit $?
fi

# patch AJAX call
sed -i "s/OCP\\\\JSON::callCheck/#OCP\\\\JSON::callCheck/g" settings/ajax/createuser.php

curl -X POST -u admin:admin -d "username=$USER&password=$PASSWORD" http://localhost:8888/index.php/settings/ajax/createuser.php

# reset change
sed -i "s/#OCP\\\\JSON::callCheck/OCP\\\\JSON::callCheck/g" settings/ajax/createuser.php

exit 0
57 changes: 57 additions & 0 deletions build/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
#
# ownCloud music
#
# @author Morris Jobke
# @copyright 2015 Morris Jobke <[email protected]>
#

OWNCLOUD=$1
DB=$2
DB_NAME=$3
DB_USER=$4
DB_PASS=$5
ADMIN_USER=$6
ADMIN_PASS=$7

if [[ "$OWNCLOUD" == 'master' ]];
then
./occ maintenance:install --admin-user $ADMIN_USER --admin-pass $ADMIN_PASS --database $DB --database-name $DB_NAME --database-user $DB_USER --database-pass $DB_PASS
exit $?
fi

cat > ./config/autoconfig.php <<DELIM
<?php
\$AUTOCONFIG = array (
'installed' => false,
'dbtype' => '$DB',
'dbtableprefix' => 'oc_',
'adminlogin' => '$ADMIN_USER',
'adminpass' => '$ADMIN_PASS',
'dbuser' => '$DB_USER',
'dbname' => '$DB_NAME',
'dbhost' => 'localhost',
'dbpass' => '$DB_PASS',
'directory' => \\OC::\$SERVERROOT . '/data',
);
DELIM

if [[ "$DB_NAME" == 'sqlite' ]];
then
cat > ./config/autoconfig.php <<DELIM
<?php
\$AUTOCONFIG = array (
'installed' => false,
'dbtype' => 'sqlite',
'dbtableprefix' => 'oc_',
'adminlogin' => '$ADMIN_USER',
'adminpass' => '$ADMIN_PASS',
'directory' => \\OC::\$SERVERROOT . '/data',
);
DELIM
fi

# trigger installation
php -f index.php | grep -i -C9999 error && echo "Error during setup" && exit 101

exit 0

0 comments on commit a492d96

Please sign in to comment.