Skip to content

Commit

Permalink
(feat): Add github action to check code style
Browse files Browse the repository at this point in the history
  • Loading branch information
dtakken committed Jun 28, 2024
1 parent 432b0a5 commit 10b1768
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/check-code-style.yml
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit 10b1768

Please sign in to comment.