This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/.travis.yml

301 lines
12 KiB
YAML
Raw Normal View History

2011-11-10 03:27:56 +00:00
language: php
2021-06-06 15:23:08 +01:00
dist: bionic
git:
2018-09-03 13:29:28 +01:00
depth: 2
addons:
2015-08-18 15:04:52 +01:00
apt_packages:
- parallel
- language-pack-fr-base
- zookeeperd
- libzookeeper-mt-dev
2021-06-06 15:23:08 +01:00
- librabbitmq-dev
- libsodium-dev
- libtidy-dev
env:
global:
- SYMFONY_VERSION=4.4
- MIN_PHP=7.1.3
2017-10-11 13:06:43 +01:00
- SYMFONY_PROCESS_PHP_TEST_BINARY=~/.phpenv/shims/php
2019-08-10 19:54:30 +01:00
- SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE=1
2015-10-13 09:49:36 +01:00
2013-12-14 12:00:39 +00:00
matrix:
include:
- php: 7.1
env: php_extra="7.2 7.3 8.0"
- php: 7.4
env: deps=high
2020-12-08 13:29:48 +00:00
- php: 8.0
env: deps=low
fast_finish: true
cache:
directories:
- .phpunit
- php-$MIN_PHP
2018-02-22 12:59:51 +00:00
- ~/php-ext
before_install:
2017-04-18 16:01:04 +01:00
- |
# General configuration
set -e
2017-04-18 16:01:04 +01:00
stty cols 120
2020-10-26 16:14:25 +00:00
cp .github/composer-config.json "$(composer config home)/config.json"
2021-05-20 10:40:33 +01:00
git config --global user.email ""
git config --global user.name "Symfony"
2017-04-18 16:01:04 +01:00
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"')
2021-05-20 10:40:33 +01:00
export SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)
2017-04-18 16:01:04 +01:00
nanoseconds () {
2017-08-24 09:32:12 +01:00
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
2017-04-18 16:01:04 +01:00
# tfold is a helper to create folded reports
tfold () {
local title="$PHP $1 $FLIP"
2017-08-24 09:32:12 +01:00
local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
2017-04-18 16:01:04 +01:00
shift
2017-08-24 09:32:12 +01:00
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) &&
2017-04-18 16:01:04 +01:00
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
2017-08-24 09:32:12 +01:00
echo -e "\\e[41mKO\\e[0m $title\\n"
(exit $ok)
2017-04-18 16:01:04 +01:00
}
export -f tfold
2018-02-04 09:26:21 +00:00
# tpecl is a helper to compile and cache php extensions
tpecl () {
local ext_name=$1
local ext_so=$2
2018-02-22 12:51:03 +00:00
local INI=$3
local input=${4:-yes}
2018-02-04 09:26:21 +00:00
local ext_dir=$(php -r "echo ini_get('extension_dir');")
2018-02-22 12:59:51 +00:00
local ext_cache=~/php-ext/$(basename $ext_dir)/$ext_name
2018-02-04 09:26:21 +00:00
if [[ -e $ext_cache/$ext_so ]]; then
echo extension = $ext_cache/$ext_so >> $INI
else
rm ~/.pearrc /tmp/pear 2>/dev/null || true
2018-02-04 09:26:21 +00:00
mkdir -p $ext_cache
2021-01-14 19:21:32 +00:00
echo $input | pecl -q install -f $ext_name &&
2018-02-04 09:26:21 +00:00
cp $ext_dir/$ext_so $ext_cache
fi
}
export -f tpecl
2017-04-18 16:01:04 +01:00
- |
# 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 &&
2017-04-18 16:01:04 +01:00
(cd php-$MIN_PHP && ./configure --enable-sigchild --enable-pcntl && make -j2)
fi
- |
# php.ini configuration
2021-06-06 15:23:08 +01:00
(
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
2021-06-07 16:35:37 +01:00
(cd / && wget https://storage.googleapis.com/travis-ci-language-archives/php/binaries/ubuntu/18.04/x86_64/php-$PHP.tar.bz2 -O - | tar -xj) &
2021-06-06 15:23:08 +01:00
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
2020-05-30 19:30:09 +01:00
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
2020-12-03 00:55:58 +00:00
find ~/.phpenv -name xdebug.ini -delete
2021-06-06 15:23:08 +01:00
composer self-update
composer self-update --2
2017-04-18 16:01:04 +01:00
- |
# 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
2021-06-06 15:23:08 +01:00
if [[ $PHP != 8.* ]]; then
tfold ext.zookeeper tpecl zookeeper-0.7.2 zookeeper.so $INI
fi
2021-06-06 15:23:08 +01:00
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
2020-10-17 17:04:15 +01:00
tfold ext.igbinary tpecl igbinary-3.1.6 igbinary.so $INI
2020-10-26 00:24:11 +00:00
tfold ext.redis tpecl redis-5.2.3 redis.so $INI "no"
2021-06-07 16:05:04 +01:00
tfold ext.mongodb tpecl mongodb-1.10.0alpha1 mongodb.so $INI
done
2013-09-12 22:41:34 +01:00
install:
2019-08-02 15:07:32 +01:00
- |
# Install the phpunit-bridge from a PR if required
#
2019-08-04 09:28:30 +01:00
# To run a PR with a patched phpunit-bridge, first submit the patch for the
2019-08-02 15:07:32 +01:00
# 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
2019-08-02 15:07:32 +01:00
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
2019-08-05 09:06:54 +01:00
rm -rf .phpunit
2019-08-02 15:07:32 +01:00
fi
2017-04-18 16:01:04 +01:00
- |
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
if [[ ! $deps ]]; then
2020-05-01 11:47:45 +01:00
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
else
2017-04-18 16:01:04 +01:00
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) &&
2017-04-18 16:01:04 +01:00
mv composer.json composer.json.phpunit &&
mv composer.json.orig composer.json
fi
2019-08-02 15:07:32 +01:00
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
2017-04-18 16:01:04 +01:00
- |
2021-05-20 10:40:33 +01:00
# 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='^'
2021-05-20 10:40:33 +01:00
export SYMFONY_VERSION=$(echo "$SYMFONY_VERSIONS" | grep -FB1 /$SYMFONY_VERSION | head -n 1 | sed s/.//) &&
git fetch --depth=2 origin $SYMFONY_VERSION &&
2017-04-18 16:01:04 +01:00
git checkout -m FETCH_HEAD &&
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n' | sort)
2017-04-18 16:01:04 +01:00
fi
- |
# Skip the phpunit-bridge on bugfix-branches when $deps is empty
2021-05-20 10:40:33 +01:00
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='>=2.3'
else
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
fi
composer global require --no-progress --no-scripts --no-plugins symfony/flex
2017-04-18 16:01:04 +01:00
- |
2019-07-24 19:15:30 +01:00
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
2021-05-20 10:40:33 +01:00
[[ $deps = high && $SYMFONY_VERSION = *.4 ]] && export LEGACY=,legacy
2017-04-18 16:01:04 +01:00
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi
2017-05-18 13:41:01 +01:00
2017-04-18 16:01:04 +01:00
- |
# 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
2020-10-27 12:25:07 +00:00
tfold phpinfo phpinfo $PHP
done
2017-04-18 16:01:04 +01:00
- |
run_tests () {
set -e
export PHP=$1
2019-11-29 13:59:03 +00:00
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"
2019-09-23 08:36:04 +01:00
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)
2020-05-05 18:12:03 +01:00
tfold 'composer update' $COMPOSER_UP
2020-04-12 10:46:54 +01:00
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)
2021-05-20 10:40:33 +01:00
if [[ $COMPONENTS && $SYMFONY_VERSION = *.4 && $TRAVIS_PULL_REQUEST != false ]]; then
export FLIP='^'
SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}')
2019-09-21 08:43:36 +01:00
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
2019-09-21 08:43:36 +01:00
COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort)
2021-01-14 19:21:32 +00:00
(cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
2019-09-21 08:43:36 +01:00
[[ ! $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)
2017-04-18 16:01:04 +01:00
elif [[ $deps = low ]]; then
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
2017-04-18 16:01:04 +01:00
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
2017-04-18 16:01:04 +01:00
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
2019-12-16 13:25:15 +00:00
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
2017-07-04 12:07:48 +01:00
tfold src/Symfony/Component/Process.sigchild SYMFONY_DEPRECATIONS_HELPER=weak php-$MIN_PHP/sapi/cli/php ./phpunit --colors=always src/Symfony/Component/Process/
2017-04-18 16:01:04 +01:00
fi
fi
}
2019-09-23 08:36:04 +01:00
export -f run_tests
2013-09-12 22:41:34 +01:00
script:
2019-09-23 08:36:04 +01:00
echo $TRAVIS_PHP_VERSION $php_extra | xargs -n1 bash -c '(</dev/tty run_tests $0)' || false