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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3227079-4.patch | 3.71 KB | bartlangelaan |
Issue fork upgrade_status-3227079
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
Comment #2
bartlangelaanPatch attached.
Comment #3
bartlangelaanThis patch has some enhancements on how the errors are reported (with module name added, and better severity detection).
Comment #4
bartlangelaanAnd a small coding standard fix, removing a space at the end of a line.
Comment #5
gábor hojtsyCan 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.
Comment #6
gábor hojtsyReviewed the code as well. Looks pretty reasonable even without knowing gitlab code quality reports.
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.
Comment #7
bartlangelaanIt 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.
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.
Comment #8
gábor hojtsyWow, 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 :)
Comment #9
gábor hojtsyAlso #3152580: Add UI option to export Upgrade Status results as CSV is somewhat similar.
Comment #10
kim.pepperDocs link is a 404. I think it's moved to https://docs.gitlab.com/ee/ci/testing/code_quality.html
Comment #11
gábor hojtsyJust now I merged #3175323: The analyze command should report proper exit code so now there is
--formatsupport on theanalyzecommand 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
categoryelement 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 acheck_namedefined 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.Comment #12
gábor hojtsyComment #14
rosk0Will try to push this forward.
Comment #16
rosk0Moved code from patch #4 into the
analyzeDrush 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.
Comment #17
gábor hojtsyAw, 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?
Comment #19
gábor hojtsyWoot, thanks!
Comment #20
gábor hojtsyTrying this out now on #3443986: Test code quality analysis integration of Upgrade Status.