From 10b176889df0444183d991b9140fb3e72e476673 Mon Sep 17 00:00:00 2001 From: Dik Takken Date: Wed, 26 Jun 2024 10:40:07 +0200 Subject: [PATCH] (feat): Add github action to check code style --- .github/workflows/check-code-style.yml | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/check-code-style.yml diff --git a/.github/workflows/check-code-style.yml b/.github/workflows/check-code-style.yml new file mode 100644 index 0000000..b7847ae --- /dev/null +++ b/.github/workflows/check-code-style.yml @@ -0,0 +1,54 @@ +name: Check Code Style + +on: push + +jobs: + php-cs: + runs-on: ubuntu-latest + needs: what-has-changed + # Run only if PHP files have changed + if: ${{ needs.what-has-changed.outputs.php == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.composer/cache/files + key: dependencies-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + extensions: simplexml, tokenizer, xmlwriter + coverage: none + + - name: Install dependencies + run: composer update --prefer-dist --no-interaction --no-suggest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Execute tests + run: ./vendor/bin/phpcs + + # Job to check if certain files have changed + what-has-changed: + name: Detect file changes + runs-on: ubuntu-latest + outputs: + php: ${{ steps.filter.outputs.php }} + steps: + - name: Checkout + uses: actions/checkout@v3 + # For pull requests it's not necessary to checkout the code + if: ${{ github.event_name != 'pull_request' }} + + - uses: dorny/paths-filter@v2 + id: filter + with: + base: ${{ github.ref }} + filters: | + php: + - added|modified: 'src/**/*.php'