-
Notifications
You must be signed in to change notification settings - Fork 43
/
.travis.yml
112 lines (97 loc) · 3.32 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
# http://about.travis-ci.org/docs/user/languages/php/
# dist: trusty
sudo: false
language: php
# list any PHP version
php:
# using major version aliases
# aliased to a recent 7.x version
- 7.1
- 7.0
- 5.6
- 5.5
- 5.4
# - 5.3
services:
- mysql
- memcached
- redis-server
git:
depth: 2
# https://docs.travis-ci.com/user/environment-variables/
# optionally specify a list of environments
env:
# global:
matrix:
- environ=dev
- environ=product
# optionally set up exclutions and allowed failures in the matrix
# matrix:
# # allow_failures:
# # - php: 5.3
#init tests environment
install:
# use init.cmd YYF ( test the server.cmd, when php>=5.4)
- if [[ "$environ" == "dev" ]];then
if [[ $TRAVIS_PHP_VERSION = "5.3" ]];then
echo 3 |./init.cmd;
else
echo 2 |./init.cmd &
fi;
else
echo 4 |./init.cmd;
fi;
- export PHP_CONF="$(dirname ~/ss)/.phpenv/versions/$(phpenv version-name)/etc"
# Enable redis.so and memcached.so
# test sqlite in dev and test mysql in product
- if [[ "$environ" == "product" ]];then
echo -e "extension = redis.so\nextension = memcached.so">> $PHP_CONF/php.ini;
sed -i'' 's/options.3 = 2/options.3 = 0/' conf/secret.*.ini;
else
sed -i'' -e's/db\._\./db.tmp./' -e's/db\.test\./db._./' -e's/db\.tmp\./db.test./' conf/secret.common.ini;
fi;
# allow yaf autoload
- echo 'yaf.use_spl_autoload = 1' >> $PHP_CONF/php.ini
- '[[ "$environ" != "product" ]] || wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.8.0/php-cs-fixer.phar -O ../php-cs-fixer'
- '[[ "$environ" != "product" ]] || chmod +x ../php-cs-fixer'
# execute any number of scripts before the test run, custom env's are available as variables
before_script:
# init MySQL database
- sed '/^\/\*MYSQL/d;/MYSQL\*\//d' tests/yyf.sql|mysql -uroot;
# init Sqlite database
- sed '/^\/\*SQLITE/d;/SQLITE\*\//d' tests/yyf.sql|sqlite3 runtime/yyf.db;
# Waiting for the php dev server to start
- if [[ "$environ" == "dev" && $TRAVIS_PHP_VERSION != "5.3" ]];then
while [ ! -f "$PHP_CONF/conf.d/yaf.ini" ];do
sleep 0.5;
done;
echo "Initialized!";
fi;
# omitting "script:" will default to phpunit
# use the env variable to determine the phpunit.xml to use
script:
# test php
- phpunit -c tests/phpunit.xml
# check format style
# disabled xdebug to speed up
- phpenv config-rm xdebug.ini
- '[[ "$environ" != "product" || $TRAVIS_PHP_VERSION < "5.6" ]] || ../php-cs-fixer fix -v --dry-run --using-cache=no library/'
- '[[ "$environ" != "product" || $TRAVIS_PHP_VERSION < "5.6" ]] || ../php-cs-fixer fix -v --dry-run --using-cache=no app/'
- '[[ "$environ" != "product" || $TRAVIS_PHP_VERSION < "5.6" ]] || ../php-cs-fixer fix -v --dry-run --using-cache=no public/'
# test server
- if [[ "$environ" == "dev" && $TRAVIS_PHP_VERSION != "5.3" ]];then
curl -sS localhost:1122|grep -iPo '(?<=<title>)(.*)(?=</title>)';
fi;
#on fail
after_failure:
- if [[ "$environ" == "dev" && $TRAVIS_PHP_VERSION != "5.3" ]];then cat server.cmd ;fi;
- cat runtime/log/*.log
- test -f runtime/error* && cat runtime/error*
#on success
after_success:
- cat runtime/phpunit/test.txt
# configure notifications (email, IRC, campfire etc)
notifications:
email:
on_failure: change
on_success: change