Skip to content

[travis/appveyor] Wire simple-phpunit #19917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/build-packages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

if (4 > $_SERVER['argc']) {
echo "Usage: branch version dir1 dir2 ... dirN\n";
exit(1);
}
chdir(dirname(__DIR__));

$dirs = $_SERVER['argv'];
array_shift($dirs);
$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs))));
$version = array_shift($dirs);

$packages = array();
$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;

foreach ($dirs as $k => $dir) {
if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) {
if ($exitStatus) {
exit($exitStatus);
}
unset($dirs[$k]);
continue;
}
echo "$dir\n";

$json = ltrim(file_get_contents($dir.'/composer.json'));
if (null === $package = json_decode($json)) {
passthru("composer validate $dir/composer.json");
exit(1);
}

$package->repositories = array(array(
'type' => 'composer',
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
));
if (false === strpos($json, "\n \"repositories\": [\n")) {
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
file_put_contents($dir.'/composer.json', $json);
}
passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");

$package->version = $version.'.999';
$package->dist['type'] = 'tar';
$package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar";

$packages[$package->name][$package->version] = $package;

$versions = file_get_contents('https://packagist.org/packages/'.$package->name.'.json');
$versions = json_decode($versions);

foreach ($versions->package->versions as $v => $package) {
$packages[$package->name] += array($v => $package);
}
}

file_put_contents('packages.json', json_encode(compact('packages'), $flags));

if ($dirs) {
$json = ltrim(file_get_contents('composer.json'));
if (null === $package = json_decode($json)) {
passthru("composer validate $dir/composer.json");
exit(1);
}

$package->repositories = array(array(
'type' => 'composer',
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
));
if (false === strpos($json, "\n \"repositories\": [\n")) {
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
file_put_contents('composer.json', $json);
}
}
54 changes: 0 additions & 54 deletions .github/travis.php

This file was deleted.

17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,27 @@ before_install:
- if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = ldap.so >> $INI_FILE; fi
- if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
- if [[ ! $skip ]]; then [ -d ~/.composer ] || mkdir ~/.composer; cp .composer/* ~/.composer/; fi
- if [[ ! $skip ]]; then ./phpunit install; fi
- if [[ ! $skip ]]; then export PHPUNIT=$(readlink -f ./phpunit); fi

install:
- if [[ ! $skip && $deps ]]; then cp composer.json composer.json.orig; fi
- if [[ ! $skip && $deps ]]; then echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json; fi
- if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
- if [[ ! $skip && $deps ]]; then git fetch origin $TRAVIS_BRANCH && php .github/travis.php FETCH_HEAD $TRAVIS_BRANCH $COMPONENTS; fi
- if [[ ! $skip && $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH $COMPONENTS; fi
- if [[ ! $skip && $deps ]]; then mv composer.json composer.json.phpunit; mv composer.json.orig composer.json; fi
- if [[ ! $skip && ! $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH src/Symfony/Bridge/PhpUnit; fi
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); ./phpunit install; fi
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
- if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
- if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi
- if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi
- if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
- if [[ ! $skip && $deps ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi
- if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
- if [[ ! $skip ]]; then composer update; fi
- if [[ ! $skip ]]; then COMPOSER_ROOT_VERSION= ./phpunit install; fi
- if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi

script:
- if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi
Expand Down
10 changes: 6 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,20 @@ install:
- echo curl.cainfo=c:\php\cacert.pem >> php.ini-max
- copy /Y php.ini-max php.ini
- cd c:\projects\symfony
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.0/composer.phar)
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.1/composer.phar)
- php composer.phar self-update
- copy /Y .composer\* %APPDATA%\Composer\
- php phpunit install
- php .github/build-packages.php "HEAD^" %APPVEYOR_REPO_BRANCH% src\Symfony\Bridge\PhpUnit
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
- php composer.phar update --no-progress --ansi
- SET COMPOSER_ROOT_VERSION=
- php phpunit install

test_script:
- cd c:\projects\symfony
- SET X=0
- copy /Y c:\php\php.ini-min c:\php\php.ini
- php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
- copy /Y c:\php\php.ini-max c:\php\php.ini
- php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
- exit %X%
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"monolog/monolog": "~1.11",
"ircmaxell/password-compat": "~1.0",
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
"symfony/phpunit-bridge": "~3.2",
"egulias/email-validator": "~1.2,>=1.2.1"
},
"autoload": {
Expand All @@ -99,11 +100,6 @@
"**/Tests/"
]
},
"autoload-dev": {
"psr-4": {
"Symfony\\Bridge\\PhpUnit\\": "src/Symfony/Bridge/PhpUnit/"
}
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
Expand Down
Loading