Code Climate message if report cannot generate

Problem to solve

The Code Climate report in the MR view is missing if there is no report to compare the current artifact to.

This was initially written up as a bug from @k.boese which is preserved here.

Summary

The code climate report from pipelines does not longer show up in merge requests (for a few days for now)

Steps to reproduce

Any merge request triggers a code climate check via template. The artifact exported by this job should display a code climate report on the MR. Sample MR which should show climate report: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15794 - but its missing

Example Project

gitlab-ee

What is the current bug behavior?

No climate report displayed

What is the expected correct behavior?

Climate report displayed

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Stuff

  • The report is uploaded as artifact
  • Climate updated the images this days
  • We are using an own runner for climate to not use gitlab runner time, but our job worked until recently. As gitlabs climate reports are missing as well i dont think its an issue on our runners site

Intended users

Further details

When researching this bug we found that when an artifact is expired it can't be used for comparison, thus the missing code climate report.

Proposal

The outcome we want for users is to know why a code quality score is not present when they expect it to be.

When the base_path is missing, it could be one of two things:

  1. This is the first time code quality is being introduced to the project so the code_quality job has never been run on the target branch, usually master. The MR has to be merged first for succeeding MRs to show the widget.
  2. The MR's base_pipeline's report artifact has already expired and there are more recent commits to master having the updated report. The MR must be rebased on master. See #14033 (comment 244402302) for more info.

It won't be possible to tell which case is true because base_path will just be null for both, so we have to craft a message that can inform the user about these 2 possible cases.

Once we have the message, show it on the widget's section whenever base_path is missing. Right now we just don't show the widget at all if base_path is missing.

Permissions and Security

Documentation

The docs for code quality should be updated to contain this information as well.

Testing

  • We need to test against some non-standard GitLab Flow cases, like the example in the notes below.

What does success look like, and how can we measure that?

  • Users who can make use of code quality reports but do not see one in the MR widget always have direction on how to get a report on their next MR.

Acceptance Criteria

  • Users get clear information in the about why a code quality score is not present and how to resolve the issue.
  • Readers of code quality documentation will know when to expect/not expect a code quality score based on reading the docs.

What is the type of buyer?

Links / references

/label feature

Edited by Erick Bajao