Skip to content

Commit 736bf41

Browse files
author
Ben Lavender
committed
Combined status API blog post
1 parent 2dce794 commit 736bf41

File tree

8 files changed

+157
-62
lines changed

8 files changed

+157
-62
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ group :development do
1919
end
2020

2121
group :test do
22-
gem 'html-proofer', '~> 0.6.0'
22+
gem 'html-proofer', '~> 0.6.1'
2323
end

Gemfile.lock

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ GEM
1010
cri (2.4.1)
1111
colored (>= 1.2)
1212
daemons (1.1.9)
13-
ethon (0.6.2)
13+
ethon (0.7.0)
1414
ffi (>= 1.3.0)
15-
mime-types (~> 1.18)
1615
eventmachine (1.0.3)
1716
ffi (1.9.3)
1817
fssm (0.2.10)
19-
html-proofer (0.6.0)
18+
html-proofer (0.6.1)
2019
colored (~> 1.2)
2120
mercenary (~> 0.2.0)
2221
nokogiri (~> 1.6.0)
@@ -40,8 +39,8 @@ GEM
4039
daemons (>= 1.0.9)
4140
eventmachine (>= 1.0.0)
4241
rack (>= 1.0.0)
43-
typhoeus (0.6.7)
44-
ethon (~> 0.6.2)
42+
typhoeus (0.6.8)
43+
ethon (>= 0.7.0)
4544
yajl-ruby (0.8.3)
4645

