This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests fixes #23 added appveyor
- Loading branch information
danielbannert
committed
Jul 25, 2018
1 parent
ebbb58d
commit a3681f1
Showing
10 changed files
with
310 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
build: false | ||
platform: | ||
- x64 | ||
- x86 | ||
clone_depth: 1 | ||
clone_folder: C:\projects\discovery | ||
|
||
environment: | ||
matrix: | ||
- dependencies: basic | ||
PHP_VERSION: 7.2 | ||
- dependencies: high | ||
PHP_VERSION: 7.2 | ||
- dependencies: lowest | ||
PHP_VERSION: 7.2 | ||
|
||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
- dependencies: lowest | ||
PHP_VERSION: 7.2 | ||
|
||
services: | ||
- memcached | ||
|
||
# cache is cleared when linked file is modified | ||
cache: | ||
# Cache chocolatey packages | ||
- C:\ProgramData\chocolatey\bin -> .appveyor.yml | ||
- C:\ProgramData\chocolatey\lib -> .appveyor.yml | ||
# Cache php install | ||
- C:\tools\php -> .appveyor.yml | ||
# Cache composer | ||
- C:\projects\discovery\vendor -> composer.json | ||
- '%LOCALAPPDATA%\Composer\files -> composer.json' | ||
|
||
init: | ||
- SET PHP=1 | ||
- SET PATH=C:\Program Files\OpenSSL;C:\tools\php;%PATH% | ||
- SET ANSICON=121x90 (121x90) | ||
- SET COMPOSER_NO_INTERACTION=1 | ||
- SET COMPOSER_UP=php composer.phar update --no-interaction --prefer-dist --no-progress --profile --no-suggest --ansi | ||
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f | ||
|
||
install: | ||
# If there is a newer build queued for the same PR, cancel this one. | ||
# The AppVeyor 'rollout builds' option is supposed to serve the same | ||
# purpose but it is problematic because it tends to cancel builds pushed | ||
# directly to master instead of just PR builds (or the converse). | ||
# credits: JuliaLang developers. | ||
- ps: if ($Env:APPVEYOR_PULL_REQUEST_NUMBER -and $Env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` | ||
https://ci.appveyor.com/api/projects/$Env:APPVEYOR_ACCOUNT_NAME/$Env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` | ||
Where-Object pullRequestId -eq $Env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` | ||
throw "There are newer queued builds for this pull request, failing early." } | ||
# Install PHP | ||
- IF EXIST C:\tools\php (SET PHP=0) | ||
- IF %PHP%==1 appveyor DownloadFile "https://raw.githubusercontent.com/prisis/ps-install-php/master/Install-PHP.ps1" | ||
- ps: if (-not (Test-Path C:\tools\php)) {.\Install-PHP.ps1 -InstallPath C:\tools\php -Version $Env:PHP_VERSION -Highest -Arch $Env:PLATFORM -Extensions mbstring,intl,openssl,memcache,fileinfo,pdo_sqlite,curl,sodium} | ||
# PHP settings and extensions | ||
- IF %PHP%==1 cd C:\tools\php | ||
- IF %PHP%==1 echo zend_extension=php_opcache.dll >> php.ini | ||
- IF %PHP%==1 echo max_execution_time=1200 >> php.ini | ||
- IF %PHP%==1 echo date.timezone="Europe/Berlin" >> php.ini | ||
- IF %PHP%==1 echo opcache.enable_cli=1 >> php.ini | ||
- IF %PHP%==1 echo apc.enable_cli=1 >> php.ini | ||
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) | ||
- cd C:\projects\discovery | ||
- php -r "readfile('https://getcomposer.org/installer');" | php | ||
# Matrix | ||
- php composer.phar global require hirak/prestissimo | ||
- IF %dependencies%==basic appveyor-retry %COMPOSER_UP% | ||
- IF %dependencies%==lowest appveyor-retry %COMPOSER_UP% --prefer-lowest --prefer-stable | ||
- IF %dependencies%==high appveyor-retry %COMPOSER_UP% | ||
- cd build/appveyor | ||
- appveyor DownloadFile https://cdn.rawgit.com/prisis/43a2a7b137998ac92e24ee4daaa8e296/raw/681b89b8e156750de46558ead661509c468fb9a2/try_catch.sh | ||
|
||
test_script: | ||
- cd C:\projects\discovery | ||
- sh ./build/appveyor/script.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
source ./build/appveyor/try_catch.sh | ||
|
||
for f in ./src/*; do | ||
if [[ -d "$f" && ! -L "$f" ]]; then | ||
TYPE="$(basename "$f")"; | ||
|
||
if [[ "$TYPE" = "Common" ]]; then | ||
TESTSUITE="Narrowspark Discovery Common Test Suite"; | ||
elif [[ "$TYPE" = "Discovery" ]]; then | ||
TESTSUITE="Narrowspark Discovery Test Suite"; | ||
fi | ||
|
||
echo ""; | ||
echo -e "$TESTSUITE"; | ||
echo ""; | ||
|
||
try | ||
sh vendor/bin/phpunit --verbose -c ./phpunit.xml.dist --testsuite="$TESTSUITE"; | ||
catch || { | ||
exit 1 | ||
} | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace Narrowspark\Discovery\Prefetcher; | ||
|
||
use Composer\Cache as BaseComposerCache; | ||
|
||
/** | ||
* Ported from symfony flex, see original. | ||
* | ||
* @see https://github.com/symfony/flex/blob/master/src/Cache.php | ||
* | ||
* (c) Nicolas Grekas <[email protected]> | ||
*/ | ||
class Cache extends BaseComposerCache | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private static $lowestTags = [ | ||
'symfony/symfony' => [ | ||
'version' => 'v3.4.0', | ||
'replaces' => [ | ||
'symfony/asset', | ||
'symfony/browser-kit', | ||
'symfony/cache', | ||
'symfony/config', | ||
'symfony/console', | ||
'symfony/css-selector', | ||
'symfony/dependency-injection', | ||
'symfony/debug', | ||
'symfony/debug-bundle', | ||
'symfony/doctrine-bridge', | ||
'symfony/dom-crawler', | ||
'symfony/dotenv', | ||
'symfony/event-dispatcher', | ||
'symfony/expression-language', | ||
'symfony/filesystem', | ||
'symfony/finder', | ||
'symfony/form', | ||
'symfony/framework-bundle', | ||
'symfony/http-foundation', | ||
'symfony/http-kernel', | ||
'symfony/inflector', | ||
'symfony/intl', | ||
'symfony/ldap', | ||
'symfony/lock', | ||
'symfony/messenger', | ||
'symfony/monolog-bridge', | ||
'symfony/options-resolver', | ||
'symfony/process', | ||
'symfony/property-access', | ||
'symfony/property-info', | ||
'symfony/proxy-manager-bridge', | ||
'symfony/routing', | ||
'symfony/security', | ||
'symfony/security-core', | ||
'symfony/security-csrf', | ||
'symfony/security-guard', | ||
'symfony/security-http', | ||
'symfony/security-bundle', | ||
'symfony/serializer', | ||
'symfony/stopwatch', | ||
'symfony/templating', | ||
'symfony/translation', | ||
'symfony/twig-bridge', | ||
'symfony/twig-bundle', | ||
'symfony/validator', | ||
'symfony/var-dumper', | ||
'symfony/web-link', | ||
'symfony/web-profiler-bundle', | ||
'symfony/web-server-bundle', | ||
'symfony/workflow', | ||
'symfony/yaml', | ||
], | ||
], | ||
]; | ||
|
||
/** | ||
* @param string $file | ||
* | ||
* @return bool|string | ||
*/ | ||
public function read($file) | ||
{ | ||
$content = parent::read($file); | ||
|
||
if (0 === \mb_strpos($file, 'provider-symfony$')) { | ||
$content = \json_encode($this->removeLegacyTags(\json_decode($content, true))); | ||
} | ||
|
||
return $content; | ||
} | ||
|
||
/** | ||
* @param array $data | ||
* | ||
* @return array | ||
*/ | ||
public function removeLegacyTags(array $data): array | ||
{ | ||
foreach (self::$lowestTags as $lowestPackage => $settings) { | ||
$lowestVersion = $settings['version']; | ||
$replacedPackages = $settings['replaces']; | ||
|
||
if (! isset($data['packages'][$lowestPackage][$lowestVersion])) { | ||
continue; | ||
} | ||
|
||
foreach ($data['packages'] as $package => $versions) { | ||
if ($package !== $lowestPackage && ! \in_array($package, $replacedPackages, true)) { | ||
continue; | ||
} | ||
|
||
foreach ($versions as $version => $composerJson) { | ||
if (\version_compare($version, $lowestVersion, '<')) { | ||
unset($data['packages'][$package][$version]); | ||
} | ||
} | ||
} | ||
|
||
break; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace Narrowspark\Discovery\Prefetcher; | ||
|
||
use Composer\Config; | ||
use Composer\EventDispatcher\EventDispatcher; | ||
use Composer\IO\IOInterface; | ||
use Composer\Repository\ComposerRepository as BaseComposerRepository; | ||
use Composer\Util\RemoteFilesystem; | ||
|
||
/** | ||
* Ported from symfony flex, see original. | ||
* | ||
* @see https://github.com/symfony/flex/blob/master/src/Cache.php | ||
* | ||
* (c) Nicolas Grekas <[email protected]> | ||
*/ | ||
class TruncatedComposerRepository extends BaseComposerRepository | ||
{ | ||
public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, RemoteFilesystem $rfs = null) | ||
{ | ||
parent::__construct($repoConfig, $io, $config, $eventDispatcher, $rfs); | ||
$this->cache = new Cache($io, $config->get('cache-repo-dir') . '/' . \preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$'); | ||
} | ||
|
||
protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false) | ||
{ | ||
$data = parent::fetchFile($filename, $cacheKey, $sha256, $storeLastModifiedTime); | ||
|
||
return $this->cache->removeLegacyTags($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.