Merge remote-tracking branch 'kyrias/scrutinizer'
This commit is contained in:
commit
32d51d6f0e
46
server.js
46
server.js
|
@ -1605,6 +1605,52 @@ cache(function(data, match, sendBadge, request) {
|
|||
});
|
||||
}));
|
||||
|
||||
// Scrutinizer build integration.
|
||||
camp.route(/^\/scrutinizer\/build\/(.*)\.(svg|png|gif|jpg|json)$/,
|
||||
cache(function(data, match, sendBadge, request) {
|
||||
var repo = match[1]; // eg, g/phpmyadmin/phpmyadmin
|
||||
var format = match[2];
|
||||
// The repo may contain a branch, which would be unsuitable.
|
||||
var repoParts = repo.split('/');
|
||||
var branch = null;
|
||||
// Normally, there are 2 slashes in `repo` when the branch isn't specified.
|
||||
var slashesInRepo = 2;
|
||||
if (repoParts[0] === 'gp') { slashesInRepo = 1; }
|
||||
if ((repoParts.length - 1) > slashesInRepo) {
|
||||
branch = repoParts[repoParts.length - 1];
|
||||
repo = repoParts.slice(0, -1).join('/');
|
||||
}
|
||||
var apiUrl = 'https://scrutinizer-ci.com/api/repositories/' + repo;
|
||||
var badgeData = getBadgeData('build', data);
|
||||
request(apiUrl, {}, function(err, res, buffer) {
|
||||
if (err !== null) {
|
||||
badgeData.text[1] = 'inaccessible';
|
||||
sendBadge(format, badgeData);
|
||||
}
|
||||
try {
|
||||
var data = JSON.parse(buffer);
|
||||
// Which branch are we dealing with?
|
||||
if (branch === null) { branch = data.default_branch; }
|
||||
var res = data.applications[branch].build_status.status;
|
||||
badgeData.text[1] = res;
|
||||
if (res === 'passed') {
|
||||
badgeData.colorscheme = 'brightgreen';
|
||||
} else if (res === 'failed' || res === 'error') {
|
||||
badgeData.colorscheme = 'red';
|
||||
} else if (res === 'pending') {
|
||||
badgeData.colorscheme = 'orange';
|
||||
} else if (res === 'unknown') {
|
||||
badgeData.colorscheme = 'gray';
|
||||
}
|
||||
sendBadge(format, badgeData);
|
||||
|
||||
} catch(e) {
|
||||
badgeData.text[1] = 'invalid';
|
||||
sendBadge(format, badgeData);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
// Scrutinizer integration.
|
||||
camp.route(/^\/scrutinizer\/(.*)\.(svg|png|gif|jpg|json)$/,
|
||||
cache(function(data, match, sendBadge, request) {
|
||||
|
|
4
try.html
4
try.html
|
@ -148,6 +148,10 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
|||
<td><img src='/scrutinizer/coverage/g/phpmyadmin/phpmyadmin/master.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/scrutinizer/coverage/g/phpmyadmin/phpmyadmin/master.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> Scrutinizer Build: </th>
|
||||
<td><img src='/scrutinizer/build/g/filp/whoops.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/scrutinizer/build/g/filp/whoops.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> Codecov: </th>
|
||||
<td><img src='/codecov/c/github/codecov/example-python.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/codecov/c/github/codecov/example-python.svg</code></td>
|
||||
|
|
Loading…
Reference in New Issue
Block a user