Commit 965d87a2 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'feature/sm/2783-rename-codeclimate-to-codequality' into 'master'

Support `codequality` job name for Code Quality feature

Closes #2783

See merge request !2704
parents 043f96eb d4358566
...@@ -37,7 +37,7 @@ module Ci ...@@ -37,7 +37,7 @@ module Ci
scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) } scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) }
scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) } scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) }
scope :manual_actions, ->() { where(when: :manual, status: COMPLETED_STATUSES + [:manual]) } scope :manual_actions, ->() { where(when: :manual, status: COMPLETED_STATUSES + [:manual]) }
scope :codeclimate, ->() { where(name: 'codeclimate') } scope :codequality, ->() { where(name: %w[codequality codeclimate]) }
mount_uploader :artifacts_file, ArtifactUploader mount_uploader :artifacts_file, ArtifactUploader
mount_uploader :artifacts_metadata, ArtifactUploader mount_uploader :artifacts_metadata, ArtifactUploader
......
...@@ -442,7 +442,7 @@ module Ci ...@@ -442,7 +442,7 @@ module Ci
end end
def codeclimate_artifact def codeclimate_artifact
artifacts.codeclimate.find(&:has_codeclimate_json?) artifacts.codequality.find(&:has_codeclimate_json?)
end end
private private
......
---
title: Support `codequality` job name for Code Quality feature
merge_request: 2704
author:
type: changed
...@@ -50,12 +50,15 @@ Apart from those, here is an collection of tutorials and guides on setting up yo ...@@ -50,12 +50,15 @@ Apart from those, here is an collection of tutorials and guides on setting up yo
- **Articles:** - **Articles:**
- [Setting up GitLab CI for Android projects](https://about.gitlab.com/2016/11/30/setting-up-gitlab-ci-for-android-projects/) - [Setting up GitLab CI for Android projects](https://about.gitlab.com/2016/11/30/setting-up-gitlab-ci-for-android-projects/)
### Code quality analysis
- [Analyze code quality with the Code Climate CLI](code_climate.md)
### Other ### Other
- [Using `dpl` as deployment tool](deployment/README.md) - [Using `dpl` as deployment tool](deployment/README.md)
- [Repositories with examples for various languages](https://gitlab.com/groups/gitlab-examples) - [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) - [The .gitlab-ci.yml file for GitLab itself](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/.gitlab-ci.yml)
- [Analyze code quality with the Code Climate CLI](code_climate.md)
- **Articles:** - **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/) - [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/)
......
...@@ -5,10 +5,10 @@ GitLab CI and Docker. ...@@ -5,10 +5,10 @@ GitLab CI and Docker.
First, you need GitLab Runner with [docker-in-docker executor][dind]. First, you need GitLab Runner with [docker-in-docker executor][dind].
Once you set up the Runner, add a new job to `.gitlab-ci.yml`, called `codeclimate`: Once you set up the Runner, add a new job to `.gitlab-ci.yml`, called `codequality`:
```yaml ```yaml
codeclimate: codequality:
image: docker:latest image: docker:latest
variables: variables:
DOCKER_DRIVER: overlay DOCKER_DRIVER: overlay
...@@ -22,7 +22,7 @@ codeclimate: ...@@ -22,7 +22,7 @@ codeclimate:
paths: [codeclimate.json] paths: [codeclimate.json]
``` ```
This will create a `codeclimate` job in your CI pipeline and will allow you to This will create a `codequality` job in your CI pipeline and will allow you to
download and analyze the report artifact in JSON format. download and analyze the report artifact in JSON format.
For GitLab [Enterprise Edition Starter][ee] users, this information can be automatically For GitLab [Enterprise Edition Starter][ee] users, this information can be automatically
......
...@@ -27,8 +27,14 @@ For instance, consider the following workflow: ...@@ -27,8 +27,14 @@ For instance, consider the following workflow:
## How it works ## How it works
>**Note:**
In [GitLab Enterprise Edition Starter][ee] 10.0, another job name will
also be supported: `codequality`. This new job name will eventually replace
`codeclimate` which is scheduled to be removed in GitLab 11.0. You are advised
to update your current `.gitlab-ci.yml` configuration to reflect that change.
In order for the report to show in the merge request, you need to specify a In order for the report to show in the merge request, you need to specify a
`codeclimate` job (exact name) that will analyze the code and upload the resulting `codequality` job (exact name) that will analyze the code and upload the resulting
`codeclimate.json` as an artifact. GitLab will then check this file and show `codeclimate.json` as an artifact. GitLab will then check this file and show
the information inside the merge request. the information inside the merge request.
...@@ -38,11 +44,11 @@ Code Climate display in the merge request. ...@@ -38,11 +44,11 @@ Code Climate display in the merge request.
If the Code Climate report doesn't have anything to compare to, no information If the Code Climate report doesn't have anything to compare to, no information
will be displayed in the merge request area. That is the case when you add the will be displayed in the merge request area. That is the case when you add the
`codeclimate` job in your `.gitlab-ci.yml` for the very first time. `codequality` job in your `.gitlab-ci.yml` for the very first time.
Consecutive merge requests will have something to compare to and the code quality Consecutive merge requests will have something to compare to and the code quality
report will be shown properly. report will be shown properly.
For more information on how the `codeclimate` job should look like, check the For more information on how the `codequality` job should look like, check the
example on [analyzing a project's code quality with Code Climate CLI][cc-docs]. example on [analyzing a project's code quality with Code Climate CLI][cc-docs].
[ee-1984]: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1984 [ee-1984]: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1984
......
...@@ -12,6 +12,28 @@ describe Ci::Build do ...@@ -12,6 +12,28 @@ describe Ci::Build do
let(:job) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
describe '.codequality' do
subject { described_class.codequality }
context 'when a job name is codequality' do
let!(:job) { create(:ci_build, pipeline: pipeline, name: 'codequality') }
it { is_expected.to include(job) }
end
context 'when a job name is codeclimate' do
let!(:job) { create(:ci_build, pipeline: pipeline, name: 'codeclimate') }
it { is_expected.to include(job) }
end
context 'when a job name is irrelevant' do
let!(:job) { create(:ci_build, pipeline: pipeline, name: 'codechecker') }
it { is_expected.not_to include(job) }
end
end
describe '#shared_runners_minutes_limit_enabled?' do describe '#shared_runners_minutes_limit_enabled?' do
subject { job.shared_runners_minutes_limit_enabled? } subject { job.shared_runners_minutes_limit_enabled? }
...@@ -112,7 +134,7 @@ describe Ci::Build do ...@@ -112,7 +134,7 @@ describe Ci::Build do
create( create(
:ci_build, :ci_build,
:artifacts, :artifacts,
name: 'codeclimate', name: 'codequality',
pipeline: pipeline, pipeline: pipeline,
options: { options: {
artifacts: { artifacts: {
...@@ -130,7 +152,7 @@ describe Ci::Build do ...@@ -130,7 +152,7 @@ describe Ci::Build do
create( create(
:ci_build, :ci_build,
:artifacts, :artifacts,
name: 'codeclimate', name: 'codequality',
pipeline: pipeline, pipeline: pipeline,
options: {} options: {}
) )
......
...@@ -1325,12 +1325,12 @@ describe Ci::Pipeline, :mailer do ...@@ -1325,12 +1325,12 @@ describe Ci::Pipeline, :mailer do
end end
describe '#codeclimate_artifact' do describe '#codeclimate_artifact' do
context 'has codeclimate build' do context 'has codequality job' do
let!(:build) do let!(:build) do
create( create(
:ci_build, :ci_build,
:artifacts, :artifacts,
name: 'codeclimate', name: 'codequality',
pipeline: pipeline, pipeline: pipeline,
options: { options: {
artifacts: { artifacts: {
...@@ -1343,7 +1343,7 @@ describe Ci::Pipeline, :mailer do ...@@ -1343,7 +1343,7 @@ describe Ci::Pipeline, :mailer do
it { expect(pipeline.codeclimate_artifact).to eq(build) } it { expect(pipeline.codeclimate_artifact).to eq(build) }
end end
context 'no codeclimate build' do context 'no codequality job' do
before do before do
create(:ci_build, pipeline: pipeline) create(:ci_build, pipeline: pipeline)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment