diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index a92b315..5ef88a7 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -54,7 +54,7 @@ jobs: - 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 + echo "CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- . ':!tests' | grep '\.php$' | tr '\n' ' ')" >> $GITHUB_ENV # ------------------------------------------------------------------------------ # PHPCS @@ -66,4 +66,10 @@ jobs: env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.access-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)`
\($msg.message)" ' | reviewdog -efm="%f:%l:%c:%m" -name="phpcs" -filter-mode="added" -fail-on-error=true -reporter=github-pr-review + JSON_REPORT=$(vendor/bin/phpcs --report=json $CHANGED_FILES) + echo $JSON_REPORT | jq empty + if [ $? -ne 0 ]; then + echo "Invalid JSON" + exit 1 + fi + echo $JSON_REPORT | jq -r ' .files | to_entries[] | .key as $path | .value.messages[] as $msg | "\($path):\($msg.line):\($msg.column):`\($msg.source)`
\($msg.message)" ' | reviewdog -efm="%f:%l:%c:%m" -name="phpcs" -filter-mode="added" -fail-on-error=true -reporter=github-pr-review