-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy path.travis.yml
183 lines (150 loc) · 4.72 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
sudo: required
language: php
php: 7.1
services:
- mysql
- docker
- postgresql
matrix:
include:
- php: 7.1
env:
- DB=mysql
- SELENIUM=1
- COVERAGE=1
- php: 7.2
env:
- DB=mysql
- SELENIUM=1
- php: 7.1
env: DB=postgres
allow_failures:
- env: DB=postgres
fast_finish: true
# Run pushed branches build on master and tagged version
branches:
only:
- master
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
addons:
postgresql: "9.6"
chrome: stable
before_install:
- cp /home/travis/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/xdebug.ini .
- phpenv config-rm xdebug.ini
- mkdir -p $TRAVIS_BUILD_DIR/results/coverage
- cp scripts/tests/.env.$DB.travis .env
- if [[ "$DB" == "mysql" ]]; then mysql -v -e 'CREATE DATABASE monica;'; fi
- if [[ "$DB" == "postgres" ]]; then psql -e -c 'CREATE DATABASE monica;' -U postgres; fi
- composer self-update
install:
# Get packages
- travis_retry composer install --no-interaction --no-suggest --ignore-platform-reqs
# Build js and css assets
- php artisan lang:generate
- npm install
- npm run production
before_script:
- php artisan migrate --env=testing --no-interaction -vvv
- php artisan db:seed --env=testing --no-interaction -vvv
# Start Xvfb
- "export DISPLAY=:99.0"
- if [[ "$SELENIUM" == "1" && "$SAUCELABS" != "1" ]]; then /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16; fi
# Start chromedriver
- bash -c "if [[ \"$SELENIUM\" == \"1\" && \"$SAUCELABS\" != \"1\" ]]; then ./vendor/bin/chromedriver; fi" &
script:
# Run unit tests
- phpdbg -qrr vendor/bin/phpunit -c phpunit${DB/mysql/}.xml
# Start http server
- phpenv config-add xdebug.ini
- bash -c "if [[ \"$SELENIUM\" == \"1\" ]]; then php -S localhost:8000 -t $TRAVIS_BUILD_DIR/public $TRAVIS_BUILD_DIR/scripts/tests/server-cc.php 2>/dev/null; fi" &
- if [[ "$SELENIUM" == "1" ]]; then until $(nc -z localhost 8000); do sleep 1; echo Waiting for http server to start...; done; fi
# Run browser tests
- if [[ "$SELENIUM" == "1" ]]; then php artisan dusk; fi
after_script:
- if [[ "$SELENIUM" == "1" ]]; then scripts/tests/travis-report.sh 2>/dev/null; fi
- if [[ "$COVERAGE" == "1" ]]; then vendor/bin/phpcov merge --clover=$TRAVIS_BUILD_DIR/results/coverage2.xml $TRAVIS_BUILD_DIR/results/coverage/; fi
- if [[ "$COVERAGE" == "1" ]]; then bash <(curl -s https://codecov.io/bash); fi
- if [[ "$COVERAGE" == "1" ]]; then scripts/tests/travis-sonar.sh; fi
cache:
directories:
- $HOME/.composer/cache/files
- node_modules
- $HOME/.sonar/cache
- $HOME/sonarscanner
- $HOME/sonarlauncher
jobs:
include:
- stage: Tests
php: 7.1
env:
- DB=mysql
- SELENIUM=1
- COVERAGE=1
- stage: Tests
php: 7.2
env:
- DB=mysql
- SELENIUM=1
- stage: Tests
allow_failure: true
php: 7.1
env: DB=postgres
- stage: Deploy
if: tag IS present
skip_cleanup: true
before_install:
- cp scripts/tests/.env.mysql.travis .env
- composer self-update
install:
# Get packages without require-dev
- travis_retry composer install --no-interaction --no-suggest --ignore-platform-reqs --no-dev
# Build js and css assets
- php artisan lang:generate
- npm install
- npm run production
before_script: skip
script:
- make dist
after_script: skip
before_deploy:
- make .travis.deploy.json
deploy:
provider: bintray
file: .travis.deploy.json
skip_cleanup: true
user: $BINTRAY_USER
key: $BINTRAY_APIKEY
on:
all_branches: true
- stage: Deploy
if: tag IS present
before_install:
- cp scripts/tests/.env.mysql.travis .env
- docker-compose --version
install: skip
before_script: skip
script:
- make docker_build
- echo $BINTRAY_APIKEY | docker login -u $BINTRAY_USER --password-stdin monicahq-docker-docker.bintray.io
- make docker_push_bintray
after_script: skip
- stage: Deploy
if: tag IS present
before_install:
- scripts/vagrant/install-vagrant.sh
install: skip
before_script: skip
script:
- make vagrant_build
after_script: skip
before_deploy:
- DEPLOY_TEMPLATE=scripts/vagrant/build/.travis.deploy.json.in make .travis.deploy.json
deploy:
provider: bintray
file: .travis.deploy.json
skip_cleanup: true
user: $BINTRAY_USER
key: $BINTRAY_APIKEY
on:
all_branches: true