-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.travis.yml
112 lines (97 loc) · 4.91 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
language: php
php:
- 7.2
sudo: enabled
env:
global:
- STANDALONE=TRUE
addons:
apt:
sources:
- mysql-5.7-trusty
packages:
- mysql-server
- mysql-client
services:
- mysql
- redis-server
branches:
only:
master
before_install:
# We need beanstalkd for backgrounding
- travis_retry sudo apt-get update
- travis_retry sudo apt-get install beanstalkd
# SpamAssasin for filtering.
- sudo apt-get install spamassassin spamc psmisc
- sudo groupadd spamd
- sudo useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
- sudo mkdir /var/log/spamassassin
- sudo sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/spamassassin
- sudo sed -i 's/home-dir/home-dir -4/g' /etc/default/spamassassin
- sudo service spamassassin start
- sudo apt-get install php-ssh2
- sudo ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
# GeoIP
- sudo apt-get install php-geoip
- sudo add-apt-repository ppa:maxmind/ppa -y
- sudo apt-get install geoipupdate
- sudo echo UserId $MAXMIND_ACCOUNT > /tmp/GeoIP.conf
- sudo echo LicenseKey $MAXMIND_KEY >> /tmp/GeoIP.conf
- sudo echo ProductIds GeoLite2-Country GeoLite2-City >> /tmp/GeoIP.conf
- sudo geoipupdate -v -f /tmp/GeoIP.conf
# Having installed MySQL 5.7 we need to reset the password.
- sudo systemctl unmask mysql
- sudo service mysql start
- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
- sudo mysql_upgrade
# ...and change some config, otherwise some of the larger attachment inserts fail.
- echo -e "[server]\nmax_allowed_packet=32MB" | sudo tee -a /etc/mysql/my.cnf
- sudo service mysql restart
# PHP extensions
- travis_retry pecl install mailparse
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- echo "extension = ssh2.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
# Redis listens on localhost on travis, whereas we use a unix socket on the live servers.
- sed -ie 's/\/var\/run\/redis\/redis.sock/127.0.0.1/g' include/config.php
# /etc/iznik.conf is where our config goes on the live server. We have some keys in environment variables.
- sudo cp install/iznik.conf.php /etc/iznik.conf
- sudo chmod 777 /etc/iznik.conf
- sudo sed -ie "s/'GOOGLE_VISION_KEY', 'zzz'/'GOOGLE_VISION_KEY', '$GOOGLE_VISION_KEY'/g" /etc/iznik.conf
- sudo sed -ie "s/'AZURE_CONNECTION_STRING', 'zzzz'/'AZURE_CONNECTION_STRING', '$AZURE_CONNECTION_STRING'/g" /etc/iznik.conf
- sudo sed -ie "s/'PLAYGROUND_TOKEN', 'zzzz'/'PLAYGROUND_TOKEN', '$PLAYGROUND_TOKEN'/g" /etc/iznik.conf
- sudo sed -ie "s/'PLAYGROUND_SECRET', 'zzzz'/'PLAYGROUND_SECRET', '$PLAYGROUND_SECRET'/g" /etc/iznik.conf
- sudo sed -ie "s/'FBGRAFFITIAPP_ID', 'zzz'/'FBGRAFFITIAPP_ID', '$FBGRAFFITIAPP_ID'/g" /etc/iznik.conf
- sudo sed -ie "s/'FBGRAFFITIAPP_SECRET', 'zzz'/'FBGRAFFITIAPP_SECRET', '$FBGRAFFITIAPP_SECRET'/g" /etc/iznik.conf
- sudo sed -ie "s/'CHAT_HOST', 'users.ilovefreegle.org'/'CHAT_HOST', NULL/g" /etc/iznik.conf
- echo "define('SQLLOG', TRUE);" >> /etc/iznik.conf
# phpunit.xml is set up for running tests on our debug server.
- sed -ie 's/\/var\/www\/iznik.mt.dbg\//\//g' test/ut/php/phpunit.xml
# Set up the DB. We need to make some minor schema tweaks otherwise it fails to install.
- mysql -e 'CREATE DATABASE IF NOT EXISTS iznik;'
- sed -ie 's/ROW_FORMAT=DYNAMIC//g' install/schema.sql
- sed -ie 's/timestamp(3)/timestamp/g' install/schema.sql
- sed -ie 's/timestamp(6)/timestamp/g' install/schema.sql
- sed -ie 's/CURRENT_TIMESTAMP(3)/CURRENT_TIMESTAMP/g' install/schema.sql
- sed -ie 's/CURRENT_TIMESTAMP(6)/CURRENT_TIMESTAMP/g' install/schema.sql
- mysql -u root iznik < install/schema.sql
- mysql -u root iznik < install/functions.sql
- mysql -e "SET GLOBAL sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"
# We need the DamLevLim UDF.
- sudo cp install/mysqldamlevlim.so /usr/lib/mysql/plugin/
- mysql -u root -e "CREATE FUNCTION damlevlim RETURNS INT SONAME 'mysqldamlevlim.so'"
# Install composer dependencies. Use v1 as we're not compatible with v2.
- cd composer
- travis_retry wget https://getcomposer.org/composer-1.phar
- travis_retry php composer-1.phar install
- cd ..
# Set up the environment we need for running our UT.
- php install/testenv.php
script:
# We need our background and export scripts running for some UTs
- php $TRAVIS_BUILD_DIR/scripts/cron/background.php&
- php $TRAVIS_BUILD_DIR/scripts/cron/exports.php&
# Run the UT
- cd $TRAVIS_BUILD_DIR/http/api; ../../composer/vendor/bin/phpunit --stderr --bootstrap ../../composer/vendor/autoload.php -dxdebug.coverage_enable=1 --coverage-clover ../../test/ut/php/clover.xml --configuration ../../test/ut/php/phpunit.xml ../../test/ut/php/
after_script:
- cd $TRAVIS_BUILD_DIR ; php composer/vendor/bin/php-coveralls -v