diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 0000000..b8831fc --- /dev/null +++ b/.github/workflows/rector.yml @@ -0,0 +1,58 @@ +name: Rector CI + +on: + push: + branches: + - main + pull_request: + branches: + - '*' + +jobs: + rector: + runs-on: ubuntu-latest + + steps: + # Checkout the code + - name: Checkout repository + uses: actions/checkout@v3 + + # Setup PHP environment + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + extensions: mbstring, xml, tokenizer, curl, json + tools: composer + coverage: none + + # Cache dependencies + - name: Cache Composer dependencies + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + # Install dependencies + - name: Install dependencies + run: composer install --no-progress --no-suggest --prefer-dist + + # Cache Rector + - name: Cache Rector cache + uses: actions/cache@v3 + with: + path: .rector/cache + key: ${{ runner.os }}-rector-${{ hashFiles('**/rector.php') }} + restore-keys: ${{ runner.os }}-rector- + + # Run Rector + - name: Run Rector + run: | + vendor/bin/rector process \ + --ansi + + # Optional: Fail if Rector suggests changes + - name: Validate Rector changes + run: | + git diff --exit-code