name: drupal_rector_examples

on:
    pull_request: null
    push:
        branches:
            - master

jobs:
    drupal_rector_examples:
        runs-on: ubuntu-latest
        steps:
            -   uses: actions/checkout@v2
            -   uses: shivammathur/setup-php@v2
                with:
                    php-version: 7.3
                    coverage: none # disable xdebug, pcov
                    extensions: "intl"

            # Run standalone install in non-root package, ref https://github.com/rectorphp/rector/issues/732
            -   run: |
                    # Download the latest Drupal core project and all its dependencies
                    composer create-project drupal/recommended-project drupal --dev --no-progress

            -   run: |
                    # Install drupal-rector
                    cd drupal
                    composer require palantirnet/drupal-rector --no-progress

            -   run: |
                    # Prepare rector config files with Drupal specific settings
                    cd drupal
                    cp vendor/palantirnet/drupal-rector/rector.yml .

            -   run: |
                    # Prepare rector_examples folder in the drupal modules directory
                    cd drupal
                    mkdir -p web/modules/custom
                    cp -r vendor/palantirnet/drupal-rector/rector_examples web/modules/custom/.

            -   run: |
                    # Run Rector
                    cd drupal
                    vendor/bin/rector process web/modules/custom/rector_examples --debug

Test with Drupal-Rector project to discover BC breaks early on
Test with Drupal-Rector project to discover BC breaks early on

