forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
302 lines (268 loc) · 12.5 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
language: php
dist: bionic
git:
depth: 2
addons:
apt_packages:
- parallel
- language-pack-fr-base
- zookeeperd
- libzookeeper-mt-dev
- librabbitmq-dev
- libsodium-dev
- libtidy-dev
- zlib1g-dev
env:
global:
- SYMFONY_VERSION=5.4
- MIN_PHP=7.2.5
- SYMFONY_PROCESS_PHP_TEST_BINARY=~/.phpenv/shims/php
- SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE=1
matrix:
include:
- php: 7.2
env: php_extra="7.3 7.4"
- php: 8.0
env: deps=high
- php: 8.0
env: deps=low
fast_finish: true
cache:
directories:
- .phpunit
- php-$MIN_PHP
- ~/php-ext
before_install:
- |
# General configuration
set -e
stty cols 120
sudo sed -i 's/127\.0\.1\.1 localhost/127.0.0.1 localhost/' /etc/hosts
cp .github/composer-config.json "$(composer config home)/config.json"
git config --global user.email ""
git config --global user.name "Symfony"
export PHPUNIT=$(readlink -f ./phpunit)
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
export COMPOSER_UP='composer update --no-progress --ansi'
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n' | sort)
export SYMFONY_FEATURE_BRANCH=$(curl -s https://flex.symfony.com/versions.json | jq -r '."dev-name"')
export SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)
nanoseconds () {
local cmd="date"
local format="+%s%N"
local os=$(uname)
if hash gdate > /dev/null 2>&1; then
cmd="gdate"
elif [[ "$os" = Darwin ]]; then
format="+%s000000000"
fi
$cmd -u $format
}
export -f nanoseconds
# tfold is a helper to create folded reports
tfold () {
local title="$PHP $1 $FLIP"
local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
shift
local id=$(printf %08x $(( RANDOM * RANDOM )))
local start=$(nanoseconds)
echo -e "travis_fold:start:$fold"
echo -e "travis_time:start:$id"
echo -e "\\e[1;34m$title\\e[0m"
bash -xc "$*" 2>&1
local ok=$?
local end=$(nanoseconds)
echo -e "\\ntravis_time:end:$id:start=$start,finish=$end,duration=$(($end-$start))"
(exit $ok) &&
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
echo -e "\\e[41mKO\\e[0m $title\\n"
(exit $ok)
}
export -f tfold
# tpecl is a helper to compile and cache php extensions
tpecl () {
local ext_name=$1
local ext_so=$2
local INI=$3
local input=${4:-yes}
local ext_dir=$(php -r "echo ini_get('extension_dir');")
local ext_cache=~/php-ext/$(basename $ext_dir)/$ext_name
if [[ -e $ext_cache/$ext_so ]]; then
echo extension = $ext_cache/$ext_so >> $INI
else
rm ~/.pearrc /tmp/pear 2>/dev/null || true
mkdir -p $ext_cache
echo $input | pecl -q install -f $ext_name &&
cp $ext_dir/$ext_so $ext_cache
fi
}
export -f tpecl
- |
# Install sigchild-enabled PHP to test the Process component on the lowest PHP matrix line
if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then
wget http://php.net/get/php-$MIN_PHP.tar.bz2/from/this/mirror -O - | tar -xj &&
(cd php-$MIN_PHP && ./configure --enable-sigchild --enable-pcntl && make -j2)
fi
- |
# php.ini configuration
(
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
([[ $PHP != 7.4 ]] && phpenv global $PHP 2>/dev/null) || (cd / && wget https://storage.googleapis.com/travis-ci-language-archives/php/binaries/ubuntu/18.04/x86_64/php-$PHP.tar.bz2 -O - | tar -xj) &
done
wait
)
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
echo date.timezone = Europe/Paris >> $INI
echo memory_limit = -1 >> $INI
echo default_socket_timeout = 10 >> $INI
echo session.gc_probability = 0 >> $INI
echo opcache.enable_cli = 1 >> $INI
echo apc.enable_cli = 1 >> $INI
done
find ~/.phpenv -name xdebug.ini -delete
composer self-update
composer self-update --2
- |
# Install extra PHP extensions
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
export PHP=$PHP
phpenv global $PHP
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
if ! php --ri sodium > /dev/null; then
tfold ext.libsodium tpecl libsodium sodium.so $INI
fi
if [[ $PHP != 8.* ]]; then
tfold ext.zookeeper tpecl zookeeper-0.7.2 zookeeper.so $INI
fi
tfold ext.memcached tpecl memcached-3.1.5 memcached.so $INI
tfold ext.amqp tpecl amqp-1.11.0beta amqp.so $INI
tfold ext.apcu tpecl apcu-5.1.19 apcu.so $INI
tfold ext.igbinary tpecl igbinary-3.1.6 igbinary.so $INI
tfold ext.redis tpecl redis-5.2.3 redis.so $INI "no"
tfold ext.mongodb tpecl mongodb-1.10.0alpha1 mongodb.so $INI
done
install:
- |
# Install the phpunit-bridge from a PR if required
#
# To run a PR with a patched phpunit-bridge, first submit the patch for the
# phpunit-bridge as a separate PR against the next feature-branch then
# uncomment and update the following line with that PR number
#SYMFONY_PHPUNIT_BRIDGE_PR=32886
if [[ $SYMFONY_PHPUNIT_BRIDGE_PR ]]; then
git fetch --depth=2 origin refs/pull/$SYMFONY_PHPUNIT_BRIDGE_PR/head
git rm -rq src/Symfony/Bridge/PhpUnit
git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit
SYMFONY_PHPUNIT_BRIDGE_REF=$(curl -s https://api.github.com/repos/symfony/symfony/pulls/$SYMFONY_PHPUNIT_BRIDGE_PR | jq -r .base.ref)
sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_PHPUNIT_BRIDGE_REF'.x@dev"/' composer.json
rm -rf .phpunit
fi
- |
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
if [[ ! $deps ]]; then
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
else
export SYMFONY_DEPRECATIONS_HELPER=weak &&
cp composer.json composer.json.orig &&
echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json &&
php .github/build-packages.php HEAD^ $SYMFONY_VERSION $(find src/Symfony -mindepth 2 -type f -name composer.json -printf '%h\n' | sort) &&
mv composer.json composer.json.phpunit &&
mv composer.json.orig composer.json
fi
if [[ $SYMFONY_PHPUNIT_BRIDGE_PR ]]; then
git rm -fq -- src/Symfony/Bridge/PhpUnit/composer.json
git diff --staged -- src/Symfony/Bridge/PhpUnit/ | git apply -R --index
fi
- |
# For the highest branch, when deps=high, the version before it is checked out and tested with the locally patched components
if [[ $deps = high && $SYMFONY_VERSION = $(echo "$SYMFONY_VERSIONS" | tail -n 1 | sed s/.//) ]]; then
export FLIP='^'
export SYMFONY_VERSION=$(echo "$SYMFONY_VERSIONS" | grep -FB1 /$SYMFONY_VERSION | head -n 1 | sed s/.//) &&
git fetch --depth=2 origin $SYMFONY_VERSION &&
git checkout -m FETCH_HEAD &&
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n' | sort)
fi
- |
# Skip the phpunit-bridge on bugfix-branches when $deps is empty
if [[ ! $deps && $SYMFONY_VERSION != $SYMFONY_FEATURE_BRANCH ]]; then
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' -printf '%h\n' | sort)
fi
- |
# Install symfony/flex
if [[ $deps = low ]]; then
export SYMFONY_REQUIRE='>=3.4'
else
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
fi
composer global require --no-progress --no-scripts --no-plugins symfony/flex
- |
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
[[ $deps = high && $SYMFONY_VERSION = *.4 ]] && export LEGACY=,legacy
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi
- |
# phpinfo
phpinfo() {
phpenv global $1
php -r 'foreach (get_loaded_extensions() as $extension) echo $extension . " " . phpversion($extension) . PHP_EOL;'
php -i
}
export -f phpinfo
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
tfold phpinfo phpinfo $PHP
done
- |
run_tests () {
set -e
export PHP=$1
if [[ $PHP != 8.0* && $PHP != $TRAVIS_PHP_VERSION && $TRAVIS_PULL_REQUEST != false ]]; then
echo -e "\\n\\e[33;1mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
return
fi
phpenv global $PHP
rm vendor/composer/package-versions-deprecated -Rf
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; cp composer.json composer.bak; composer require --dev --no-update mongodb/mongodb)
tfold 'composer update' $COMPOSER_UP
tfold 'phpunit install' ./phpunit install
if [[ $deps = high ]]; then
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'" || X=1
(cd src/Symfony/Component/HttpFoundation; mv composer.bak composer.json)
COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
if [[ $COMPONENTS && $SYMFONY_VERSION = *.4 && $TRAVIS_PULL_REQUEST != false ]]; then
export FLIP='^'
SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}')
echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m"
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
git fetch --depth=2 origin $SYMFONY_VERSION
git checkout -m FETCH_HEAD
COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort)
(cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
[[ ! $COMPONENTS ]] || tfold 'phpunit install' SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 ./phpunit install
[[ ! $COMPONENTS ]] || echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT_X$LEGACY'" || X=1
fi
[[ ! $X ]] || (exit 1)
elif [[ $deps = low ]]; then
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
else
if [[ $PHP = 8.0* ]]; then
# add return types before running the test suite
sed -i 's/"\*\*\/Tests\/"//' composer.json
composer install --optimize-autoloader
SYMFONY_PATCH_TYPE_DECLARATIONS=force=1 php .github/patch-types.php
SYMFONY_PATCH_TYPE_DECLARATIONS=force=1 php .github/patch-types.php # ensure the script is idempotent
PHPUNIT_X="$PHPUNIT_X,legacy"
fi
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
tfold src/Symfony/Component/Console.tty $PHPUNIT src/Symfony/Component/Console --group tty
tfold src/Symfony/Bridge/Twig.tty $PHPUNIT src/Symfony/Bridge/Twig --group tty
if [[ $PHP = ${MIN_PHP%.*} ]]; then
export PHP=$MIN_PHP
tfold src/Symfony/Component/Process.sigchild SYMFONY_DEPRECATIONS_HELPER=weak php-$MIN_PHP/sapi/cli/php ./phpunit --colors=always src/Symfony/Component/Process/
fi
fi
}
export -f run_tests
script:
echo $TRAVIS_PHP_VERSION $php_extra | xargs -n1 bash -c '(</dev/tty run_tests $0)' || false