Skip to content

Commit

Permalink
Add phpcs.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
borkweb committed Nov 28, 2023
1 parent aecbe92 commit 447aacb
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'PHPCS'
on:
workflow_call:
inputs:
ref:
description: 'Git Commit Ref (branch, tag, or hash)'
required: true
type: string
php_version:
description: 'PHP Version'
required: true
type: string
default: '7.4'
jobs:
phpcs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
fetch-depth: 0

# ------------------------------------------------------------------------------
# Prepare our cache directories
# ------------------------------------------------------------------------------
- name: Get Composer Cache Directory
id: get-composer-cache-dir
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v2
id: composer-cache
with:
path: ${{ steps.get-composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: "shivammathur/setup-php@v2"
with:
php-version: ${{ inputs.php_version }}
- uses: "ramsey/composer-install@v2"

- name: "Give permissions"
run: |
sudo chown -R root:root $GITHUB_WORKSPACE
# ------------------------------------------------------------------------------
# Get changed files
# ------------------------------------------------------------------------------
- name: Get list of changed files
id: files
run: |
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '\.php$' | tr '\n' ' ')" >> $GITHUB_ENV
# ------------------------------------------------------------------------------
# PHPCS
# ------------------------------------------------------------------------------
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest # Optional. [latest,nightly,v.X.Y.Z]
- name: Run reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
run: |
vendor/bin/phpcs --report=json ${CHANGED_FILES} | jq -r ' .files | to_entries[] | .key as $path | .value.messages[] as $msg | "\($path):\($msg.line):\($msg.column):`\($msg.source)`<br>\($msg.message)" ' | reviewdog -efm="%f:%l:%c:%m" -name="PHPCS" -filter-mode="added" -fail-on-error=true -reporter=github-pr-review

0 comments on commit 447aacb

Please sign in to comment.