Skip to content

Commit

Permalink
[Scoper] Rollback attribute exclude, add specify PHP80_BIN_PATH env w…
Browse files Browse the repository at this point in the history
…hen run ./full_build.sh locally (#1748)

* [Scoper] Rollback attribute exclude, add specify PHP80_BIN_PATH env when run ./full_build.sh locally

* roll;
  • Loading branch information
samsonasik committed Jan 31, 2022
1 parent 5b23064 commit 412043b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
7 changes: 6 additions & 1 deletion build/build-rector-scoped.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ note "Running scoper to $RESULT_DIRECTORY"
wget https://github.com/humbug/php-scoper/releases/download/0.14.0/php-scoper.phar -N --no-verbose

# Work around possible PHP memory limits
php -d memory_limit=-1 php-scoper.phar add-prefix bin config src packages rules vendor composer.json --output-dir "../$RESULT_DIRECTORY" --config scoper.php --force --ansi --working-dir "$BUILD_DIRECTORY"

if test -z ${PHP80_BIN_PATH+y}; then
php -d memory_limit=-1 php-scoper.phar add-prefix bin config src packages rules vendor composer.json --output-dir "../$RESULT_DIRECTORY" --config scoper.php --force --ansi --working-dir "$BUILD_DIRECTORY";
else
echo "scoping with specify PHP80_BIN_PATH env";
$PHP80_BIN_PATH -d memory_limit=-1 php-scoper.phar add-prefix bin config src packages rules vendor composer.json --output-dir "../$RESULT_DIRECTORY" --config scoper.php --force --ansi --working-dir "$BUILD_DIRECTORY";
fi

# note "Dumping Composer Autoload"
composer dump-autoload --working-dir "$RESULT_DIRECTORY" --ansi --classmap-authoritative --no-dev
Expand Down
41 changes: 26 additions & 15 deletions full_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,43 @@ rm rector.php
cp ../build/target-repository/bootstrap.php .
cp ../preload.php .

# allow to specify PHP71_BIN_PATH env
# Check php 7.1 can be used locally with PHP71_BIN_PATH env
# Prefixing build only works on php < 8.0, can be used locally with PHP80_BIN_PATH env

#
# usage:
#
# export PHP71_BIN_PATH=/opt/homebrew/Cellar/php@7.1/7.1.33_4/bin/php && sh ./full_build.sh
# export PHP71_BIN_PATH=/opt/homebrew/Cellar/php@7.1/7.1.33_4/bin/php PHP80_BIN_PATH=/opt/homebrew/Cellar/php@8.0/8.0.14/bin/php && sh ./full_build.sh
#
if test -z ${PHP71_BIN_PATH+y}; then
eval "bin/rector list --ansi";
bin/rector list --ansi;
else
eval "$PHP71_BIN_PATH bin/rector list --ansi";
echo "verify downgraded rector with specify PHP71_BIN_PATH env";
$PHP71_BIN_PATH bin/rector list --ansi;
fi

cd ..
rm -rf rector-build

# Prefixed build only works on PHP < 8.1 now, so only able to run on CI.
# We may need a way to specify PHP path on run build/build-rector-scoped.sh, eg:
#
# /path/to/php/bin/php build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
#
#
# sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
# cd rector-prefixed-downgraded
# cp ../build/target-repository/bootstrap.php .
# cp ../preload.php .
# bin/rector list --ansi
# bin/rector process vendor/symfony/string/Slugger/ --dry-run

# cd ..
# rm -rf rector-prefixed-downgraded
sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
cd rector-prefixed-downgraded
cp ../build/target-repository/bootstrap.php .
cp ../preload.php .

if test -z ${PHP71_BIN_PATH+y}; then
bin/rector list --ansi;
bin/rector process vendor/symfony/string/Slugger/ --dry-run;
else
echo "verify scoped rector with specify PHP71_BIN_PATH env";
$PHP71_BIN_PATH bin/rector list --ansi;
$PHP71_BIN_PATH bin/rector process vendor/symfony/string/Slugger/ --dry-run;
fi

cd ..

rm -rf rector-prefixed-downgraded
rm -rf rector-build
1 change: 0 additions & 1 deletion scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
'Symplify\ComposerJsonManipulator\ValueObject\ComposerJson',
],
'packages/Testing/PHPUnit/AbstractTestCase.php' => ['PHPUnit\Framework\TestCase'],
'vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php' => ['Attribute'],
];
// see https://github.com/humbug/php-scoper
return [
Expand Down

0 comments on commit 412043b

Please sign in to comment.