forked from Yoast/wordpress-seo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
318 lines (304 loc) · 11.2 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
os: linux
dist: xenial
language: php
services:
- mysql
branches:
only:
- master
- trunk
- /^release\/*/
- /^hotfix\/\d+\.\d+(\.\d+)?(-\S*)?$/
- /^feature\/*/
# Also build tags like 1.1.1 or 1.1 for deployment.
- /^\d+\.\d+(\.\d+)?(-\S*)?$/
stages:
# Don't run the test steps on tag builds, this makes tag deployments a ton faster.
- name: test
if: NOT tag is present
- 🚀 deployment
jobs:
fast_finish: true
include:
- php: 7.2
env: PHPCS=1 CHECKJS=1 SECURITY=1 TRAVIS_NODE_VERSION=lts/* AUTO_CHECKOUT_MONOREPO_BRANCH=1
- php: 7.3
env: WP_VERSION=latest WP_MULTISITE=1 COVERAGE=1
- php: 5.6
env: WP_VERSION=5.4 WP_MULTISITE=1 PHPLINT=1 PHPUNIT=1
# Use 'trusty' to test against MySQL 5.6, 'xenial' contains 5.7 by default.
dist: trusty
- php: 7.3
env: WP_VERSION=master PHPUNIT=1
- php: 7.4
env: WP_VERSION=latest PHPUNIT=1 PHPLINT=1
- php: "nightly"
env: PHPLINT=1
- stage: 🚀 deployment
name: "Deploy to S3"
if: branch = deploy # Only build when on the `deploy` branch, this functionality is not used yet and is taking a long time to complete.
env: SC_ATTR=wordpress-seo
before_script: skip
script: grunt artifact
install:
- yarn global add grunt-cli
- yarn install
deploy:
skip_cleanup: true
provider: s3
access_key_id: AKIAJRNLQAPRL5UKDJKQ
secret_access_key:
secure: TE13B5MDyw16DxEIRpbXPtxb1LZAzi8jdCU4FZuTzNsdVaowlAXUEFFB+g8uapoQhJKqvZrwvrpqifRPhH0tcRlJ5Z0A+qWp8WhiFGmipp3gJBblacviAIvswGzKFN8+DgQVwHSKpzk3ZjEkDkH/KYq6OTYPL/g5oRwsjI0Ug9w=
bucket: yoast-seo-builds
region: us-east-1
local-dir: artifact
upload-dir: $TRAVIS_BRANCH
on:
repo: Yoast/wordpress-seo
all_branches: true
- stage: 🚀 deployment
name: "Deploy to Yoast-dist"
php: 7.2
install:
- yarn global add grunt-cli
- |
if [[ ( $TRAVIS_BRANCH =~ ^feature\/* || $TRAVIS_BRANCH =~ ^release\/* || $TRAVIS_BRANCH = "trunk" ) && "$TRAVIS_EVENT_TYPE" = "push" ]]; then
git clone https://github.com/yoast/javascript /tmp/javascript
echo '{"monorepo-location":"/tmp/javascript"}' > .yoast
AUTO_CHECKOUT_MONOREPO_BRANCH=1 yarn link-monorepo
fi
- yarn install
before_script: skip
script:
- |
if [[ ! -z "$TRAVIS_TAG" ]]; then
grunt set-version -new-version=$TRAVIS_TAG
grunt update-version
fi
- grunt artifact
- grunt composer-artifact
if: ( tag IS present OR branch =~ /^feature\// OR branch =~ /^release\// OR branch = trunk ) AND type != pull_request
before_install:
- nvm install lts/*
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- openssl aes-256-cbc -K $encrypted_e268719177eb_key -iv $encrypted_e268719177eb_iv -in config/travis/deploy_keys/id_rsa_yoast_dist.enc -out config/travis/deploy_keys/id_rsa_yoast_dist -d
- chmod 600 config/travis/deploy_keys/id_rsa_yoast_dist
- eval $(ssh-agent -s)
- ssh-add config/travis/deploy_keys/id_rsa_yoast_dist
# If the commit was tagged, create an artifact and push it to the distribution github
deploy:
skip_cleanup: true
provider: script
script: bash config/travis/deploy_to_dist.sh ${TRAVIS_TAG:-$TRAVIS_BRANCH} wordpress-seo
on:
repo: $TRAVIS_REPO_SLUG
all_branches: true
allow_failures:
# Allow failures for unstable builds.
- php: "nightly"
- php: 7.3
env: WP_VERSION=master PHPUNIT=1
cache:
yarn: true
directories:
- $HOME/.composer/cache
- .cache
- node_modules
before_install:
- export SECURITYCHECK_DIR=/tmp/security-checker
- if [[ -z "$CC_TEST_REPORTER_ID" ]]; then COVERAGE="0"; fi
- if [[ -d "premium" ]]; then IS_PREMIUM=1; fi
- if [[ "$COVERAGE" != "1" ]]; then phpenv config-rm xdebug.ini || echo 'No xdebug config.'; fi
- |
if [[ "$CHECKJS" == "1" ]]; then
nvm install $TRAVIS_NODE_VERSION
curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH=$HOME/.yarn/bin:$PATH
fi
install:
- |
if [[ "$PHPUNIT" == "1" || "$COVERAGE" == "1" || "$TRAVIS_BUILD_STAGE_NAME" == "🚀 deployment" ]]; then
# The prefix-dependencies task only works on PHP 7.1 and we need to prefix our dependencies to accurately test them.
# So we temporarily switch PHP versions, do a full install and then remove the package.
# Then switch back to the PHP version we want to test and delete the vendor directory.
phpenv local 7.1
composer install --no-interaction --ignore-platform-reqs
composer remove humbug/php-scoper --dev --ignore-platform-reqs
composer remove atanamo/php-codeshift --dev --ignore-platform-reqs
phpenv local --unset
rm -rf vendor/*
fi
- |
if [[ "$COVERAGE" == "1" ]]; then
# Install phpcov so we can combine the coverage results of unit and integration tests.
composer require phpunit/phpcov ^3.1
fi
- |
if [[ $TRAVIS_PHP_VERSION == "nightly" && "$PHPLINT" == "1" ]]; then
composer install --no-interaction --ignore-platform-reqs --no-scripts --no-suggest
elif [[ "$PHPUNIT" == "1" || "$COVERAGE" == "1" || "$PHPCS" == "1" || "$PHPLINT" == "1" ]]; then
# Run composer update as we have dev dependencies locked at PHP ^7.0 versions.
composer update
composer install --no-interaction
composer du
if [[ "$IS_PREMIUM" == "1" ]]; then
if [[ "$PHPCS" == "1" || "$PHPLINT" == "1" ]]; then
cd premium
composer install --no-interaction
cd -
fi
fi
elif [[ "$TRAVIS_BUILD_STAGE_NAME" == "🚀 deployment" ]]; then
composer update
composer install --no-dev --no-interaction
composer du
fi
- |
if [[ "$PHPCS" == "1" && "$IS_PREMIUM" != "1" ]]; then
composer config-yoastcs
fi
- |
if [[ "$CHECKJS" == "1" ]]; then
yarn global add grunt-cli
yarn install
fi
- if [[ "$SECURITY" == "1" ]]; then wget -P $SECURITYCHECK_DIR https://get.sensiolabs.org/security-checker.phar && chmod +x $SECURITYCHECK_DIR/security-checker.phar;fi
before_script:
# Careful: The HTTPS version of the following URL is different, therefore we need to use HTTP.
- |
if [[ "$PHPUNIT" == "1" || "$COVERAGE" == "1" ]]; then
if [[ "$WP_VERSION" == "latest" ]]; then
curl -s http://api.wordpress.org/core/version-check/1.7/ > /tmp/wp-latest.json
WP_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
fi
PLUGIN_SLUG=$(basename $(pwd))
export WP_DEVELOP_DIR=/tmp/wordpress/
git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ /tmp/wordpress
cd ..
cp -r "$PLUGIN_SLUG" "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
cd /tmp/wordpress/
cp wp-tests-config-sample.php wp-tests-config.php
sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
sed -i "s/yourusernamehere/travis/" wp-tests-config.php
sed -i "s/yourpasswordhere//" wp-tests-config.php
mysql -e "CREATE DATABASE wordpress_tests;" -uroot
cd "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
fi
- |
if [[ "$CHECKJS" == "1" ]]; then
git fetch --tags
PLUGIN_TAGS=$(git tag --points-at $TRAVIS_COMMIT)
if [[ -z "$PLUGIN_TAGS" ]]; then
git clone https://github.com/yoast/javascript /tmp/javascript
echo '{"monorepo-location":"/tmp/javascript"}' > .yoast
yarn link-monorepo
fi
fi
- phpenv rehash
- |
if [[ "$COVERAGE" == "1" ]]; then
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
mkdir -p /tmp/coverage
fi
- export -f travis_fold
- export -f travis_time_start
- export -f travis_time_finish
- mysql --version
- phpenv versions
- php --version
- php -m
- curl --version
- git --version
- svn --version
- |
if [[ "$CHECKJS" == "1" ]]; then
npm --version
node --version
yarn --version
grunt --version
fi
- locale -a
script:
# JavaScript checks
- |
if [[ "$CHECKJS" == "1" ]]; then
travis_fold start "JavaScript.check" && travis_time_start
grunt check:js
travis_time_finish && travis_fold end "JavaScript.check"
fi
# JavaScript tests
- |
if [[ "$CHECKJS" == "1" ]]; then
travis_fold start "JavaScript.tests" && travis_time_start
yarn test
travis_time_finish && travis_fold end "JavaScript.tests"
fi
# PHP Linting
- |
if [[ "$PHPLINT" == "1" ]]; then
travis_fold start "PHP.check" && travis_time_start
if [[ "$IS_PREMIUM" == "1" ]]; then
cd premium
composer lint
cd -
else
composer lint
fi
travis_time_finish && travis_fold end "PHP.check"
fi
# PHP CS
- |
if [[ "$PHPCS" == "1" ]]; then
travis_fold start "PHP.code-style" && travis_time_start
if [[ "$IS_PREMIUM" == "1" ]]; then
cd premium
composer check-cs
cd -
else
vendor/bin/phpcs -qn
fi
travis_time_finish && travis_fold end "PHP.code-style"
fi
# PHP Unit
- |
if [[ "$PHPUNIT" == "1" ]]; then
travis_fold start "PHP.integration-tests" && travis_time_start
vendor/bin/phpunit -c phpunit-integration.xml.dist
travis_time_finish && travis_fold end "PHP.integration-tests"
fi;
- |
if [[ "$PHPUNIT" == "1" ]]; then
travis_fold start "PHP.tests" && travis_time_start
vendor/bin/phpunit
travis_time_finish && travis_fold end "PHP.tests"
fi;
- |
if [[ "$COVERAGE" == "1" ]]; then
travis_fold start "PHP.coverage" && travis_time_start
vendor/bin/phpunit -c phpunit-integration.xml.dist --coverage-php /tmp/coverage/integration-tests.cov
travis_time_finish && travis_fold end "PHP.coverage"
fi
- |
if [[ "$COVERAGE" == "1" ]]; then
travis_fold start "PHP.coverage" && travis_time_start
vendor/bin/phpunit --coverage-php /tmp/coverage/tests.cov
travis_time_finish && travis_fold end "PHP.coverage"
fi
# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- if [[ $TRAVIS_PHP_VERSION == "5.6" || $TRAVIS_PHP_VERSION == "7.4" ]]; then composer validate --no-check-all; fi
# Check for known security vulnerabilities in the currently locked-in dependencies.
- if [[ "$SECURITY" == "1" ]]; then php $SECURITYCHECK_DIR/security-checker.phar -n security:check $(pwd)/composer.lock;fi
after_script:
- |
if [[ "$COVERAGE" == "1" ]]; then
./vendor/bin/phpcov merge /tmp/coverage --clover build/logs/clover.xml
fi
- if [[ "$COVERAGE" == "1" ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
notifications:
slack:
secure: W3StABr+AdcdQawTObK4nbsnn5nLrTTtZfVpD/GEN6gvSOQcykbGEC5+ceYg0jn5b4StDyCiTo5blEsrpVICFpYKc44+ogah+qaGRUfVRS/rpOvn4AueXTWn4JxhZzuxqKMiTmyW+MQG0uYM7sk7Q5S+15jj6ilkj4QATaBVNbY=
email: false