Skip to content

Commit 2fe2f15

Browse files
committed
Build/Test Tools: Report PHPStan errors in a pull request comment.
Since PHPStan was integrated into CI, its errors have only been reported as warning annotations, which are easy to miss, even for committers. Some cannot be shown alongside the changes at all: an out-of-date baseline entry is reported without a line number, which is how a stale baseline was committed in r63485 and regenerated afterward in r63486, and an unmatched `ignoreErrors` entry without a path has no file to be attached to. The annotations are now emitted from PHPStan's JSON report instead of by `cs2pr`, since that report says whether each error can be ignored. Errors that can be ignored remain warnings, while those PHPStan does not allow to be ignored are annotated as errors and fail the check, with instructions for regenerating the baselines when those are the cause. For pull requests, the results are also uploaded as an artifact, which a new workflow triggered by `workflow_run` turns into a single comment on the pull request, so that it works for pull requests from forks as well. The comment's heading shows whether the check fails, has only warnings, or has nothing left to report. It lists each error with the commit it was first reported for, moves the errors that a commit resolves into a collapsed list naming that commit, and is minimized once all of them are resolved. The history is kept within the comment itself. Since the analysis runs on the pull request merged into its base branch, errors in files that the base branch has changed since are not linked to their lines, and the comment suggests merging the latest base branch instead. The artifact is treated as untrusted: nothing from the pull request is checked out in the privileged workflow, the results are validated, messages are rendered as code spans so that they cannot mention users or link issues, and results are only accepted for the current head of the pull request. The PHPStan README now describes these results, and discourages `@phpstan-ignore` comments, which hide an error from every later analysis of that line, in favor of fixing the error or correcting the types PHPStan relies on. Developed in #14261. Follow-up to r61699, r63019. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@64539 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5e2b02a commit 2fe2f15

3 files changed

Lines changed: 527 additions & 38 deletions

File tree

0 commit comments

Comments
 (0)