From 81f08d7b38c89167d016fbe4bf475cf373055947 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 15 May 2017 09:23:20 +0300 Subject: Add Code Climate CLI example to CI documentation Signed-off-by: Dmitriy Zaporozhets --- doc/ci/examples/README.md | 1 + doc/ci/examples/code_quality.md | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 doc/ci/examples/code_quality.md diff --git a/doc/ci/examples/README.md b/doc/ci/examples/README.md index 33c27b39a8a..b232fb838f4 100644 --- a/doc/ci/examples/README.md +++ b/doc/ci/examples/README.md @@ -55,6 +55,7 @@ Apart from those, here is an collection of tutorials and guides on setting up yo - [Using `dpl` as deployment tool](deployment/README.md) - [Repositories with examples for various languages](https://gitlab.com/groups/gitlab-examples) - [The .gitlab-ci.yml file for GitLab itself](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/.gitlab-ci.yml) +- [Analyze code quality with Code Climate CLI](examples/code_quality.md) - **Articles:** - [Continuous Deployment with GitLab: how to build and deploy a Debian Package with GitLab CI](https://about.gitlab.com/2016/10/12/automated-debian-package-build-with-gitlab-ci/) diff --git a/doc/ci/examples/code_quality.md b/doc/ci/examples/code_quality.md new file mode 100644 index 00000000000..f46b1b22631 --- /dev/null +++ b/doc/ci/examples/code_quality.md @@ -0,0 +1,24 @@ +# Analyze project code quality with Code Climate CLI + +This example shows how to run Code Climate CLI on your code by using GitLab CI and docker. + +First, you need GitLab runner with docker-in-docker executor - https://docs.gitlab.com/ce/ci/docker/using_docker_build.html#use-docker-in-docker-executor. + +Once you setup runner let's add new job to the `.gitlab-ci.yml`: + +```yaml +codeclimate: + image: docker:latest + variables: + DOCKER_DRIVER: overlay + services: + - docker:dind + script: + - docker pull codeclimate/codeclimate + - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate init + - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json > codeclimate.json + artifacts: + paths: [codeclimate.json] +``` + +This will create `codeclimate` job in your CI pipeline and will allow you to download analyse report artifact in JSON format. -- cgit v1.2.1