Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ignore phpcs on tests #6

Merged
merged 11 commits into from
Jun 18, 2024
Merged

Fix/ignore phpcs on tests #6

merged 11 commits into from
Jun 18, 2024

Conversation

dpanta94
Copy link
Member

@dpanta94 dpanta94 commented Jun 18, 2024

Fail non silently. Catch phpcs exit code and exit with that one.

Also check if the json report produced is valid json and if not exit 1

Please ignore the trial and error i had in the branch. Couldn't figure out where it was failing until the only possibility was phpcs 's exit code

@@ -66,4 +66,24 @@ 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)`<br>\($msg.message)" ' | reviewdog -efm="%f:%l:%c:%m" -name="phpcs" -filter-mode="added" -fail-on-error=true -reporter=github-pr-review
# Run phpcs and capture both the output and the exit code
JSON_REPORT=$(vendor/bin/phpcs --report=json src/Tribe/Main.php || echo "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JSON_REPORT=$(vendor/bin/phpcs --report=json src/Tribe/Main.php || echo "")
JSON_REPORT=$(vendor/bin/phpcs --report=json ${CHANGED_FILES} || echo "")

Copy link
Contributor

@redscar redscar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great.

When the code has issues the PHPCS test fails properly.

When the code has been fixed PHPCS test passes.

Tested on https://github.com/the-events-calendar/events-community/pull/695

@dpanta94 dpanta94 merged commit 7d352a3 into main Jun 18, 2024
@dpanta94 dpanta94 deleted the fix/ignore-phpcs-on-tests branch June 18, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants