Skip to content

Commit 5afbc10

Browse files
authored
Run tests in parallel (#170)
* Run tests in parallel * Disable/enable some services * Do not install redis on PHP 5.6 * Run composer update * Install redis 3.0.0 * Enable redis extension but do not install * Bugfix * force instsall dependencies * Force install stuff * Fixes * Minors * Updated deps * Debub * Coverage fix * Reduce sleep * Because... you know * Sleep less * Applied changes from StyleCI * Applied changes from StyleCI
1 parent f47bdd8 commit 5afbc10

56 files changed

Lines changed: 193 additions & 243 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
language: php
2-
sudo: false
3-
2+
sudo: required
3+
dist: precise
44
env:
55
global:
66
- COVERAGE=false
7-
- TEST="./vendor/bin/phpunit"
87

98
branches:
109
except:
1110
- /^analysis-.*$/
1211
- /^patch-.*$/
1312

1413
matrix:
14+
fast_finish: true
1515
include:
16+
- php: 5.6
17+
env: deps="low"
18+
- php: 7.1
19+
env: deps="high"
1620
- php: 7.0
1721
env: COVERAGE=true
1822
- php: 7.1
1923
- php: 5.6
20-
fast_finish: true
2124

2225
services:
2326
- redis
@@ -29,20 +32,70 @@ addons:
2932
sources:
3033
- mongodb-3.2-precise
3134
packages:
35+
- parallel
3236
- mongodb-org-server
3337

3438
cache:
3539
directories:
3640
- "$HOME/.composer/cache"
3741

3842
before_install:
39-
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
40-
- if [[ $COVERAGE == true ]]; then TEST="$TEST --coverage-clover=coverage.xml"; fi
43+
- if [[ $COVERAGE == false ]]; then phpenv config-rm xdebug.ini || true; fi
4144
- mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d
4245
- ./build/php/all.sh
46+
- sleep 5 # To make sure all services installed and running
47+
- |
48+
# General configuration
49+
stty cols 120
50+
PHP=$TRAVIS_PHP_VERSION
51+
[ -d ~/.composer ] || mkdir ~/.composer
52+
export PHPUNIT=$(readlink -f ./phpunit)
53+
export PHPUNIT_X="$PHPUNIT --exclude-group benchmark"
54+
export PHPUNIT_COVERAGE="$PHPUNIT_X --coverage-clover=coverage.xml"
55+
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi --prefer-dist'
56+
57+
# tfold is a helper to create folded reports
58+
tfold () {
59+
title=$1
60+
fold=$(echo $title | sed -r 's/[^-_A-Za-z\d]+/./g')
61+
shift
62+
echo -e "travis_fold:start:$fold\\n\\e[1;34m$title\\e[0m"
63+
bash -xc "$*" 2>&1 &&
64+
echo "########################################" &&
65+
echo "########################################" &&
66+
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
67+
( echo -e "\\e[41mKO\\e[0m $title\\n" && exit 1 )
68+
}
69+
export -f tfold
70+
71+
COMPONENTS=$(find src -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n')
72+
73+
# php.ini configuration
74+
INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
75+
echo memory_limit = -1 >> $INI
76+
77+
install:
78+
- if [[ ! $skip ]]; then $COMPOSER_UP; fi
79+
- |
80+
run_tests () {
81+
set -e
82+
if [[ $skip ]]; then
83+
echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
84+
elif [[ $deps = high ]]; then
85+
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
86+
elif [[ $deps = low ]]; then
87+
sleep 3
88+
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
89+
elif [[ $COVERAGE == true ]]; then
90+
$PHPUNIT_COVERAGE
91+
else
92+
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
93+
tfold tty-group $PHPUNIT --group tty
94+
fi
95+
}
4396
4497
script:
45-
- ./build/runAllTests.sh
98+
- (run_tests)
4699

47100
after_success:
48101
- if [[ $COVERAGE == true ]]; then pip install --user codecov && codecov ; fi

build/php/5.5/Apc.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/php/5.5/Apcu.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/php/5.5/Memcache.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/php/5.5/Memcached.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

build/php/5.5/MongoDB.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

build/php/5.5/Redis.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

build/php/5.6/Apc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ echo "Add php.ini settings"
44
phpenv config-add ./build/php/apc.ini
55

66
echo "Install APC Adapter & APCu Adapter dependencies"
7-
yes '' | pecl install apcu-4.0.10
7+
yes '' | pecl install -f apcu-4.0.11

build/php/5.6/Apcu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ echo "Add php.ini settings"
44
phpenv config-add ./build/php/apc.ini
55

66
echo "Install APC Adapter & APCu Adapter dependencies"
7-
yes '' | pecl install apcu-4.0.10
7+
yes '' | pecl install -f apcu-4.0.10

build/php/5.6/Redis.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env bash
22

33
echo "Install redis"
4-
yes '' | pecl install redis-2.2.8
4+
yes '' | pecl install -f redis-2.2.8
5+
6+
#echo "Enable extension"
7+
#echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini

0 commit comments

Comments
 (0)