Skip to content

Commit

Permalink
Rework build & e2e steps (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Sep 22, 2017
1 parent 944618d commit 6c9c0e9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 38 deletions.
89 changes: 52 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BOX=vendor-bin/box/vendor/bin/box
PHPUNIT=vendor/bin/phpunit
PHPSCOPER=bin/php-scoper.phar
BLACKFIRE=blackfire

.DEFAULT_GOAL := help
.PHONY: build test tu tc e2e tb
Expand All @@ -14,27 +15,36 @@ help:
## Build
##---------------------------------------------------------------------------

clean: ## Clean all created artifacts
clean:
rm -f bin/php-scoper.phar
rm -rf build
rm -rf vendor-back
rm -rf vendor
rm -rf vendor/box/vendor

build: ## Build the PHAR
build: src vendor vendor-bin/box/vendor
build:
# Cleanup existing artefacts
rm -f bin/php-scoper.phar
rm -rf build

# Remove unnecessary packages
mv -f vendor vendor-back
composer install --no-dev --prefer-dist

# Prefixes the code to be bundled
php -d zend.enable_gc=0 bin/php-scoper add-prefix --force
php -d zend.enable_gc=0 bin/php-scoper add-prefix --output-dir=build/php-scoper --force

# Re-dump the loader to account for the prefixing
# and optimize the loader
composer dump-autoload -d build --classmap-authoritative
composer dump-autoload --working-dir=build/php-scoper --classmap-authoritative --no-dev

# Build the PHAR
php -d zend.enable_gc=0 -d phar.readonly=0 $(BOX) build $(CONFIG)

# Install back all the dependencies
composer install
mv -f vendor-back vendor


##
Expand All @@ -53,46 +63,48 @@ tc: vendor
phpdbg -qrr -d zend.enable_gc=0 $(PHPUNIT) --coverage-html=dist/coverage --coverage-text

e2e: ## Run end-to-end tests
e2e: bin/scoper.phar fixtures/set005/vendor fixtures/set011/vendor
# Set004
php -d zend.enable_gc=0 $(PHPSCOPER) add-prefix fixtures/set004 -o build/set004 -f
composer -d=build/set004 dump-autoload
php -d zend.enable_gc=0 -d phar.readonly=0 $(BOX) build -c build/set004/box.json.dist
e2e: e2e_004 e2e_005

php build/set004/bin/greet.phar > build/output
diff fixtures/set004/expected-output build/output
e2e_004: ## Run end-to-end tests for the fixture set 004
e2e_004: bin/scoper.phar
php -d zend.enable_gc=0 $(PHPSCOPER) add-prefix --working-dir=fixtures/set004 --output-dir=../../build/set004 --force
composer --working-dir=build/set004 dump-autoload
php -d zend.enable_gc=0 -d phar.readonly=0 $(BOX) build -c build/set004/box.json.dist

php build/set004/bin/greet.phar > build/set004/output
diff fixtures/set004/expected-output build/set004/output

# Set005
php -d zend.enable_gc=0 $(PHPSCOPER) add-prefix fixtures/set005 -o build/set005 -f
composer -d=build/set005 dump-autoload
e2e_005: ## Run end-to-end tests for the fixture set 005
e2e_005: bin/scoper.phar fixtures/set005/vendor
php -d zend.enable_gc=0 $(PHPSCOPER) add-prefix --working-dir=fixtures/set005 --output-dir=../../build/set005 --force
composer --working-dir=build/set005 dump-autoload
php -d zend.enable_gc=0 -d phar.readonly=0 $(BOX) build -c build/set005/box.json.dist

php build/set005/bin/greet.phar > build/output
diff fixtures/set005/expected-output build/output
php build/set005/bin/greet.phar > build/set005/output
diff fixtures/set005/expected-output build/set005/output

e2e_011: ## Run end-to-end tests for the fixture set 011
e2e_011: bin/scoper.phar
php -d zend.enable_gc=0 $(PHPSCOPER) add-prefix --working-dir=fixtures/set011 --output-dir=../../build/set011 --force
cp -R fixtures/set011/tests build/set011/
composer --working-dir=build/set011 dump-autoload
php -d zend.enable_gc=0 -d phar.readonly=0 $(BOX) build -c build/set011/box.json.dist

# Set0011
# Skipped for now
# # TMP: replace bin/php-scoper by $(PHPSCOPER)
# php -d zend.enable_gc=0 bin/php-scoper add-prefix -o build/set011 -f -c fixtures/set011/scoper.inc.php -p PhpScoper598627d709dd4
# # Leave the `tests` autoloading of the `composer.json` intact
# cp -f build/set011/composer.json.dist build/set011/composer.json
# composer -d=build/set011 dump-autoload
# php -d zend.enable_gc=0 -d phar.readonly=0 $(BOX) build -c build/set011/box.json.dist
# cp -R fixtures/set011/tests build/set011
#
# php build/set011/bin/greet.phar > build/output
# diff fixtures/set011/expected-output build/output
php build/set011/bin/greet.phar > build/set011/output
diff fixtures/set011/expected-output build/set011/output

tb: ## Run Blackfire profiling
tb: vendor
rm -rf build
rm -rf vendor-bin/*/vendor

mv -f vendor tmp-back
composer install --no-dev --prefer-dist --classmap-authoritative
blackfire --new-reference run php -d zend.enable_gc=0 bin/php-scoper add-prefix --force --quiet
composer install

$(BLACKFIRE) --new-reference run php -d zend.enable_gc=0 bin/php-scoper add-prefix --output-dir=build/php-scoper --force --quiet

rm -rf vendor
mv -f tmp-back vendor


##
Expand All @@ -106,16 +118,19 @@ vendor-bin/box/vendor: vendor-bin/box/composer.lock
composer bin all install

fixtures/set005/vendor: fixtures/set005/composer.lock
composer -d=fixtures/set005 install
composer --working-dir=fixtures/set005 install

fixtures/set011/vendor: fixtures/set011/composer.lock
composer -d=fixtures/set011 install
composer --working-dir=fixtures/set011 install

composer.lock: composer.json
@echo compose.lock is not up to date.
@echo composer.lock is not up to date.

fixtures/set005/composer.lock: fixtures/set005/composer.json
@echo fixtures/set005/composer.lock is not up to date.

vendor-bin/box/composer.lock: vendor-bin/box/composer.json
@echo compose.lock is not up to date.
fixtures/set011/composer.lock: fixtures/set011/composer.json
@echo fixtures/set011/composer.lock is not up to date.

bin/scoper.phar: bin/php-scoper src vendor scoper.inc.php
$(MAKE) CONFIG="-c box.json.dist" build
bin/scoper.phar: bin/php-scoper src vendor-bin/box/vendor scoper.inc.php
$(MAKE) build
2 changes: 1 addition & 1 deletion box.json.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"base-path": "build",
"base-path": "build/php-scoper",
"chmod": "0755",
"main": "bin/php-scoper",
"output": "bin/php-scoper.phar",
Expand Down
1 change: 1 addition & 0 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function (string $className): bool {
Finder::create()->append([
'bin/php-scoper',
'composer.json',
'box.json.dist',
]),
],
'patchers' => [
Expand Down

0 comments on commit 6c9c0e9

Please sign in to comment.