4746
PLATFORMS
@@ -52,7 +51,7 @@ DEPENDENCIES
5251
builder
5352
coderay
5453
fssm
55-
html-proofer (~> 0.6.0)
54+
html-proofer (~> 0.6.1)
5655
kramdown (~> 0.13.2)
5756
mime-types (~> 1.16)
5857
nanoc (~> 3.4.3)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
kind: change
3+
title: Preview the New Combined Status API
4+
created_at: 2014-03-27
5+
author_name: bhuga
6+
---
7+
8+
What does it mean for a branch to be "green?" The [Status API][status-api] helps
9+
thousands of teams answer that question. Developers use it to record the status
10+
of continuous integration builds, contributor license agreements, code coverage
11+
analysis, automated security testing, dependency management, and more.
12+
13+
For many teams, a branch is considered "green" only when _all_ of their various
14+
status checks are successful. With the new [Combined Status
15+
API][combined-status-api], developers can easily fetch this single, consolidated
16+
status for any branch, commit, or tag.
17+
18+
### Status context
19+
20+
To help multiple service providers use the Status API simultaneously, statuses
21+
now support a `context` field. This field allows a provider to distinguish its
22+
statuses from another provider's statuses. For example, your [Jenkins][] builds
23+
might use a context of `ci/jenkins`, while your [Brakeman][] checks might adopt a
24+
context of `security/brakeman`.
25+
26+
The new [Combined Status endpoint][combined-status-api] returns a single,
27+
combined state, as well as the latest status from each context. Systems that
28+
consume status updates can now get all the information they need in one place.
29+
30+
### Opt-in
31+
32+
The existing [Status API][list-statuses] continues to work as it always has. The
33+
`context` field is entirely optional, and the [color of the merge button on pull
34+
requests](https://github.com/blog/1227-commit-status-api) does not currently
35+
take context into account.
36+
37+
### Preview period
38+
39+
We're making this new API available today for developers to
40+
[preview][status-api]. During this period, we may change aspects of the Combined
41+
Status API from time to time. We will announce any changes here (on the
42+
developer blog), but we will not provide any advance notice.
43+
44+
We expect the preview period to last 30-60 days. At the end of preview period,
45+
the Combined Status API will become an official component of GitHub API v3. At
46+
that point, this new API will be stable and suitable for production use.
47+
48+
We hope you'll [try it out][status-api] and [send us your feedback][contact]!
49+
50+
[status-api]: /v3/repos/statuses/
51+
[contact]: https://github.com/contact?form[subject]=Combined+Status+API
52+
[combined-status-api]: /v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
53+
[create-a-status]: /v3/repos/statuses/#create-a-status
54+
[brakeman]: http://brakemanscanner.org/
55+
[jenkins]: http://jenkins-ci.org/
56+
[list-statuses]: /v3/repos/statuses/#list-statuses-for-a-specific-ref

content/program.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ layout: developers
66
<div class="feature dev-program">
77
<div class="wrapper">
88
<h1>It takes a community to design, build, and ship great software.</h1>
9-
<p class="intro">Building an application that integrates with GitHub? Register for our Developer Program, the possibilities are endless and the kudos is all yours.</p>
9+
<p class="intro">Building an application that integrates with GitHub? Register for our Developer Program! The possibilities are endless, and you enjoy the kudos.</p>
1010
<a href="https://github.com/developer/register" class="button">Register now</a>
1111
</div>
1212
<img src="/shared/images/header-animation.gif" alt="GitHub Universe" class="earth" width="450" height="375">

content/v3/repos/deployments.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ Users with pull access can view deployments for a repository:
9898
## Create a Deployment
9999

100100
If your repository is taking advantage of [commit statuses](/v3/repos/statuses),
101-
the API will reject requests that do not have a success status. (Your repository
102-
is not required to use commit statuses. If no commit statuses are present, the
103-
deployment will always be created.)
101+
the API will reject requests that do not have a successful [combined
102+
status.](/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref) (Your
103+
repository is not required to use commit statuses. If no commit statuses are
104+
present, the deployment will always be created.)
104105

105106
The `force` parameter can be used when you really just need a deployment to go
106107
out. In these cases, all checks are bypassed, and the deployment is created for

content/v3/repos/statuses.md

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,59 @@ Note that the `repo:status` [OAuth scope](/v3/oauth/#scopes) grants targeted
2525
access to Statuses **without** also granting access to repository code, while the
2626
`repo` scope grants permission to code as well as statuses.
2727

28+
## Create a Status
29+
30+
Users with push access can create commit statuses for a given ref:
31+
32+
POST /repos/:owner/:repo/statuses/:sha
33+
34+
### Parameters
35+
36+
Name | Type | Description
37+
-----|------|--------------
38+
`state`|`string` | **Required**. The state of the status. Can be one of `pending`, `success`, `error`, or `failure`.
39+
`target_url`|`string` | The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the 'source' of the Status.<br/>For example, if your Continuous Integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA:<br/>`http://ci.example.com/user/repo/build/sha`.
40+
`description`|`string` | A short description of the status.
41+
`context`|`string` | A string label to differentiate this status from the status of other systems.
42+
43+
#### Example
44+
45+
<%= json \
46+
:state => "success",
47+
:target_url => "https://example.com/build/status",
48+
:description => "The build succeeded!",
49+
:context => "continuous-integration/jenkins"
50+
%>
51+
52+
### Response
53+
54+
<%= headers 201,
55+
:Location =>
56+
'https://api.github.com/repos/octocat/example/statuses/1' %>
57+
<%= json :status %>
58+
59+
<% combined_media_type = "application/vnd.github.she-hulk-preview+json" %>
60+
2861
## List Statuses for a specific Ref
2962

3063
Users with pull access can view commit statuses for a given ref:
3164

3265
GET /repos/:owner/:repo/statuses/:ref
3366

67+
<div class="alert">
68+
<p>
69+
If you send an <code>Accept</code> header with the Combined Status API preview
70+
<a href="/v3/media/">media type</a>, <code><%= combined_media_type %></code>,
71+
this endpoint is also available at <code>/repos/:owner/:repo/:ref/status</code>.
72+
</p>
73+
</div>
74+
3475
Statuses are returned in reverse chronological order. The first status in the
3576
list will be the latest one.
3677

3778
### Parameters
3879

39-
Name | Type | Description
80+
Name | Type | Description
4081
-----|------|--------------
4182
`ref`|`string` | **Required**. Ref to list the statuses from. It can be a SHA, a branch name, or a tag name.
4283

@@ -46,31 +87,37 @@ Name | Type | Description
4687
<%= headers 200 %>
4788
<%= json(:status) { |h| [h] } %>
4889

49-
## Create a Status
90+
## Get the combined Status for a specific Ref
5091

51-
Users with push access can create commit statuses for a given ref:
92+
<div class="alert">
93+
<p>
94+
The Combined status endpoint is currently available for developers to preview.
95+
During the preview period, the API may change without advance notice.
96+
Please see the <a href="/changes/2014-03-27-combined-status-api/">blog post</a> for full details.
97+
</p>
98+
<p>
99+
To access this endpoint during the preview period, you must provide a custom
100+
<a href="/v3/media/">media type</a> in the <code>Accept</code> header:
101+
<pre><%= combined_media_type %></pre>
102+
</p>
103+
</div>
52104

53-
POST /repos/:owner/:repo/statuses/:sha
105+
Users with pull access can access a combined view of commit statuses for a given ref.
54106

55-
### Parameters
107+
GET /repos/:owner/:repo/:ref/statuses
56108

57-
Name | Type | Description
58-
-----|------|--------------
59-
`state`|`string` | **Required**. The state of the status. Can be one of `pending`, `success`, `error`, or `failure`.
60-
`target_url`|`string` | The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the 'source' of the Status.<br/>For example, if your Continuous Integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA:<br/>`http://ci.example.com/user/repo/build/sha`.
61-
`description`|`string` | A short description of the status
109+
The most recent status for each context is returned (up to 25), as well as a combined
110+
`state`. The `state` is `pending` to start, `failure` if any status reports as
111+
`error` or `failure`, `pending` if any context's latest status is `pending`, and
112+
`success` if the latest status for all contexts is `success`. (`null` is
113+
considered a distinct context)
62114

63-
#### Example
115+
### Parameters
64116

65-
<%= json \
66-
:state => "success",
67-
:target_url => "https://example.com/build/status",
68-
:description => "The build succeeded!"
69-
%>
117+
Name | Type | Description
118+
-----|------|--------------
119+
`ref`|`string` | **Required**. Ref to fetch the status for. It can be a SHA, a branch name, or a tag name.
70120

71121
### Response
72-
73-
<%= headers 201,
74-
:Location =>
75-
'https://api.github.com/repos/octocat/example/statuses/1' %>
76-
<%= json :status %>
122+
<%= headers 200 %>
123+
<%= json(:combined_status) { |h| [h] } %>

layouts/_meta.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2 class="title">
1212
<% end %>
1313
</li>
1414
<li class="who_when">
15-
<%= gravatar_for(@item[:author_name]) %>
15+
<%= avatar_for(@item[:author_name]) %>
1616
<a href="https://github.com/<%= @item[:author_name] %>"><%= @item[:author_name] %></a>
1717
</li>
1818
</ul>

lib/resources.rb

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,6 @@ module Helpers
2727
502 => '502 Bad Gateway'
2828
}
2929

30-
AUTHORS = {
31-
:technoweenie => '821395fe70906c8290df7f18ac4ac6cf',
32-
:tclem => '2f4861b27dc35663ed271d39f5358261',
33-
:pengwynn => '7e19cd5486b5d6dc1ef90e671ba52ae0',
34-
:pezra => 'f38112009dc16547051c8ac246cee443',
35-
:rick => 'a44d5abad6e86cff4e34d9f0839535c9',
36-
:agh => '6af915d3c6aa4ad30bbad43d8035fe10',
37-
:jasonrudolph => '592e1e6f041f9a4ec51846fd82013aea',
38-
:Caged => '97c3a8eea9b7eaa9e1e93ea3cd47399f',
39-
:foca => 'd0ca2bf32bda9e9ea8c4473ffc3aaa0d',
40-
:ymendel => 'b1b1d33e0655e841d4fd8467359c58d0',
41-
:mastahyeti => '8caa0afdae1a934c30a1998472c63134',
42-
:atmos => 'a86224d72ce21cd9f5bee6784d4b06c7',
43-
:kdaigle => 'dd18bb36fa5f06e45843ff8de33b793e',
44-
:gjtorikian => 'befd819b3fced8c6bd3dba7e633dd068',
45-
:izuzak => 'ff743b4cba28cc47ad65cb90212c1e51',
46-
:spicycode => '7ce90d712fab09421b7f2cf955b9a4c8',
47-
:dbussink => 'b012094b37ab6946c44eaa41d7828478',
48-
:benbalter => '19d03ecc1ff5da1a5e63a3ddaa2d84c2',
49-
}
50-
5130
DefaultTimeFormat = "%B %-d, %Y".freeze
5231

5332
def post_date(item)
@@ -58,15 +37,12 @@ def strftime(time, format = DefaultTimeFormat)
5837
attribute_to_time(time).strftime(format)
5938
end
6039

61-
def gravatar_for(login)
62-
%(<img height="16" width="16" src="%s" alt="gravatar_for_#{login}"/>) % gravatar_url_for(login)
40+
def avatar_for(login)
41+
%(<img height="16" width="16" src="%s" alt="Avatar for #{login}"/>) % avatar_url_for(login)
6342
end
6443

65-
def gravatar_url_for(login)
66-
md5 = AUTHORS[login.to_sym]
67-
default = "https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png"
68-
"https://secure.gravatar.com/avatar/%s?s=20&d=%s" %
69-
[md5, default]
44+
def avatar_url_for(login)
45+
"https://github.com/#{login}.png"
7046
end
7147

7248
def headers(status, head = {})
@@ -1589,15 +1565,31 @@ def text_html(response, status, head = {})
15891565
"description" => "Deploy request from hubot",
15901566
}
15911567

1592-
STATUS = {
1568+
SIMPLE_STATUS = {
15931569
"created_at" => "2012-07-20T01:19:13Z",
15941570
"updated_at" => "2012-07-20T01:19:13Z",
15951571
"state" => "success",
15961572
"target_url" => "https://ci.example.com/1000/output",
15971573
"description" => "Build has completed successfully",
15981574
"id" => 1,
15991575
"url" => "https://api.github.com/repos/octocat/example/statuses/1",
1576+
"context" => "continuous-integration/jenkins"
1577+
}
1578+
1579+
STATUS = SIMPLE_STATUS.merge(
16001580
"creator" => USER
1581+
)
1582+
1583+
COMBINED_STATUS = {
1584+
"state" => "success",
1585+
"name" => "octocat/Hello-World",
1586+
"sha" => COMMIT["sha"],
1587+
"statuses" => [
1588+
SIMPLE_STATUS.merge("context" => "continuous-integration/jenkins"),
1589+
SIMPLE_STATUS.merge("context" => "security/brakeman")
1590+
],
1591+
"commit_url" => "https://api.github.com/repos/octocat/Hello-World/#{COMMIT["sha"]}",
1592+
"repository_url" => "https://api.github.com/repos/octocat/Hello-World"
16011593
}
16021594

16031595
META = {

0 commit comments

Comments
 (0)