-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat): Add github action to check code style
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |