Problem/Motivation

The upgrade_status module can currently generate two types of reports through Drush: a 'normal' table and a 'checkstyle' report.
Gitlab CI supports Code Quality (Code Climate) reports. If upgrade_status could generate this report, it can be loaded in Gitlab and its results can be shown in the UI.
More information is in the Gitlab documentation: https://docs.gitlab.com/ee/ci/testing/code_quality.html

Proposed resolution

Create a upgrade_status:codequality command, just like the upgrade_status:checkstyle command, which generates JSON output that can be interpeted by Gitlab.

Remaining tasks

Create patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bartlangelaan created an issue. See original summary.

bartlangelaan’s picture

Status: Active » Needs review
StatusFileSize
new2.93 KB

Patch attached.

bartlangelaan’s picture

StatusFileSize
new3.71 KB

This patch has some enhancements on how the errors are reported (with module name added, and better severity detection).

bartlangelaan’s picture

StatusFileSize
new3.71 KB

And a small coding standard fix, removing a space at the end of a line.

gábor hojtsy’s picture

Can you show a sample screenshot from this command? Also do you have others who could help verify/review the code? I don't believe I have a way to check this.

gábor hojtsy’s picture

Status: Needs review » Postponed (maintainer needs more info)

Reviewed the code as well. Looks pretty reasonable even without knowing gitlab code quality reports.

+++ b/src/Commands/UpgradeStatusCommands.php
@@ -122,6 +122,105 @@ class UpgradeStatusCommands extends DrushCommands {
+            $description = $name . ' - ' . $error['message'];

How does this show up on the UI? Is it possible to dive deeper into this? The extension name and error is not necessarily a unique identifier, multiple copies of the same description could appear with unique fingerprints.

bartlangelaan’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new56.85 KB

It uses the description to inform the user on what new errors are in the MR (and which are solved).

This shows a MR that introduces 2 new code quality issues, one from phpstan (not related to this module) and one from this module.

Code quality example

There are other issues that this module reports on this project - but it only displays the differences (based on the fingerprint).

It also shows the file and line, so it is easy for users to identify where the issue was introduced.

gábor hojtsy’s picture

Title: Support generating Code Quality reports (for Gitlab) » Support generating Code Quality JSON reports (for Gitlab)
Related issues: +#3391323: Add options to provide drush analyze output in JSON and CSV

Wow, there is also #3391323: Add options to provide drush analyze output in JSON and CSV, but this may guide the JSON format better to align with an industry solution :)

gábor hojtsy’s picture

kim.pepper’s picture

Issue summary: View changes

Docs link is a 404. I think it's moved to https://docs.gitlab.com/ee/ci/testing/code_quality.html

gábor hojtsy’s picture

Title: Support generating Code Quality JSON reports (for Gitlab) » Support generating Code Quality JSON reports (for GitLab CI integration)
Status: Needs review » Needs work

Just now I merged #3175323: The analyze command should report proper exit code so now there is --format support on the analyze command where this should go instead of its own command.

Also I added drush command testing there which this should extend.

Finally, I looked at the current GitLab CI docs at https://docs.gitlab.com/ee/ci/testing/code_quality.html and Code Climate docs at https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.... (which the GitLab CI solution is based on) and it appears like you added the category element as raw value of Upgrade Status category, which is not supported by either. Code Climate does not require the fingerprint but GitLab CI appears so, so that looks good. However both require a check_name defined that is not in the patch. So that is still to be done. I think it could either be "Upgrade Status" or we can lightly expand the analyzers in Upgrade Status to give a bit more info, so we can identify the checker at least (eg. PHPStan, Info/composer checker, CSS deprecation checker, etc). I don't know how specific are those checker names usually with other tools.

gábor hojtsy’s picture

Version: 8.x-3.x-dev » 4.x-dev

RoSk0 made their first commit to this issue’s fork.

rosk0’s picture

Assigned: Unassigned » rosk0
Status: Needs work » Active

Will try to push this forward.

rosk0’s picture

Assigned: rosk0 » Unassigned
Status: Active » Needs review

Moved code from patch #4 into the analyze Drush command as requested in #11.

Added format test. It would be good to also add integration test that would actually scan one of the test modules and throw that into GitLab to consume. However the check would really only be done by a human to make sure it's parse and displayed in the GitLab UI, so not sure how much value in it. Could be a follow up.

Added all required by the spec fields.

gábor hojtsy’s picture

Aw, such a perfect update! Thanks for being so thorough! I would love to get this and give it some publicity. How would someone go about integrating this into their drupal.org modules's CI workflow and optionally if they have their own gitlab (or github) CI setup, how would this be possible to integrate there?

gábor hojtsy’s picture

Status: Needs review » Fixed

Woot, thanks!

gábor hojtsy’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.