2021-05-09 18:03:49 +00:00
# builds the content of https://github.com/rectorphp/rector
2021-03-23 00:08:23 +00:00
# inspiration from https://github.com/phpstan/phpstan-src/blob/master/.github/workflows/phar.yml
2020-12-25 23:17:31 +00:00
name : Build Scoped Rector
on :
push :
2020-12-27 21:14:39 +00:00
branches :
2021-03-11 20:29:21 +00:00
- main
2021-03-18 01:48:44 +00:00
tags :
2021-02-11 12:37:40 +00:00
- '*'
2021-03-18 22:03:54 +00:00
env :
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION : "dev-main"
2020-12-25 23:17:31 +00:00
jobs :
build_scoped_rector :
2021-12-07 21:27:44 +00:00
# Don't run on forks.
if : github.repository == 'rectorphp/rector-src'
2020-12-25 23:17:31 +00:00
runs-on : ubuntu-latest
2021-07-16 14:29:52 +00:00
timeout-minutes : 30
2020-12-25 23:17:31 +00:00
steps :
2021-08-08 16:54:24 +00:00
# sometime, when 2 or more consecutive PRs merged, the checkout rectorphp/rector-src is overlapped
# and reverting other commit change
# this should not happen on create a tag, so wait first
-
name : "Wait 3 minutes before checkout rectorphp/rector-src on create a tag"
if : "startsWith(github.ref, 'refs/tags/')"
run : sleep 180
2020-12-25 23:17:31 +00:00
-
uses : actions/checkout@v2
2021-03-18 01:48:44 +00:00
with :
fetch-depth : 0
2020-12-25 23:17:31 +00:00
-
uses : shivammathur/setup-php@v2
with :
2021-12-03 14:44:33 +00:00
php-version : 8.1
2021-03-18 01:48:44 +00:00
coverage : none
2020-12-25 23:17:31 +00:00
# fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth
env :
COMPOSER_TOKEN : ${{ secrets.ACCESS_TOKEN }}
2021-03-18 01:48:44 +00:00
# install only prod dependencies - do not use ramsey, it uses cache including "dev", we want to avoid it here
2021-11-04 15:10:58 +00:00
# somehow psr/http-message needed now when downgrading ssch/typo3-rector
- run : |
composer require psr/http-message
composer update --no-dev --ansi
2021-03-18 01:48:44 +00:00
2021-10-27 10:21:45 +00:00
# early downgrade individual functions
2021-06-10 13:03:40 +00:00
- run : bin/rector process src/functions -c build/config/config-downgrade.php --ansi
2021-06-01 12:27:38 +00:00
2021-03-18 01:48:44 +00:00
# 1. copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop
- run : rsync --exclude rector-build -av * rector-build --quiet
2021-12-14 12:06:02 +00:00
- run : rm -rf rector-build/packages-tests rector-build/rules-tests rector-build/tests rector-build/bin/generate-changelog.php rector-build/bin/validate-phpstan-version.php
2021-03-18 01:48:44 +00:00
# 2. downgrade rector
2021-04-21 20:03:40 +00:00
- run : sh build/downgrade-rector.sh rector-build
2021-03-18 01:48:44 +00:00
2021-12-03 14:44:33 +00:00
# scoped using php-scoper.phar which require #[\ReturnTypeWillChange] inside so use php 8.0 for scoping
-
uses : shivammathur/setup-php@v2
with :
php-version : 8.0
coverage : none
# fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth
env :
COMPOSER_TOKEN : ${{ secrets.ACCESS_TOKEN }}
2021-03-18 01:48:44 +00:00
# 3. prefix classes
- run : sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
# 4. lint the code for PHP 7.1 - this must happen here, as setup-php allows only one PHP version switch: https://github.com/shivammathur/setup-php/issues/434
-
uses : shivammathur/setup-php@v2
with :
php-version : 7.1
coverage : none
- run : composer create-project php-parallel-lint/php-parallel-lint php-parallel-lint --ansi
2021-12-11 09:13:18 +00:00
- run : php-parallel-lint/parallel-lint rector-prefixed-downgraded --exclude rector-prefixed-downgraded/stubs --exclude rector-prefixed-downgraded/vendor/rector/rector-nette/tests --exclude rector-prefixed-downgraded/vendor/symfony/polyfill-mbstring/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/tracy/tracy/examples --exclude rector-prefixed-downgraded/vendor/ssch/typo3-rector/templates/maker --exclude rector-prefixed-downgraded/vendor/symfony/console/Event --exclude rector-prefixed-downgraded/vendor/symfony/console/EventListener --exclude rector-prefixed-downgraded/vendor/symfony/console/Tester --exclude rector-prefixed-downgraded/vendor/rector/rector-generator/templates
2021-03-18 01:48:44 +00:00
# 5. copy repository meta files
2021-03-26 15:56:42 +00:00
- run : |
cp -R build/target-repository/. rector-prefixed-downgraded
cp -R templates rector-prefixed-downgraded/
2021-05-19 23:34:39 +00:00
cp CONTRIBUTING.md rector-prefixed-downgraded/
2021-08-04 08:45:17 +00:00
cp preload.php rector-prefixed-downgraded/
2021-03-18 01:48:44 +00:00
2021-03-22 22:17:58 +00:00
# 6. clone remote repository, so we can push it
2021-03-22 21:29:08 +00:00
-
2021-03-22 22:17:58 +00:00
uses : "actions/checkout@v2"
with :
2021-05-09 18:03:49 +00:00
repository : rectorphp/rector
2021-03-22 22:17:58 +00:00
path : remote-repository
2021-03-22 22:18:17 +00:00
token : ${{ secrets.ACCESS_TOKEN }}
2021-03-22 22:17:58 +00:00
2021-03-23 22:50:36 +00:00
# remove remote files, to avoid piling up dead code in remote repository
2021-12-14 12:45:09 +00:00
- run : rm -rf remote-repository/.github remote-repository/config remote-repository/src remote-repository/rules remote-repository/packages remote-repository/vendor remote-repository/bin/generate-changelog.php
2021-03-23 22:50:36 +00:00
- run : cp -a rector-prefixed-downgraded/. remote-repository
2021-03-22 22:17:58 +00:00
# 7. setup git
-
working-directory : remote-repository
2021-03-22 21:29:08 +00:00
run : |
git config user.email "tomas.vot@gmail.com"
git config user.name "Tomas Votruba"
2021-03-23 00:08:23 +00:00
# commit metadata
-
name : "Get Git log"
id : git-log
2021-05-11 11:42:05 +00:00
run : echo ::set-output name=log::$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='%H %s' | sed -e 's/^/https:\/\/github.com\/rectorphp\/rector-src\/commit\//')
2021-03-23 00:08:23 +00:00
2021-03-22 22:17:58 +00:00
# 8.A publish it to remote repository without tag
2021-03-18 01:48:44 +00:00
-
2021-03-22 21:18:33 +00:00
name : "Commit Prefixed - main"
2021-03-22 22:17:58 +00:00
working-directory : remote-repository
2021-03-18 01:48:44 +00:00
if : "!startsWith(github.ref, 'refs/tags/')"
2021-03-22 20:47:21 +00:00
run : |
2021-03-22 21:37:19 +00:00
git add --all
2021-03-23 00:08:23 +00:00
git commit -m "Updated Rector to commit ${{ github.event.after }}" -m "${{ steps.git-log.outputs.log }}"
2021-03-22 21:18:33 +00:00
git push --quiet origin main
2021-03-22 20:47:21 +00:00
2021-03-22 22:17:58 +00:00
# 8.B publish it to remote repository with tag
2020-12-25 23:17:31 +00:00
-
2021-03-22 21:18:33 +00:00
name : "Commit Prefixed - tag"
2021-03-22 22:17:58 +00:00
working-directory : remote-repository
2021-03-18 01:48:44 +00:00
if : "startsWith(github.ref, 'refs/tags/')"
2021-03-22 21:18:33 +00:00
run : |
2021-03-22 21:37:19 +00:00
git add --all
2021-03-23 00:08:23 +00:00
git commit -m "Rector ${GITHUB_REF#refs/tags/}" -m "${{ steps.git-log.outputs.log }}"
2021-03-22 21:18:33 +00:00
git push --quiet origin main
git tag ${GITHUB_REF#refs/tags/} -m "${GITHUB_REF#refs/tags/}"
git push --quiet origin ${GITHUB_REF#refs/tags/}
2021-10-27 11:33:39 +00:00
# run bare run test
- run : cd remote-repository && bin/rector list --ansi && cd ..