Show all projects!

Run rector only on changed files in Gitlab

Rector changed files only:
  stage: analyze
  interruptible: true
  image: registry.mehrkanal.com/docker/phpx/fpm:${PHP_VERSION}
  dependencies: [ "Install Composer dependencies" ]
  needs: [ "Install Composer dependencies" ]
  script:
    - export MERGE_BASE=$(git merge-base origin/$CI_COMMIT_BRANCH origin/develop)
    - export FILES=$(git diff $MERGE_BASE...$CI_COMMIT_SHA --name-only --diff-filter=d | grep .php)
    - if [ -z "$FILES" ]; then echo "No PHP-Files to scan"; exit 0; fi;
    - echo $FILES;
    - vendor/bin/rector process --dry-run $FILES || exit 1;
  except:
    - develop
    - master

If you have a large PHP project and use Rector for automated refactoring, it might become very slow or run in memory or timeout limits.


To prevent this, you could run rector only on changed files


Gitlab Pipeline with fast running rector

Article relase date: / Last update: