From a1faff1e62af893309b6c873f8f2060e539c1a9c Mon Sep 17 00:00:00 2001 From: Nico Lindemann Date: Wed, 3 Sep 2014 22:43:11 +0200 Subject: [PATCH 1/4] Add codeship.io support --- server.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/server.js b/server.js index f3c2b49..8a3250c 100644 --- a/server.js +++ b/server.js @@ -1662,6 +1662,58 @@ cache(function(data, match, sendBadge) { }); })); +// Codeship.io integration +camp.route(/^\/codeship\/(.+)\.(svg|png|gif|jpg)$/, +cache(function(data, match, sendBadge) { + var projectId = match[1]; // eg, `github/kabisaict/flow`. + var format = match[2]; + var options = { + method: 'GET', + uri: 'https://www.codeship.io/projects/' + projectId + '/status' + }; + var badgeData = getBadgeData('build', data); + request(options, function(err, res) { + if (err != null) { + badgeData.text[1] = 'inaccessible'; + sendBadge(format, badgeData); + } + try { + var statusMatch = res.headers['content-disposition'] + .match(/filename="status_(.+)\.png"/); + if (!statusMatch) { + badgeData.text[1] = 'unknown'; + sendBadge(format, badgeData); + return; + } + + switch (statusMatch[1]) { + case 'success': + badgeData.text[1] = 'passed'; + badgeData.colorscheme = 'brightgreen'; + break; + case 'projectnotfound': + badgeData.text[1] = 'not found'; + break; + case 'testing': + case 'waiting': + badgeData.text[1] = 'pending'; + break; + case 'error': + badgeData.text[1] = 'failing'; + badgeData.colorscheme = 'red'; + break; + case 'stopped': + badgeData.text[1] = 'not built'; + break; + } + sendBadge(format, badgeData); + } catch(e) { + badgeData.text[1] = 'not found'; + sendBadge(format, badgeData); + } + }); +})); + // Any badge. camp.route(/^\/(:|badge\/)(([^-]|--)+)-(([^-]|--)+)-(([^-]|--)+)\.(svg|png|gif|jpg)$/, function(data, match, end, ask) { From c070fe7a4924446611a6f1653f95a2e835e597ee Mon Sep 17 00:00:00 2001 From: Nico Lindemann Date: Wed, 3 Sep 2014 22:51:37 +0200 Subject: [PATCH 2/4] Add codeship.io support --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 8a3250c..e08d978 100644 --- a/server.js +++ b/server.js @@ -1665,7 +1665,7 @@ cache(function(data, match, sendBadge) { // Codeship.io integration camp.route(/^\/codeship\/(.+)\.(svg|png|gif|jpg)$/, cache(function(data, match, sendBadge) { - var projectId = match[1]; // eg, `github/kabisaict/flow`. + var projectId = match[1]; // eg, `ab123456-00c0-0123-42de-6f98765g4h32`. var format = match[2]; var options = { method: 'GET', From 012d08dd3e44aa7f4a14ec09c767c2bdaa0eb27d Mon Sep 17 00:00:00 2001 From: Thaddee Tyl Date: Fri, 5 Sep 2014 09:15:55 +0200 Subject: [PATCH 3/4] Update ass to v0.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d11ff30..aa59cdf 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "semver": "~2.3.0" }, "devDependencies": { - "ass": "~0.0.4", + "ass": "~0.0.6", "should": "~3.0.0", "mocha": "~1.14.0" }, From 67358e901e37300c848e0492a8b0d74e6d48145b Mon Sep 17 00:00:00 2001 From: Thaddee Tyl Date: Fri, 5 Sep 2014 21:23:11 +0200 Subject: [PATCH 4/4] website: show codeship.io support. --- index.html | 4 ++++ try.html | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/index.html b/index.html index 92eda83..e7163ad 100644 --- a/index.html +++ b/index.html @@ -172,6 +172,10 @@ I made the GitHub Badge Service. http://img.shields.io/appveyor/ci/gruntjs/grunt.svg + Codeship: + + http://img.shields.io/codeship/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1.svg + Coveralls: http://img.shields.io/coveralls/jekyll/jekyll.svg diff --git a/try.html b/try.html index 5ec0edc..83135f2 100644 --- a/try.html +++ b/try.html @@ -171,6 +171,10 @@ I made the GitHub Badge Service. http://img.shields.io/appveyor/ci/gruntjs/grunt.svg + Codeship: + + http://img.shields.io/codeship/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1.svg + Coveralls: http://img.shields.io/coveralls/jekyll/jekyll.svg