Skip to content

Commit 8bbd8d9

Browse files
Add appveyor.yml for C.I. on Windows
1 parent cca29d8 commit 8bbd8d9

File tree

4 files changed

+187
-19
lines changed

4 files changed

+187
-19
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ phpunit.xml
55
composer.phar
66
package.tar
77
/packages.json
8+
/.phpunit

.travis.yml

+17-19
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ language: php
33
sudo: false
44

55
addons:
6-
apt_packages:
7-
- parallel
8-
- language-pack-fr-base
6+
apt_packages:
7+
- parallel
8+
- language-pack-fr-base
99

1010
matrix:
1111
include:
@@ -31,24 +31,22 @@ env:
3131
before_install:
3232
- composer self-update
3333
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi;
34-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi;
35-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
36-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
37-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi;
38-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi;
39-
# Build a standalone phpunit without symfony/yaml and that works around https://github.com/sebastianbergmann/phpunit-mock-objects/issues/223
40-
- (mkdir phpunit && cd phpunit && wget https://github.com/sebastianbergmann/phpunit/archive/4.7.zip && unzip 4.7.zip && cd phpunit-4.7 && composer remove --no-update symfony/yaml && composer require --prefer-source phpunit/phpunit-mock-objects '2.3.0')
41-
- export PHPUNIT="$(readlink -f ./phpunit/phpunit-4.7/phpunit) --colors=always"
42-
# Set the COMPOSER_ROOT_VERSION to the right version according to the branch being built
43-
- if [ "$TRAVIS_BRANCH" = "master" ]; then export COMPOSER_ROOT_VERSION=dev-master; else export COMPOSER_ROOT_VERSION="$TRAVIS_BRANCH".x-dev; fi;
34+
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then phpenv config-rm xdebug.ini; fi;
35+
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
36+
- if [[ "$TRAVIS_PHP_VERSION" =~ 5.[34] ]]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
37+
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi;
38+
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi;
39+
- ./phpunit install
40+
- export PHPUNIT="$(readlink -f ./phpunit)"
4441

4542
install:
43+
- if [ "$TRAVIS_BRANCH" = "master" ]; then export COMPOSER_ROOT_VERSION=dev-master; else export COMPOSER_ROOT_VERSION="$TRAVIS_BRANCH".x-dev; fi;
4644
- if [ "$deps" = "no" ]; then composer --prefer-source install; fi;
47-
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
48-
- if [ "$deps" != "no" ]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $components; fi;
45+
- COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
46+
- if [ "$deps" != "no" ]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi;
4947

5048
script:
51-
- if [ "$deps" = "no" ]; then echo "$components" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; $PHPUNIT --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
52-
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi;
53-
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
54-
- if [ "$deps" = "low" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
49+
- if [ "$deps" = "no" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; $PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
50+
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
51+
- if [ "$deps" = "high" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
52+
- if [ "$deps" = "low" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;

appveyor.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
build: false
2+
shallow_clone: true
3+
platform: x86
4+
clone_folder: c:\projects\symfony
5+
6+
environment:
7+
matrix:
8+
- PHP_EXT: 1
9+
- PHP_EXT: 0
10+
11+
cache:
12+
- c:\php -> appveyor.yml
13+
- .phpunit -> phpunit
14+
- vendor -> composer.json
15+
16+
init:
17+
- SET PATH=c:\php;%PATH%
18+
- SET COMPOSER_NO_INTERACTION=1
19+
- SET SYMFONY_DEPRECATIONS_HELPER=weak
20+
- SET PHP=1
21+
22+
install:
23+
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
24+
- cd c:\php
25+
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.4.43-nts-Win32-VC9-x86.zip
26+
- IF %PHP%==1 7z x php-5.4.43-nts-Win32-VC9-x86.zip -y > 7z.log
27+
- IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/ICU-51.2-dlls.zip
28+
- IF %PHP%==1 7z x ICU-51.2-dlls.zip -y > 7z.log
29+
- IF %PHP%==1 cd ext
30+
- IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/php_intl-3.0.0-5.4-nts-vc9-x86.zip
31+
- IF %PHP%==1 7z x php_intl-3.0.0-5.4-nts-vc9-x86.zip -y > 7z.log
32+
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apc/3.1.13/php_apc-3.1.13-5.4-nts-vc9-x86.zip
33+
- IF %PHP%==1 7z x php_apc-3.1.13-5.4-nts-vc9-x86.zip -y > 7z.log
34+
- IF %PHP%==1 cd ..
35+
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
36+
- appveyor DownloadFile https://getcomposer.org/composer.phar
37+
- copy php.ini-production php.ini /Y
38+
- echo date.timezone="UTC" >> php.ini
39+
- echo extension_dir=ext >> php.ini
40+
- echo extension=php_openssl.dll >> php.ini
41+
- IF %PHP_EXT%==1 echo extension=php_apc.dll >> php.ini
42+
- IF %PHP_EXT%==1 echo extension=php_intl.dll >> php.ini
43+
- IF %PHP_EXT%==1 echo extension=php_mbstring.dll >> php.ini
44+
- IF %PHP_EXT%==1 echo extension=php_fileinfo.dll >> php.ini
45+
- IF %PHP_EXT%==1 echo extension=php_pdo_sqlite.dll >> php.ini
46+
- cd c:\projects\symfony
47+
- php phpunit install
48+
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
49+
- composer update --prefer-dist --no-progress --ansi
50+
51+
test_script:
52+
- cd c:\projects\symfony
53+
- php phpunit symfony --exclude-group benchmark,intl-data

phpunit

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
error_reporting(-1);
5+
6+
$PHPUNIT_VERSION = 4.8;
7+
$PHPUNIT_DIR = __DIR__.'/.phpunit';
8+
9+
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
10+
# Build a standalone phpunit without symfony/yaml
11+
12+
$oldPwd = getcwd();
13+
mkdir($PHPUNIT_DIR);
14+
chdir($PHPUNIT_DIR);
15+
if (extension_loaded('openssl') && ini_get('allow_url_fopen')) {
16+
stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb'));
17+
} else {
18+
passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");
19+
}
20+
$zip = new ZipArchive();
21+
$zip->open("$PHPUNIT_VERSION.zip");
22+
$zip->extractTo(getcwd());
23+
$zip->close();
24+
chdir("phpunit-$PHPUNIT_VERSION");
25+
passthru("composer remove --no-update symfony/yaml");
26+
passthru("composer install --prefer-source --no-progress --ansi");
27+
chdir($oldPwd);
28+
}
29+
30+
$cmd = array_map('escapeshellarg', $argv);
31+
$exit = 0;
32+
33+
if (isset($argv[1]) && 'symfony' === $argv[1]) {
34+
# Find Symfony components in plain php for Windows portability
35+
36+
$finder = new RecursiveDirectoryIterator('src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
37+
$finder = new RecursiveIteratorIterator($finder);
38+
$finder->setMaxDepth(3);
39+
40+
array_shift($cmd);
41+
$cmd[0] = "php $PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit --colors=always";
42+
$procs = array();
43+
44+
foreach ($finder as $file => $fileInfo) {
45+
if ('phpunit.xml.dist' === $file) {
46+
$component = dirname($fileInfo->getPathname());
47+
48+
# Run phpunit tests in parallel
49+
50+
$c = escapeshellarg($component);
51+
52+
if ($proc = proc_open(implode(' ', $cmd)." $c > $c/phpunit.stdout 2> $c/phpunit.stderr", array(), $pipes)) {
53+
$procs[$component] = $proc;
54+
} else {
55+
$exit = 1;
56+
echo "\033[41mKO\033[0m $component\n\n";
57+
}
58+
}
59+
}
60+
61+
foreach ($procs as $component => $proc) {
62+
$procStatus = proc_close($proc);
63+
64+
foreach (array('out', 'err') as $file) {
65+
$file = "$component/phpunit.std$file";
66+
$h = fopen($file, 'rb');
67+
while (false !== $line = fgets($h)) {
68+
echo preg_replace_callback(
69+
'/\033\[[0-9]++(?:;[0-9]++)++m/',
70+
function ($m) {return str_replace(';', "m\033[", $m[0]);},
71+
$line
72+
);
73+
}
74+
fclose($h);
75+
unlink($file);
76+
}
77+
78+
if ($procStatus) {
79+
$exit = 1;
80+
echo "\033[41mKO\033[0m $component\n\n";
81+
} else {
82+
echo "\033[32mOK\033[0m $component\n\n";
83+
}
84+
}
85+
86+
} elseif (!isset($argv[1]) || 'install' !== $argv[1]) {
87+
# Run regular phpunit in a subprocess
88+
89+
$cmd[0] = "php $PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit --colors=always";
90+
91+
$errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.');
92+
if ($proc = proc_open(implode(' ', $cmd).' 2> '.escapeshellarg($errFile), array(1 => array('pipe', 'w')), $pipes)) {
93+
while (false !== $line = fgets($pipes[1])) {
94+
echo $line;
95+
}
96+
fclose($pipes[1]);
97+
$exit = proc_close($proc);
98+
99+
$h = fopen($errFile, 'rb');
100+
while (false !== $line = fgets($h)) {
101+
echo $line;
102+
}
103+
fclose($h);
104+
unlink($errFile);
105+
}
106+
107+
if (file_exists($component = array_pop($argv))) {
108+
if ($exit) {
109+
echo "\033[41mKO\033[0m $component\n\n";
110+
} else {
111+
echo "\033[32mOK\033[0m $component\n\n";
112+
}
113+
}
114+
}
115+
116+
exit($exit);

0 commit comments

Comments
 (0)