Gitlab code quality: where is the report?

孤人 提交于 2019-12-14 00:50:23

问题


On this project: https://gitlab.com/tyvain/parcoursup/tree/master

I have a code quality stage:

code_quality:
  stage: code_quality
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
  allow_failure: true
  services:
    - docker:stable-dind
  script:
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    - docker run
        --env SOURCE_CODE="$PWD"
        --volume "$PWD":/code
        --volume /var/run/docker.sock:/var/run/docker.sock
        "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
  artifacts:
    paths: [gl-code-quality-report.json]

This stage always endup 'passed'. Logs: https://gitlab.com/tyvain/parcoursup/-/jobs/94665791

I doubt that my code is perfect, so there should be some code quality issues somewhere.

Where is the code quality report supposed to be output ?
What is this parameter: "paths: [gl-code-quality-report.json]" ?


回答1:


2 problems here:

  • the report is only available for merge request in 'gitlab EE edition' (not free)
  • the report can be downloaded as a json file here:



回答2:


GitLab parses and displays the results in merge requests. It works by comparing to previous code quality results, so the first time you merge the job into master, you won't see anything. But, it should work on subsequent merge requests.

It's explained in a bit more detail here: Code Quality




回答3:


This is old, but adding this here, in case someone else stumbles on it. I found the same issue (success, but no output) and the result was that the test was timing out. There's a default 900 second timeout on the codeclimate engine. The images that codeclimate uses are well over 1.5gb of data, so they take forever to download on a slow connection. When they timeout they return exit code 0, but no reports.

Verified by doing this locally:

docker run \
  --env CODECLIMATE_CODE=/path/to/my/code \
  --env CONTAINER_TIMEOUT_SECONDS=9000 \
  --volume /path/to/my/code:/code \
  --volume /tmp/cc:/tmp/cc \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --env CODECLIMATE_DEBUG=1 "codeclimate/codeclimate:0.83.0" \
  analyze -f json

Adding CONTAINER_TIMEOUT_SECONDS as an environment variable will allow you to surpass this, if timeout is your issue. I haven't gone further on using this in GitLab, as the documentation is lacking, and I only wanted checkstyle, not all the other stuff codequality comes with in GitLab, and the documentation wasn't clear on how to do that.



来源:https://stackoverflow.com/questions/52174028/gitlab-code-quality-where-is-the-report

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!