Skip to content
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

Update dependencies for building the PHAR #124

Merged
merged 6 commits into from Nov 3, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions .gitignore
@@ -1,5 +1,4 @@
/composer.phar
/box.phar
/vendor
/build
/schema.phar
/box.json
/build/
/vendor/
/*.phar
23 changes: 6 additions & 17 deletions .travis.yml
Expand Up @@ -18,35 +18,24 @@ before_install:
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- export PATH="$PATH:$HOME/.composer/vendor/bin"
- wget https://phar.phpunit.de/phpunit-6.5.phar
- composer global require humbug/php-scoper:dev-master#674e24d2b9e90b2f629dab7f30d5070e4d49d815
- wget -O phpunit.phar https://phar.phpunit.de/phpunit-6.5.phar
- if [[ $coverage = 1 ]]; then mkdir -p build/logs; fi
- if [[ $coverage = 1 ]]; then wget https://github.com/satooshi/php-coveralls/releases/download/v2.0.0/php-coveralls.phar; fi
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.10.0/php-cs-fixer.phar; fi
- if [[ $lint = 1 ]]; then composer global require --dev 'phpstan/phpstan:^0.10'; fi
- if [[ ! $deps && $TRAVIS_PHP_VERSION = "7.2" ]]; then curl -LSs https://box-project.github.io/box2/installer.php | php; fi;
- wget -O box.phar https://github.com/humbug/box/releases/download/3.1.3/box.phar
- export BOX_BIN=$(pwd)/box.phar
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we export BOX_BIN here because the shell script uses that environment variable. It's also conveniently allows one to switch to another bin locally, e.g. myself to switch to my current box binary directly from the humbug/box project.


install:
- if [[ $coverage = 1 ]]; then composer require --dev --no-update 'phpunit/php-code-coverage:^5.3'; fi
- if [[ ! $deps ]]; then composer update --prefer-dist --no-progress --no-suggest --ansi; fi
- if [[ $deps = 'low' ]]; then composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi; fi

script:
- if [[ $coverage = 1 ]]; then phpdbg -qrr phpunit-6.5.phar --coverage-clover build/logs/clover.xml; else php phpunit-6.5.phar; fi
- if [[ $coverage = 1 ]]; then phpdbg -qrr phpunit.phar --coverage-clover build/logs/clover.xml; else php phpunit.phar; fi
- if [[ $lint = 1 ]]; then php php-cs-fixer.phar fix --dry-run --diff --no-ansi; fi
- if [[ $lint = 1 ]]; then phpstan analyse -l5 --ansi -c phpstan.neon src; fi
- |
if [[ ! $deps && $TRAVIS_PHP_VERSION = "7.2" ]]; then
composer install --no-dev --prefer-dist --classmap-authoritative --no-progress --no-suggest --ansi;
~/.composer/vendor/bin/php-scoper add-prefix --output-dir=build/schema-generator;
cp composer.json build/schema-generator/
composer --working-dir=build/schema-generator dump-autoload --classmap-authoritative --no-dev;
php -d phar.readonly=0 box.phar build;
php schema.phar generate-types tmp/ tests/e2e/schema.yml;
diff tests/e2e/src/AppBundle/Entity/Person.php tmp/AppBundle/Entity/Person.php;
diff tests/e2e/src/AppBundle/Entity/PostalAddress.php tmp/AppBundle/Entity/PostalAddress.php;
diff tests/e2e/src/AppBundle/Entity/Thing.php tmp/AppBundle/Entity/Thing.php;
fi;
- if [[ $lint = 1 ]]; then phpstan analyse -l5 --ansi src; fi
- if [[ ! $deps && $TRAVIS_PHP_VERSION = "7.2" ]]; then ./bin/compile; fi

after_success:
- if [[ $coverage = 1 ]]; then travis_retry php php-coveralls.phar; fi
Expand Down
11 changes: 11 additions & 0 deletions bin/compile
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -eox pipefail

php $BOX_BIN compile;

php schema.phar generate-types tmp/ tests/e2e/schema.yml;

diff tests/e2e/src/AppBundle/Entity/Person.php tmp/AppBundle/Entity/Person.php;
diff tests/e2e/src/AppBundle/Entity/PostalAddress.php tmp/AppBundle/Entity/PostalAddress.php;
diff tests/e2e/src/AppBundle/Entity/Thing.php tmp/AppBundle/Entity/Thing.php;
31 changes: 0 additions & 31 deletions box.json

This file was deleted.

33 changes: 33 additions & 0 deletions box.json.dist
@@ -0,0 +1,33 @@
{
"banner": [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was no banner previously, up to you if you want one or if you want to remove it

"This file is part of the API Platform project.",
"",
"(c) Kévin Dunglas <dunglas@gmail.com>",
"",
"For the full copyright and license information, please view the LICENSE",
"file that was distributed with this source code."
],

"directories-bin": [
"data/",
"templates/"
],
"files": [
"vendor/friendsofphp/php-cs-fixer/tests/TestCase.php",
"vendor/twig/twig/lib/Twig/Test.php"
],
"directories": [
"vendor/friendsofphp/php-cs-fixer/tests/Test"
],
"force-autodiscovery": true,

"compression": "GZ",
"compactors": [
"Herrera\\Box\\Compactor\\Json",
"Herrera\\Box\\Compactor\\Php"
],

"git-version": "package_version",

"output": "schema.phar"
}
30 changes: 2 additions & 28 deletions scoper.inc.php
Expand Up @@ -11,36 +11,10 @@

declare(strict_types=1);

use Isolated\Symfony\Component\Finder\Finder;
// TODO: This file is ignored until the PHP-Scoper compactor is enabled in the Box config. PHP-Scoper is disabled
// right now due to EasyRDF using a legacy PSR-0 configuration unsupported by PHP-Scoper.

return [
'finders' => [
Finder::create()->files()
->in('src')
->in('data')
->in('templates'),
Finder::create()
->files()
->ignoreVCS(true)
->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/')
->exclude([
'doc',
'test',
'test_old',
'tests',
'Test',
'Tests',
])
->in('vendor'),
Finder::create()->append([
'bin/schema',
'composer.json',
]),
Finder::create()->append([
'vendor/friendsofphp/php-cs-fixer/tests/Test',
'vendor/friendsofphp/php-cs-fixer/tests/TestCase.php',
]),
],
'whitelist' => [
'ApiPlatform\Core\Annotation\ApiProperty',
'ApiPlatform\Core\Annotation\ApiResource',
Expand Down