-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
.github/workflows/phpcs.yml
Outdated
@@ -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 "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON_REPORT=$(vendor/bin/phpcs --report=json src/Tribe/Main.php || echo "") | |
JSON_REPORT=$(vendor/bin/phpcs --report=json ${CHANGED_FILES} || echo "") |
There was a problem hiding this 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
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