-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3cd614
commit 8cb7d54
Showing
8 changed files
with
214 additions
and
0 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,66 @@ | ||
name: Downgraded Release | ||
|
||
on: | ||
push: | ||
tags: | ||
# avoid infinite looping, skip tags that ends with ".72" | ||
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches | ||
- '*' | ||
|
||
jobs: | ||
downgrade_release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: "actions/checkout@v3" | ||
with: | ||
token: ${{ secrets.WORKFLOWS_TOKEN }} | ||
|
||
- | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: 8.2 | ||
coverage: none | ||
|
||
# invoke patches | ||
- run: composer install --ansi | ||
|
||
# but no dev packages | ||
- run: composer update --no-dev --ansi | ||
|
||
# get rector to "rector-local" directory, to avoid downgrading itself in the /vendor | ||
- run: mkdir rector-local | ||
- run: composer require rector/rector --working-dir rector-local --ansi | ||
|
||
# downgrade to PHP 7.2 | ||
- run: rector-local/vendor/bin/rector process bin src vendor --config build/rector-downgrade-php-72.php --ansi | ||
|
||
# clear the dev files | ||
- run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig | ||
|
||
# prefix and scope | ||
- run: sh prefix-code.sh | ||
|
||
# copy PHP 7.2 composer + workflows | ||
- run: cp -r build/target-repository/. . | ||
|
||
# clear the dev files | ||
- run: rm -rf build prefix-code.sh full-tool-build.sh scoper.php rector.php rector-local | ||
|
||
# setup git user | ||
- | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "GitHub Action" | ||
# publish to the same repository with a new tag | ||
# see https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/ | ||
- | ||
name: "Tag Downgraded Code" | ||
run: | | ||
# separate a "git add" to add untracked (new) files too | ||
git add --all | ||
git commit -m "release PHP 7.2 downgraded" | ||
# force push tag, so there is only 1 version | ||
git tag "${GITHUB_REF#refs/tags/}" --force | ||
git push origin "${GITHUB_REF#refs/tags/}" --force |
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,52 @@ | ||
#!/usr/bin/env bash | ||
|
||
# inspired from https://github.com/rectorphp/rector/blob/main/build/build-rector-scoped.sh | ||
|
||
# see https://stackoverflow.com/questions/66644233/how-to-propagate-colors-from-bash-script-to-github-action?noredirect=1#comment117811853_66644233 | ||
export TERM=xterm-color | ||
|
||
# show errors | ||
set -e | ||
|
||
# script fails if trying to access to an undefined variable | ||
set -u | ||
|
||
|
||
# functions | ||
note() | ||
{ | ||
MESSAGE=$1; | ||
printf "\n"; | ||
echo "\033[0;33m[NOTE] $MESSAGE\033[0m"; | ||
} | ||
|
||
|
||
# configure here | ||
BUILD_DIRECTORY=$1 | ||
RESULT_DIRECTORY=$2 | ||
|
||
# --------------------------- | ||
|
||
note "Starts" | ||
|
||
# 2. scope it | ||
note "Running scoper with '$RESULT_DIRECTORY' output directory" | ||
wget https://github.com/humbug/php-scoper/releases/download/0.17.5/php-scoper.phar -N --no-verbose | ||
|
||
# create directory | ||
mkdir "$RESULT_DIRECTORY" -p | ||
|
||
# Work around possible PHP memory limits | ||
php -d memory_limit=-1 php-scoper.phar add-prefix bin src stubs vendor composer.json --output-dir "../$RESULT_DIRECTORY" --config scoper.php --force --ansi --working-dir "$BUILD_DIRECTORY" | ||
|
||
note "Show prefixed files in '$RESULT_DIRECTORY'" | ||
ls -l $RESULT_DIRECTORY | ||
|
||
note "Dumping Composer Autoload" | ||
composer dump-autoload --working-dir "$RESULT_DIRECTORY" --ansi --classmap-authoritative --no-dev | ||
|
||
# make bin/rule-doc-generator runnable without "php" | ||
chmod 777 "$RESULT_DIRECTORY/bin/rule-doc-generator" | ||
chmod 777 "$RESULT_DIRECTORY/bin/rule-doc-generator.php" | ||
|
||
note "Finished" |
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Set\ValueObject\DowngradeLevelSetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72]); | ||
|
||
$rectorConfig->skip([ | ||
'*/Tests/*', | ||
'*/tests/*', | ||
]); | ||
}; |
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,3 @@ | ||
# These are supported funding model platforms | ||
github: tomasvotruba | ||
custom: https://www.paypal.me/rectorphp |
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,23 @@ | ||
name: Bare Run | ||
|
||
on: [pull_request, push] | ||
|
||
jobs: | ||
bare_run: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php_version: ['7.2', '7.3', '7.4', '8.0', '8.2'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php_version }} | ||
coverage: none | ||
|
||
- run: php bin/rule-doc-generator list --ansi |
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,11 @@ | ||
{ | ||
"name": "symplify/rule-doc-generator", | ||
"description": "Documentation generator for coding standard or static analysis rules", | ||
"license": "MIT", | ||
"require": { | ||
"php": ">=7.2" | ||
}, | ||
"bin": [ | ||
"bin/rule-doc-generator" | ||
] | ||
} |
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,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# add patches | ||
composer install --ansi | ||
|
||
# but skip dev dependencies | ||
composer update --no-dev --ansi | ||
|
||
# remove tests and useless files, to make downgraded, scoped and deployed codebase as small as possible | ||
rm -rf tests | ||
|
||
# downgrade with rector | ||
mkdir rector-local | ||
composer require rector/rector --working-dir rector-local | ||
rector-local/vendor/bin/rector process bin src vendor --config build/rector-downgrade-php-72.php --ansi | ||
|
||
# prefix | ||
sh prefix-code.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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
require __DIR__ . '/vendor/autoload.php'; | ||
|
||
$nowDateTime = new DateTime('now'); | ||
$timestamp = $nowDateTime->format('Ym'); | ||
|
||
// @see https://github.com/humbug/php-scoper/blob/master/docs/further-reading.md | ||
|
||
// see https://github.com/humbug/php-scoper | ||
return [ | ||
'prefix' => 'RuleDocGenerator' . $timestamp, | ||
'expose-constants' => ['#^SYMFONY\_[\p{L}_]+$#'], | ||
'exclude-namespaces' => ['#^Symplify\\\\RuleDocGenerator#', '#^Symfony\\\\Polyfill#'], | ||
'exclude-files' => [ | ||
// do not prefix "trigger_deprecation" from symfony - https://github.com/symfony/symfony/commit/0032b2a2893d3be592d4312b7b098fb9d71aca03 | ||
// these paths are relative to this file location, so it should be in the root directory | ||
'vendor/symfony/deprecation-contracts/function.php', | ||
'stubs/PhpCsFixer/AbstractFixer.php', | ||
'stubs/Rector/Core/Contract/Rector/RectorInterface.php', | ||
], | ||
|
||
// @todo unprefix class names? | ||
]; |