Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Snap CI #492

Merged
merged 3 commits into from
Aug 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3984,6 +3984,39 @@ cache(function(data, match, sendBadge, request) {
});
}));

// Snap CI build integration.
// https://snap-ci.com/snap-ci/snap-deploy/branch/master/build_image
camp.route(/^\/snap(-ci?)\/([^\/]+\/[^\/]+)(?:\/(.+))\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var userRepo = match[2];
var branch = match[3];
var format = match[4];
var url = 'https://snap-ci.com/' + userRepo + '/branch/' + branch + '/build_image.svg';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some mechanism to get the badge for the default branch (whatever the "default" branch means for Snap CI)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it isn't. Snap CI doesn't have badge of "default" branch because Snap CI is branch based CI. For example, Snap CI doesn't track new branch in the standard, and settings is splitted.


var badgeData = getBadgeData('build', data);
fetchFromSvg(request, url, function(err, res) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
badgeData.text[1] = res.toLowerCase();
if (res === 'Passed') {
badgeData.colorscheme = 'brightgreen';
} else if (res === 'Failed') {
badgeData.colorscheme = 'red';
}
sendBadge(format, badgeData);

} catch(e) {
badgeData.text[1] = 'invalid';
sendBadge(format, badgeData);
}
});
}));


// Any badge.
camp.route(/^\/(:|badge\/)(([^-]|--)*?)-(([^-]|--)*)-(([^-]|--)+)\.(svg|png|gif|jpg)$/,
function(data, match, end, ask) {
Expand Down Expand Up @@ -4195,7 +4228,7 @@ function fetchFromSvg(request, url, cb) {
request(url, function(err, res, buffer) {
if (err != null) { return cb(err); }
try {
var badge = buffer.replace(/(?:\r\n\s|\r\s|\n\s)/g, '');
var badge = buffer.replace(/(?:\r\n\s*|\r\s*|\n\s*)/g, '');
var match = />([^<>]+)<\/text><\/g>/.exec(badge);
cb(null, match[1]);
} catch(e) {
Expand Down
4 changes: 4 additions & 0 deletions try.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ <h3 id="build"> Build </h3>
<td><img src='/shippable/54d119db5ab6cc13528ab183/master.svg' alt=''/></td>
<td><code>https://img.shields.io/shippable/54d119db5ab6cc13528ab183/master.svg</code></td>
</tr>
<tr><th> Snap CI branch: </th>
<td><img src='/snap-ci/ThoughtWorksStudios/eb_deployer/master.svg' alt=''/></td>
<td><code>https://img.shields.io/snap-ci/ThoughtWorksStudios/eb_deployer/master.svg</code></td>
</tr>
<tr><th> Jenkins: </th>
<td><img src='/jenkins/s/https/jenkins.qa.ubuntu.com/precise-desktop-amd64_default.svg' alt=''/></td>
<td><code>https://img.shields.io/jenkins/s/https/jenkins.qa.ubuntu.com/precise-desktop-amd64_default.svg</code></td>
Expand Down