From d9f0f64f2773be6e8d12e36b20cd0d0a7040bbb3 Mon Sep 17 00:00:00 2001 From: Jewei Mak Date: Sun, 28 Apr 2024 13:02:00 +0800 Subject: [PATCH] Rector GH action workflow --- .github/workflows/rector.yaml | 33 +++++++++++++++++++++++++++++ app/Http/Middleware/Idempotency.php | 2 ++ rector.php | 6 +++--- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/rector.yaml diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml new file mode 100644 index 0000000..f3856f2 --- /dev/null +++ b/.github/workflows/rector.yaml @@ -0,0 +1,33 @@ +# github action that checks code with Rector +name: Rector + +on: + pull_request: null + +jobs: + rector: + runs-on: ubuntu-latest + if: github.event.pull_request.head.repo.full_name == 'jewei/laravel-skeleton' + steps: + - if: github.event.pull_request.head.repo.full_name == github.repository + uses: actions/checkout@v4 + with: + # Must be used to trigger workflow after push + token: ${{ secrets.ACCESS_TOKEN }} + + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + coverage: none + + - uses: "ramsey/composer-install@v3" + + - run: vendor/bin/rector --ansi + # @todo apply coding standard if used + + - # commit only to core contributors who have repository access + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "[rector] Rector fixes" + commit_author: "GitHub Action " + commit_user_email: "action@github.com" diff --git a/app/Http/Middleware/Idempotency.php b/app/Http/Middleware/Idempotency.php index c94a348..c5a863c 100644 --- a/app/Http/Middleware/Idempotency.php +++ b/app/Http/Middleware/Idempotency.php @@ -26,6 +26,8 @@ class Idempotency /** * The verbs that are considered idempotent. + * + * @var array */ protected array $verbs = ['POST', 'PUT', 'PATCH', 'DELETE']; diff --git a/rector.php b/rector.php index f958ce8..431c2b2 100644 --- a/rector.php +++ b/rector.php @@ -40,10 +40,10 @@ // ]) ->withSets([ - LaravelSetList::LARAVEL_110, LaravelSetList::ARRAY_STR_FUNCTIONS_TO_STATIC_CALL, - LaravelSetList::LARAVEL_CODE_QUALITY, + LaravelSetList::LARAVEL_110, LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL, - LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES, + LaravelSetList::LARAVEL_CODE_QUALITY, LaravelSetList::LARAVEL_ELOQUENT_MAGIC_METHOD_TO_QUERY_BUILDER, + LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES, ]);