forked from Yoast/wordpress-seo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
226 lines (216 loc) · 7.71 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
language: php
dist: trusty
sudo: false
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+)/
jobs:
fast_finish: true
include:
- php: 7.2
env: WP_VERSION=latest WP_MULTISITE=1 PHPLINT=1 PHPCS=1 CHECKJS=1 TRAVIS_NODE_VERSION=node
- php: 7.2
env: WP_VERSION=latest WP_MULTISITE=1 COVERAGE=1
- php: 5.2
# As 'trusty' is not supporting PHP 5.2/5.3 anymore, we need to force using 'precise'.
dist: precise
env: WP_VERSION=4.8 WP_MULTISITE=1 PHPLINT=1
- php: 5.3
# As 'trusty' is not supporting PHP 5.2/5.3 anymore, we need to force using 'precise'.
dist: precise
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=latest
- php: 5.2
# As 'trusty' is not supporting PHP 5.2/5.3 anymore, we need to force using 'precise'.
dist: precise
env: WP_VERSION=master
- php: nightly
env: WP_VERSION=master
- stage: 🚀 deployment
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: github-distribution-deploy
if: tag IS present
before_install:
- openssl aes-256-cbc -K $encrypted_06a9c1b95cfa_key -iv $encrypted_06a9c1b95cfa_iv -in ./deploy_keys/travis_dist_id_rsa.enc -out ./deploy_keys/travis_dist_id_rsa -d
- chmod 600 ./deploy_keys/travis_dist_id_rsa
- eval $(ssh-agent -s)
- ssh-add ./deploy_keys/travis_dist_id_rsa
before_deploy:
- nvm install node
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- yarn global add grunt-cli
- yarn install
- grunt set-version -new-version=$TRAVIS_TAG
- grunt update-version
- grunt artifact
# If the commit was tagged, create an artifact and push it to the distribution github
deploy:
skip_cleanup: true
provider: script
script: bash scripts/deploy_to_dist.sh $TRAVIS_TAG wordpress-seo
on:
tags: true
repo: $TRAVIS_REPO_SLUG
all_branches: true
allow_failures:
# Allow failures for unstable builds.
- php: nightly
- env: WP_VERSION=master
cache:
yarn: true
directories:
- vendor
- $HOME/.composer/cache
- node_modules
before_install:
- PHPUNIT_BIN="phpunit"
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" || $TRAVIS_PHP_VERSION == "nightly" ]]; then PHPUNIT_BIN="vendor/bin/phpunit"; fi
- if [[ -z "$CC_TEST_REPORTER_ID" ]]; then COVERAGE="0"; 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 [[ $TRAVIS_PHP_VERSION == "5.2" || $TRAVIS_PHP_VERSION == "5.3" ]]; then phpenv local 5.6.13; fi
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" || $TRAVIS_PHP_VERSION == "nightly" ]]; then composer require --dev phpunit/phpunit ^5.7; fi
- composer install --no-interaction
- composer config-yoastcs
- if [[ $TRAVIS_PHP_VERSION == "5.2" || $TRAVIS_PHP_VERSION == "5.3" ]]; then phpenv local --unset; fi
- |
if [[ "$CHECKJS" == "1" ]]; then
yarn global add grunt-cli
yarn install
fi
before_script:
# Careful: The HTTPS version of the following URL is different, therefore we need to use HTTP.
- |
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=50 --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"
- 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
fi
- export -f travis_fold
- export -f travis_time_start
- export -f travis_time_finish
- mysql --version
- phpenv versions
- php --version
- php -m
- $PHPUNIT_BIN --version
- 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 [[ $TRAVIS_PHP_VERSION == "5.2" ]]; then
SKIP_CLI="-o -path ./cli -prune"
fi
find -L . -path ./vendor -prune -o -path ./node_modules -prune $SKIP_CLI -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
travis_time_finish && travis_fold end "PHP.check"
fi
# PHP CS
- |
if [[ "$PHPCS" == "1" ]]; then
travis_fold start "PHP.code-style" && travis_time_start
vendor/bin/phpcs -q --runtime-set ignore_warnings_on_exit 1
travis_time_finish && travis_fold end "PHP.code-style"
fi
# PHP Unit
- |
if [[ "$COVERAGE" != "1" ]]; then
travis_fold start "PHP.tests" && travis_time_start
$PHPUNIT_BIN -c phpunit.xml
travis_time_finish && travis_fold end "PHP.tests"
fi;
# Coverage environment variable is only set on the PHP 7 build, so we can safely
# assume that PHPUnit is in the vendor directory.
- |
if [[ "$COVERAGE" == "1" ]]; then
travis_fold start "PHP.coverage" && travis_time_start
$PHPUNIT_BIN -c phpunit.xml --coverage-clover build/logs/clover.xml
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.3" || $TRAVIS_PHP_VERSION == "7.2" ]]; then composer validate --no-check-all; fi
after_script:
- 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