Skip to content

functional_test__rector_examples #16

functional_test__rector_examples

functional_test__rector_examples #16

name: functional_test__rector_examples
# This test will run on every pull request, and on every commit on any branch
on:
push:
branches:
- main
pull_request:
schedule:
# Run tests every week (to check for rector changes)
- cron: '0 0 * * 0'
jobs:
run_functional_test:
name: Functional Test | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
strategy:
fail-fast: false
matrix:
include:
- php-version: "7.4"
drupal: "^8.9"
fixture: "d8"
- php-version: "7.4"
drupal: "^9.2"
fixture: "d9"
- php-version: "8.0"
drupal: "^9.2"
fixture: "d9"
- php-version: "8.1"
drupal: "^10.0"
fixture: "d10"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, gd
- name: Setup Drupal
uses: bluehorndigital/[email protected]
with:
version: '${{ matrix.drupal }}'
path: ~/drupal
- name: Install Drupal Rector
run: |
cd ~/drupal
composer require palantirnet/drupal-rector:@dev --no-progress
- name: Install Drupal Rector Config
run: |
cd ~/drupal
cp vendor/palantirnet/drupal-rector/rector.php .
- name: Prepare rector_examples folder in the drupal modules directory
run: |
cd ~/drupal
mkdir -p web/modules/custom
cp -R vendor/palantirnet/drupal-rector/fixtures/${{ matrix.fixture }}/rector_examples web/modules/custom
# dry-run is expected to return exit code 2 if there are changes, which we are expecting to happen, here.
# an error code of 1 represents other errors.
# @see \Rector\Core\Console\ExitCode::CHANGED_CODE
- name: Run rector against Drupal (dry-run)
run: |
cd ~/drupal
vendor/bin/rector process web/modules/custom/rector_examples --dry-run --debug || if (($? == 2)); then true; else false; fi
- name: Run rector against Drupal
run: |
cd ~/drupal
vendor/bin/rector process web/modules/custom/rector_examples --debug
# diff options:
# -r: recursive
# -u: show the joined context, like git diff
# -b: ignore whitespace
# -B: ignore lines that are only whitespace
- name: Check that the updated examples match expectations
run: |
diff -rubB fixtures/${{ matrix.fixture }}/rector_examples_updated ~/drupal/web/modules/custom/rector_examples