Gitlab Code Quality

Greetings

Im currently trying to integrate our proyect with code quality. I followed the steps from here https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html but it doesn’t show code quality in widget.

  • Repository allocated in Gitlab.com Free user for the repo
  • Runner (Hint: /admin/runners):version 12.7.1 locally configured on linux ubuntu using shell in a machine with docker

however for this test project i tried to use a shared runner and a image wtih java.

gitlab-ci.yml

image: java:latest

stages:
  - build
  - test
  - execute

include:
  - template: Code-Quality.gitlab-ci.yml

build:
  stage: build
  script: /usr/lib/jvm/java-8-openjdk-amd64/bin/javac HelloWorld.java
  artifacts:
    paths:
     - HelloWorld.*

code_quality:
  stage: test
  artifacts:
    paths: [gl-code-quality-report.json]

execute:
  stage: execute
  script: /usr/lib/jvm/java-8-openjdk-amd64/bin/java HelloWorld

I tried also usign the local runner using the docker installation configured locally but without success in both sceneries.

Later, i have found that i need to pay at least Bronze licence to get this feature, however, my project also has collaborators.

My question is: ¿Does only the account owner of repository needs to have Bronze licence to enable that feature or its needed also for the collaborators in the repo to make it work?

Thank you for your attention.

@Giovanni2293 - Product Manager for the testing group here. This feature is available in Core so you won’t need a Bronze license to use it, sorry for the confusion!

2 Likes

Hello.

If it’s included on core, i would like to get help because it shows:

I followed the instructions shown in the site. Any help would be apreciated.

Repo url: https://gitlab.com/Giovanni2293/movilcodeclimatetest

Have a good day and thanks for help.

You can browse to and download the report from the job page, see the right hand side.

In the not too distant future there will be a view of the full report on the pipeline page as well.

Hopefully this helps @Giovanni2293

1 Like

@jheimbuck_gl is this feature described on https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html included yet?

im a bit confused. The feature i want to enable is the coments on the Merge request from Code climate but i can’t figure how to make it work.

Yes it is live/included. You can see it on this MR on a sample project. Code Quality needs to run against the target branch to set a baseline and then against the source branch AND there is a change in the report before the widget will have content though.

1 Like

It worked!, thank you for the help.

1 Like

If a branch is created, before the code climate job is run on master, and you rebase master onto that older branch, should the MR be showing up on the branch?

@bardia - I haven’t tried that use case out and am not certain. If you have tried this yourself let us know how it goes. I will try to replicate on our side as well.

-JH

you said before its available in the Community Edition. However i cant seem to see why the Code Quality Report Tab is not showing up on the MR pipeline.?

however in your documentation it states : Code Quality Reports (STARTER)???

I am generating the code quality report manually, because we’re using SonarQube, and we’re doing code quality on SQL, so for us theres no need for code climate, or the codeclimate yml - only produce the json file.

however, the code quality report is not showing up on the MR, nor the pipeline, and I have a code quality json already in master as a comparison,

any ideas why its not showing ?
thanks

@rclarke thanks for posting! The Code Quality report on the pipeline page is a Starter feature. The Code Quality Widget that appears on the Merge Request page is a Core feature.

As far as troubleshooting goes we have documented some common tips. Beyond that if you can share the Merge Request / Project you’re expecting to see the widget on the community here may be able to help.

-James H - GitLab Product Manager

unfortunately i cant share the project. I have looked into all the documentation, and according to your words, it should be being visible in the MR widget. But whats strange is that its not showing up. Does the filename in the codeclimate.json HAVE to point to the exact filename (case sensitive)? eg: src/xxxx/xxxxx/myfilename.sql
also, do i need to put this snippet in aswell? keeping in mind that im manually creating my own codeclimate.json file.?

include:

  • template: Code-Quality.gitlab-ci.yml

thanks for your all help/assistance. :wink:

@rclarke as long as the job creating the .json file has it formatted correctly and you use the [artifacts:reports:codequality](https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html#artifactsreportscodequality) label the file should be picked up.

I’m not sure about filename case but the codeclimate docs may point you in the right direction there.

-JH

Hi, sorry to be a pain.

in custom reports, I assume:

  1. i dont need to specify the include: .codeclimate.yml
  2. I dont have to include a code_quality: job. as i can actually just place the artifacts:reports:codequality:codeclimate.json stub.

Im finding it hard to actually test these things, and im still unable to get code quality to appear on the merge request… :frowning:

do you possibly have an example, on a Community Edition, working.? thanks.

Regards

@rclarke - Here’s an example for you. The .sh file creates the 'gl-code-quality-report.json' file with the contents from the docs.

You’d replace this with whatever is doing the analysis and put that into a file that matches what you set in artifacts:reports:codequality:<yourfilehere>.

This is working for me on a private project on the free plan in addition to the example above.

I hope this helps!

-James

Hi James.
I hope i dont sound like a broken record. lol

anyway, everything you’ve shown me in the demo is same as how im doing it. apart from 1 thing:
you seem to create a codeclimate.json in master before hand, and yet you create a gl-code-quality-report.json in the MR. is that right?

UPDATE: we upgraded to 13.2, and viola ! we are now seeing Code Quality boxes in the MR ?
perhaps it was just that. anyway - THANKS A LOAD for your help and patience! you’re a star!

So now i know it DOES work in CE. However, ive now hit another snag, I think it only compares it to latest HEAD in master, and if master did not collate a code quality report on that latest job, a new MR will fail to produce - and show the “base code quality artifiact not present” message. I think it should actually compare to the latest code quality report it has from master over all jobs - dont you think ?

I await your feedback. but thanks James for helping me on this - its been interesting I’ll give it that.

Regards
Richard

@rclarke - Ah, the Code Quality MR widget was not available in CE until 13.2, that is probably what happened.

You are correct about how the MR widget compares reports today. We are discussing an alternate approach in an open issue and we’d love to have you contribute to the discussion there.

-James

Thanks James. I’ll keep an eye on that. Happy to test for you in the wild, dont wanna get too much involved in your disccussions for now, but happy to listen and test where i can.

Richard

1 Like

How do I tell the code quality job to only scan a certain directory?

@Native-Coder - Thanks for the ping! I answered your question in your original post. The short version is it looks like you are on a version that didn’t fix the bug that prevents you from using that but you can exclude other directories in the .codeclimate.yml file.

-James H, GitLab Product Manager, Verify:Testing