Merge remote-tracking branch 'g105b/master'

This commit is contained in:
Thaddee Tyl 2015-01-11 16:24:41 +01:00
commit 78818943f1
2 changed files with 66 additions and 0 deletions

View File

@ -2781,6 +2781,61 @@ cache(function(data, match, sendBadge, request) {
});
}));
// CircleCI build integration.
// https://circleci.com/api/v1/project/BrightFlair/PHP.Gt?circle-token=0a5143728784b263d9f0238b8d595522689b3af2&limit=1&filter=completed
camp.route(/^\/circleci\/project\/([^\/]+\/[^\/]+)(?:\/(.*))?\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var userRepo = match[1]; // eg, `doctrine/orm`.
var branch = match[2];
var format = match[3];
var apiUrl = 'https://circleci.com/api/v1/project/' + userRepo;
if(branch != null) {
apiUrl +=
"/tree/"
+ branch;
}
apiUrl +=
'?circle-token=0a5143728784b263d9f0238b8d595522689b3af2'
+ '&limit=1&filter=completed';
var badgeData = getBadgeData('CircleCI', data);
request(apiUrl, {json:true}, function(err, res, data) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
}
try {
var status = data[0].status;
switch(status) {
case 'success':
badgeData.colorscheme = 'brightgreen';
badgeData.text[1] = 'passing';
break;
case 'failed':
badgeData.colorscheme = 'red';
badgeData.text[1] = 'failed';
break;
case 'no_tests':
case 'scheduled':
case 'not_run':
badgeData.colorscheme = 'yellow';
default:
badgeData.text[1] = status.replace('_', ' ');
break;
}
sendBadge(format, badgeData);
} catch(e) {
badgeData.text[1] = "ERROR: Buffer = " + buffer;//'invalid';
sendBadge(format, badgeData);
}
});
}));
// Any badge.
camp.route(/^\/(:|badge\/)(([^-]|--)+)-(([^-]|--)+)-(([^-]|--)+)\.(svg|png|gif|jpg)$/,
function(data, match, end, ask) {

View File

@ -156,6 +156,14 @@ Pixel-perfect   Retina-ready   Fast   Consistent   Hackable
<td><img src='/sensiolabs/i/45afb680-d4e6-4e66-93ea-bcfa79eb8a87.svg' alt=''/></td>
<td><code>https://img.shields.io/sensiolabs/i/45afb680-d4e6-4e66-93ea-bcfa79eb8a87.svg</code></td>
</tr>
<tr><th> CircleCI: </th>
<td><img src='/circleci/project/BrightFlair/PHP.Gt.svg' alt=''/></td>
<td><code>https://img.shields.io/circleci/project/BrightFlair/PHP.Gt.svg</code></td>
</tr>
<tr><th> CircleCI branch: </th>
<td><img src='/circleci/project/BrightFlair/PHP.Gt/master.svg' alt=''/></td>
<td><code>https://img.shields.io/circleci/project/BrightFlair/PHP.Gt/master.svg</code></td>
</tr>
</tbody></table>
<h3> Downloads </h3>
<table class='badge'><tbody>
@ -587,6 +595,9 @@ is where the current server got started.
<a class='photo' href='https://github.com/jublo'>
<img alt='jublo' src='https://avatars.githubusercontent.com/u/6348321?s=80'>
</a>
<a class='photo' href='https://github.com/g105b'>
<img alt='g105b' src='https://avatars2.githubusercontent.com/u/358014?v=3&s=80'>
</a>
<a class='photo' href='https://github.com/sebmck'>
<img alt='sebmck' src='https://avatars.githubusercontent.com/u/853712?s=80'>
</a>