Code Quality MR widget: Status of report comparison is not taken into account
Summary
The backend code quality comparison returns JSON data that includes a status
property, but we are not taking it into account in three cases:
The code quality MR widget reports "No changes to code quality" when the arrays of changed issues are empty, but the message is not accurate when the status
is failed
. The widget should instead use the "Failed to load code quality report" status/message in this case.
(on further investigation, failed
refers to the status of the scan and not to the status of the report comparison, so we don't need to change the behavior in this case)
status
is not_found
so that we can remove the redundant code from the frontend. This could be combined with moving the message into the body of the widget to make it more discoverable
204 No Content
). In this case we should display a loading icon and continue to poll until we get a response with a different HTTP status so we can display the results in the widget once they have been generated.
Steps to reproduce
For
- Run code quality on the base commit of an MR
- Somehow cause an error when running code quality on the head commit of the MR
- The JSON response should show a status of
failed
but the widget will say "No changes to code quality"
For
- Run code quality on the head commit of an MR, but not the base commit
- The JSON response should show a status of
not_found
and the widget will say "Failed to load codeclimate report" - The widget should have a question mark icon with a popover that says "Base pipeline code quality artifact not found" and links to the docs
For
- Run code quality on the base commit and head commit of an MR with code quality changes
- Once the job is done for the head commit, refresh the MR page until you can see the code quality widget
- On the first load that you can see the widget, it should display "No changes to code quality" even though there are changes, and the network panel in your browser's dev tools should show a request for
codequality_reports.json
with a204 No Content
response - Refresh the page again until the widget displays the real result
Example Project
What is the current bug behavior?
The code quality MR widget reports "No changes to code quality" when the report comparison has failed/errored
The code quality MR widget reports "No changes to code quality" when the reports are still being parsed/compared
What is the expected correct behavior?
The code quality MR widget should show "Failed to load code quality" (or some other more specific/helpful error message) when the report comparison has failed/errored
The code quality MR widget should show a loading indicator while the reports are being parsed/compared, continue to poll for results until the endpoint returns a different result, then display the corresponding message for that result.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)