summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-02-15 09:25:26 +0000
committerRémy Coutable <remy@rymai.me>2017-02-15 09:25:26 +0000
commitfea03a73cfa46afa7973e38222110e12674f78cf (patch)
treebfc9826b7d464b16c55b712974586928ecc02c4e
parent1452729304393978ec93b712130dff6687db01b9 (diff)
parent0f206980d770826d887674e5182fa2bef232cde2 (diff)
downloadgitlab-ce-fea03a73cfa46afa7973e38222110e12674f78cf.tar.gz
Merge branch 'pass_coverage_value_to_commit_status_api' into 'master'
Make it possible to pass coverage value to commit status API Closes #27807 See merge request !9214
-rw-r--r--changelogs/unreleased/pass_coverage_value_to_commit_status_api.yml4
-rw-r--r--doc/api/commits.md2
-rw-r--r--lib/api/commit_statuses.rb4
-rw-r--r--lib/api/entities.rb2
-rw-r--r--spec/requests/api/commit_statuses_spec.rb2
5 files changed, 12 insertions, 2 deletions
diff --git a/changelogs/unreleased/pass_coverage_value_to_commit_status_api.yml b/changelogs/unreleased/pass_coverage_value_to_commit_status_api.yml
new file mode 100644
index 00000000000..74e0c18fa67
--- /dev/null
+++ b/changelogs/unreleased/pass_coverage_value_to_commit_status_api.yml
@@ -0,0 +1,4 @@
+---
+title: Make it possible to pass coverage value to commit status API
+merge_request: 9214
+author: wendy0402
diff --git a/doc/api/commits.md b/doc/api/commits.md
index 53ce381c8ae..ef2400aaf3c 100644
--- a/doc/api/commits.md
+++ b/doc/api/commits.md
@@ -444,6 +444,7 @@ POST /projects/:id/statuses/:sha
| `name` or `context` | string | no | The label to differentiate this status from the status of other systems. Default value is `default`
| `target_url` | string | no | The target URL to associate with this status
| `description` | string | no | The short description of the status
+| `coverage` | float | no | The total code coverage
```bash
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/17/statuses/18f3e63d05582537db6d183d9d557be09e1f90c8?state=success"
@@ -464,6 +465,7 @@ Example response:
"name" : "default",
"sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
"status" : "success",
+ "coverage": 100.0,
"description" : null,
"id" : 93,
"target_url" : null,
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb
index b6e6820c3f4..0b6076bd28c 100644
--- a/lib/api/commit_statuses.rb
+++ b/lib/api/commit_statuses.rb
@@ -46,6 +46,7 @@ module API
optional :description, type: String, desc: 'A short description of the status'
optional :name, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"'
optional :context, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"'
+ optional :coverage, type: Float, desc: 'The total code coverage'
end
post ':id/statuses/:sha' do
authorize! :create_commit_status, user_project
@@ -75,7 +76,8 @@ module API
name: name,
ref: ref,
target_url: params[:target_url],
- description: params[:description]
+ description: params[:description],
+ coverage: params[:coverage]
)
render_validation_error!(status) if status.invalid?
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 2a071e649fa..d4234ffe818 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -367,7 +367,7 @@ module API
class CommitStatus < Grape::Entity
expose :id, :sha, :ref, :status, :name, :target_url, :description,
- :created_at, :started_at, :finished_at, :allow_failure
+ :created_at, :started_at, :finished_at, :allow_failure, :coverage
expose :author, using: Entities::UserBasic
end
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index 88361def3cf..eb53fd71872 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -156,6 +156,7 @@ describe API::CommitStatuses, api: true do
context: 'coverage',
ref: 'develop',
description: 'test',
+ coverage: 80.0,
target_url: 'http://gitlab.com/status' }
post api(post_url, developer), optional_params
@@ -167,6 +168,7 @@ describe API::CommitStatuses, api: true do
expect(json_response['status']).to eq('success')
expect(json_response['name']).to eq('coverage')
expect(json_response['ref']).to eq('develop')
+ expect(json_response['coverage']).to eq(80.0)
expect(json_response['description']).to eq('test')
expect(json_response['target_url']).to eq('http://gitlab.com/status')
end