Skip to content

Commit 3cfa559

Browse files
Add appveyor.yml for C.I. on Windows
1 parent cca29d8 commit 3cfa559

File tree

4 files changed

+190
-14
lines changed

4 files changed

+190
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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

Lines changed: 12 additions & 14 deletions
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:
@@ -36,19 +36,17 @@ before_install:
3636
- 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;
3737
- 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;
3838
- 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;
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

Lines changed: 53 additions & 0 deletions
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

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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+
do {
63+
usleep(300000);
64+
$procStatus = proc_get_status($proc);
65+
} while ($procStatus['running']);
66+
67+
proc_close($proc);
68+
69+
foreach (array('out', 'err') as $file) {
70+
$file = "$component/phpunit.std$file";
71+
$h = fopen($file, 'rb');
72+
while (false !== $line = fgets($h)) {
73+
echo preg_replace_callback(
74+
'/\033\[[0-9]++(?:;[0-9]++)++m/',
75+
function ($m) {return str_replace(';', "m\033[", $m[0]);},
76+
$line
77+
);
78+
}
79+
fclose($h);
80+
unlink($file);
81+
}
82+
83+
if ($procStatus['exitcode'] || $procStatus['signaled'] || $procStatus['stopped']) {
84+
$exit = 1;
85+
echo "\033[41mKO\033[0m $component\n\n";
86+
} else {
87+
echo "\033[32mOK\033[0m $component\n\n";
88+
}
89+
}
90+
91+
} elseif (!isset($argv[1]) || 'install' !== $argv[1]) {
92+
# Run regular phpunit in a subprocess
93+
94+
$cmd[0] = "php $PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit --colors=always";
95+
96+
$errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.');
97+
if ($proc = proc_open(implode(' ', $cmd).' 2> '.escapeshellarg($errFile), array(1 => array('pipe', 'w')), $pipes)) {
98+
while (false !== $line = fgets($pipes[1])) {
99+
echo $line;
100+
}
101+
fclose($pipes[1]);
102+
$procStatus = proc_get_status($proc);
103+
proc_close($proc);
104+
105+
$exit = $procStatus['exitcode'] || $procStatus['signaled'] || $procStatus['stopped'] ? 1 : 0;
106+
107+
$h = fopen($errFile, 'rb');
108+
while (false !== $line = fgets($h)) {
109+
echo $line;
110+
}
111+
fclose($h);
112+
unlink($errFile);
113+
}
114+
115+
if (file_exists($component = array_pop($argv))) {
116+
if ($exit) {
117+
echo "\033[41mKO\033[0m $component\n\n";
118+
} else {
119+
echo "\033[32mOK\033[0m $component\n\n";
120+
}
121+
}
122+
}
123+
124+
exit($exit);

0 commit comments

Comments
 (0)