summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-02-21 09:48:56 +0000
committerRémy Coutable <remy@rymai.me>2018-02-21 15:21:05 +0100
commit5ccd3bec955c1869ad621d352c6509365f2077dc (patch)
tree50083027987f71ac88d2d4b9151fa00794256e12
parent6d2a5f044f82f9500e8694a848125f976cb6d189 (diff)
downloadgitlab-ce-improve-codequality-job.tar.gz
Merge branch 'improve-codequality-job' into 'master'improve-codequality-job
Simplify the codequality job See merge request gitlab-org/gitlab-ee!4602
-rw-r--r--.codeclimate.yml2
-rw-r--r--.gitlab-ci.yml20
-rwxr-xr-xscripts/codequality18
3 files changed, 29 insertions, 11 deletions
diff --git a/.codeclimate.yml b/.codeclimate.yml
index ecac24b68d7..b02fe54a4ff 100644
--- a/.codeclimate.yml
+++ b/.codeclimate.yml
@@ -15,7 +15,7 @@ engines:
enabled: false
rubocop:
enabled: true
- channel: "gitlab-rubocop-0-52"
+ channel: "gitlab-rubocop-0-52-1"
ratings:
paths:
- Gemfile.lock
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9c3556f5cce..f1e28d0928a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -607,22 +607,22 @@ karma:
codequality:
<<: *except-docs
<<: *pull-cache
- before_script: []
- image: docker:latest
stage: test
- variables:
- SETUP_DB: "false"
- DOCKER_DRIVER: overlay
+ image: docker:latest
+ before_script: []
services:
- docker:dind
+ variables:
+ SETUP_DB: "false"
+ DOCKER_DRIVER: overlay2
+ CODECLIMATE_FORMAT: json
+ cache: {}
+ dependencies: []
script:
- - cp .rubocop.yml .rubocop.yml.bak
- - grep -v "rubocop-gitlab-security" .rubocop.yml.bak > .rubocop.yml
- - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc dev.gitlab.org:5005/gitlab/gitlab-build-images:gitlab-codeclimate-v2 analyze -f json > raw_codeclimate.json
- - cat raw_codeclimate.json | docker run -i stedolan/jq -c 'map({check_name,fingerprint,location})' > codeclimate.json
- - mv .rubocop.yml.bak .rubocop.yml
+ - ./scripts/codequality analyze -f json > codeclimate.json || true
artifacts:
paths: [codeclimate.json]
+ expire_in: 1 week
sast:
<<: *except-docs
diff --git a/scripts/codequality b/scripts/codequality
new file mode 100755
index 00000000000..9fa692999f3
--- /dev/null
+++ b/scripts/codequality
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -eo pipefail
+
+code_path=$(pwd)
+
+# docker run --tty will merge stderr and stdout, we don't need this on CI or
+# it will break codequality json file
+[ "$CI" != "" ] || docker_tty="--tty"
+
+docker pull dev.gitlab.org:5005/gitlab/gitlab-build-images:gitlab-codeclimate-rubocop-0-52-1 > /dev/null
+docker tag dev.gitlab.org:5005/gitlab/gitlab-build-images:gitlab-codeclimate-rubocop-0-52-1 codeclimate/codeclimate-rubocop:gitlab-codeclimate-rubocop-0-52-1 > /dev/null
+
+exec docker run --rm $docker_tty --env CODECLIMATE_CODE="$code_path" \
+ --volume "$code_path":/code \
+ --volume /var/run/docker.sock:/var/run/docker.sock \
+ --volume /tmp/cc:/tmp/cc \
+ "codeclimate/codeclimate:${CODECLIMATE_VERSION:-0.71.1}" "$@"