From 357d7d4f62536760db83c75b12619804d64391e8 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Mon, 17 Jun 2024 22:28:30 +0300 Subject: [PATCH 1/2] Ignore phpcs on tests --- .github/workflows/phpcs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index a92b315..b10a8a9 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 From 1489c45291d13675254dca346dd03578b1f37cec Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Mon, 17 Jun 2024 22:40:33 +0300 Subject: [PATCH 2/2] Fail no silently when invalid JSON --- .github/workflows/phpcs.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index b10a8a9..5ef88a7 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -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