BigW Consortium Gitlab

Commit fea03a73 by Rémy Coutable

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
parents 14527293 0f206980
---
title: Make it possible to pass coverage value to commit status API
merge_request: 9214
author: wendy0402
...@@ -444,6 +444,7 @@ POST /projects/:id/statuses/:sha ...@@ -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` | `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 | `target_url` | string | no | The target URL to associate with this status
| `description` | string | no | The short description of the status | `description` | string | no | The short description of the status
| `coverage` | float | no | The total code coverage
```bash ```bash
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/17/statuses/18f3e63d05582537db6d183d9d557be09e1f90c8?state=success" 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: ...@@ -464,6 +465,7 @@ Example response:
"name" : "default", "name" : "default",
"sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8", "sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
"status" : "success", "status" : "success",
"coverage": 100.0,
"description" : null, "description" : null,
"id" : 93, "id" : 93,
"target_url" : null, "target_url" : null,
......
...@@ -46,6 +46,7 @@ module API ...@@ -46,6 +46,7 @@ module API
optional :description, type: String, desc: 'A short description of the status' 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 :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 :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 end
post ':id/statuses/:sha' do post ':id/statuses/:sha' do
authorize! :create_commit_status, user_project authorize! :create_commit_status, user_project
...@@ -75,7 +76,8 @@ module API ...@@ -75,7 +76,8 @@ module API
name: name, name: name,
ref: ref, ref: ref,
target_url: params[:target_url], target_url: params[:target_url],
description: params[:description] description: params[:description],
coverage: params[:coverage]
) )
render_validation_error!(status) if status.invalid? render_validation_error!(status) if status.invalid?
......
...@@ -367,7 +367,7 @@ module API ...@@ -367,7 +367,7 @@ module API
class CommitStatus < Grape::Entity class CommitStatus < Grape::Entity
expose :id, :sha, :ref, :status, :name, :target_url, :description, 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 expose :author, using: Entities::UserBasic
end end
......
...@@ -156,6 +156,7 @@ describe API::CommitStatuses, api: true do ...@@ -156,6 +156,7 @@ describe API::CommitStatuses, api: true do
context: 'coverage', context: 'coverage',
ref: 'develop', ref: 'develop',
description: 'test', description: 'test',
coverage: 80.0,
target_url: 'http://gitlab.com/status' } target_url: 'http://gitlab.com/status' }
post api(post_url, developer), optional_params post api(post_url, developer), optional_params
...@@ -167,6 +168,7 @@ describe API::CommitStatuses, api: true do ...@@ -167,6 +168,7 @@ describe API::CommitStatuses, api: true do
expect(json_response['status']).to eq('success') expect(json_response['status']).to eq('success')
expect(json_response['name']).to eq('coverage') expect(json_response['name']).to eq('coverage')
expect(json_response['ref']).to eq('develop') 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['description']).to eq('test')
expect(json_response['target_url']).to eq('http://gitlab.com/status') expect(json_response['target_url']).to eq('http://gitlab.com/status')
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