Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 5 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
7 Gemfile
@@ -11,10 +11,13 @@ gem 'pg'
gem 'rake'
gem 'puma'
gem 'rack-rewrite'
+gem 'redis'
group :assets do
- gem 'rake-pipeline', :git => 'git://github.com/livingsocial/rake-pipeline.git'
- gem 'rake-pipeline-web-filters', :git => 'git://github.com/wycats/rake-pipeline-web-filters.git'
+ gem 'rake-pipeline', :git => 'git://github.com/livingsocial/rake-pipeline.git',
+ :ref => '3465e0e3e134bf52ddf5d138e8c8262412080095'
+ gem 'rake-pipeline-web-filters', :git => 'git://github.com/wycats/rake-pipeline-web-filters.git',
+ :ref => '1a6dc173776b188836aa2ce2ac35b61c7f7daafe'
gem 'uglifier'
gem 'tilt'
View
35 Gemfile.lock
@@ -1,6 +1,7 @@
GIT
remote: git://github.com/livingsocial/rake-pipeline.git
revision: 3465e0e3e134bf52ddf5d138e8c8262412080095
+ ref: 3465e0e3e134bf52ddf5d138e8c8262412080095
specs:
rake-pipeline (0.6.0)
rake (~> 0.9.0)
@@ -8,7 +9,8 @@ GIT
GIT
remote: git://github.com/wycats/rake-pipeline-web-filters.git
- revision: e14e78ae70d0d25b1668c5273e80cd05a4ee52e6
+ revision: 1a6dc173776b188836aa2ce2ac35b61c7f7daafe
+ ref: 1a6dc173776b188836aa2ce2ac35b61c7f7daafe
specs:
rake-pipeline-web-filters (0.6.0)
rack
@@ -19,23 +21,24 @@ GEM
specs:
active_model_serializers (0.6.0)
activemodel (>= 3.0)
- activemodel (3.2.8)
- activesupport (= 3.2.8)
+ activemodel (3.2.9)
+ activesupport (= 3.2.9)
builder (~> 3.0.0)
- activerecord (3.2.8)
- activemodel (= 3.2.8)
- activesupport (= 3.2.8)
+ activerecord (3.2.9)
+ activemodel (= 3.2.9)
+ activesupport (= 3.2.9)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activesupport (3.2.8)
+ activesupport (3.2.9)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.4)
+ excon (0.16.10)
excon (0.16.2)
execjs (1.4.0)
multi_json (~> 1.0)
- fog (1.5.0)
+ fog (1.8.0)
builder
excon (~> 0.14)
formatador (~> 0.2.0)
@@ -45,25 +48,26 @@ GEM
net-ssh (>= 2.1.3)
nokogiri (~> 1.5.0)
ruby-hmac
- formatador (0.2.3)
+ formatador (0.2.4)
i18n (0.6.1)
mime-types (1.19)
- multi_json (1.3.6)
+ multi_json (1.4.0)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
- net-ssh (2.5.2)
+ net-ssh (2.6.2)
nokogiri (1.5.5)
- oj (1.3.4)
+ oj (1.4.6)
pg (0.14.1)
puma (1.6.3)
rack (~> 1.2)
rack (1.4.1)
- rack-rewrite (1.2.1)
- rake (0.9.2.2)
+ rack-rewrite (1.3.1)
+ rake (0.9.5)
+ redis (3.0.2)
ruby-hmac (0.4.0)
thor (0.16.0)
tilt (1.3.3)
- tzinfo (0.3.33)
+ tzinfo (0.3.35)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
@@ -87,6 +91,7 @@ DEPENDENCIES
rake
rake-pipeline!
rake-pipeline-web-filters!
+ redis
tilt
uglifier
webmachine
View
5 assets/javascripts/app/app.js
@@ -1,5 +1,4 @@
-GiddyUp = Ember.Application.create({
-});
+GiddyUp = Ember.Application.create();
require('router');
require('adapter');
@@ -9,3 +8,5 @@ require('models');
require('controllers');
require('templates');
require('views');
+
+require('events');
View
42 assets/javascripts/app/events.js
@@ -0,0 +1,42 @@
+GiddyUp.EventProcessor = Ember.Object.extend({
+ init: function() {
+ this.source = new EventSource('live');
+
+ this.source.addEventListener('test_result', function(e) {
+ var parsedResponse = JSON.parse(e.data);
+ var testResult = parsedResponse.test_result;
+
+ // Load the new test result into the store.
+ //
+ GiddyUp.store.load(GiddyUp.TestResult, testResult);
+
+ // Notification handling.
+ //
+ if (window.webkitNotifications &&
+ window.webkitNotifications.checkPermission() === 0) {
+
+ var result = GiddyUp.TestResult.find(testResult.id);
+ var message = result.get('notification');
+
+ window.webkitNotifications.createNotification(
+ "icon.png", message.title, message.message
+ ).show();
+ }
+ });
+ }
+});
+
+/* Enable live event streams if available. */
+if(!!window.EventSource) {
+ GiddyUp.eventProcessor = GiddyUp.EventProcessor.create({});
+}
+
+/* Prompt the user once to accept nofications. */
+if (window.webkitNotifications &&
+ window.webkitNotifications.checkPermission() !== 0) {
+ GiddyUp.desktopNotifierBinding = $('a').live('click', function() {
+ window.webkitNotifications.requestPermission(function() {
+ GiddyUp.desktopNotifierBinding.die();
+ });
+ });
+}
View
19 assets/javascripts/app/models.js
@@ -70,7 +70,24 @@ GiddyUp.TestResult = DS.Model.extend({
log_url: DS.attr('string'),
created_at: DS.attr('date'),
- long_version: DS.attr('string')
+ long_version: DS.attr('string'),
+
+ notification: function() {
+ var status = this.get('status') === true ? "pass" : "fail";
+ var instance = this.get('test_instance');
+ var scorecard = instance.get('scorecard');
+ var project = scorecard.get('project');
+ var backend = instance.get('backend') || "undefined";
+
+ return {
+ title: "GiddyUp: New " + status + " on " +
+ project.get('name') + " " +
+ scorecard.get('name'),
+ message: instance.get('name') + " | " +
+ backend + " | " +
+ instance.get('platform')
+ };
+ }.property()
});
GiddyUp.Log = DS.Model.extend({
View
1  lib/giddyup.rb
@@ -1,4 +1,5 @@
require 'webmachine/adapters/rack'
+
module GiddyUp
Application = Webmachine::Application.new do |app|
app.configure do |config|
View
15 lib/giddyup/bootstrap.rb
@@ -37,3 +37,18 @@
### BASIC AUTH SETUP
GiddyUp::AUTH_USER = ENV['AUTH_USER']
GiddyUp::AUTH_PASSWORD = ENV['AUTH_PASSWORD']
+
+### RedisToGo Setup
+require 'redis'
+REDISURL = URI.parse(ENV['REDISTOGO_URL'])
+
+module GiddyUp
+ module Redis
+ def self.new
+ ::Redis.new(:host => REDISURL.host,
+ :port => REDISURL.port,
+ :password => REDISURL.password,
+ :timeout => 0)
+ end
+ end
+end
View
15 lib/giddyup/contexts.rb
@@ -1,8 +1,10 @@
+require 'json'
module GiddyUp
# Context that creates a test result
class CreateTestResult
def initialize
@test_result = TestResult.new
+ @redis = GiddyUp::Redis.new
end
def id
@@ -21,12 +23,23 @@ def create_test_result(data)
@test_result.log_url = log.public_url
end
@test_result.save!
+ publish_test_result
true
rescue
- false
+ 500
end
end
+ def publish_test_result
+ result = TestResultSerializer.new(@test_result)
+
+ @redis.publish 'events', JSON.generate({
+ :id => id,
+ :event => 'test_result',
+ :data => { :test_result => result.serializable_hash }
+ })
+ end
+
def create_log(data)
directory = S3.directories.get(LogBucket) || S3.directories.create(:key => LogBucket, :public => true)
fname = "#{id}.log"
View
38 lib/giddyup/resources.rb
@@ -1,4 +1,6 @@
require 'stringio'
+require 'json'
+
module GiddyUp
# When modifying a record, wraps the resource in a transaction that
# can be rolled back if the request is not successful.
@@ -73,6 +75,41 @@ def query_ids
end
end
+ class LiveResource < Webmachine::Resource
+ def initialize
+ @redis = GiddyUp::Redis.new
+ set_headers
+ end
+
+ def set_headers
+ response.headers['Connection'] ||= 'keep-alive'
+ response.headers['Cache-Control'] ||= 'no-cache'
+ end
+
+ def allowed_methods
+ %W[GET]
+ end
+
+ def content_types_provided
+ [['text/event-stream', :to_event]]
+ end
+
+ def to_event
+ Fiber.new do |f|
+ @redis.subscribe('events') do |on|
+ on.message do |channel, msg|
+ message = JSON.parse(msg)
+ id = message["id"]
+ event = message["event"]
+ data = JSON.generate(message["data"])
+
+ Fiber.yield "id: #{id}\nevent: #{event}\ndata: #{data}\n\n"
+ end
+ end
+ end
+ end
+ end
+
# Allows posting of a new test result (or fetching an existing
# result). This should be in JSON or multipart/form-data, depending
# on the contents of the log data and the capabilities of the
@@ -275,6 +312,7 @@ def to_json
end
Application.routes do
+ add ['live'], LiveResource
add ['scorecards', :id], ScorecardResource
add ['scorecards'], ScorecardsResource
add ['logs', :id], LogResource

No commit comments for this range

Something went wrong with that request. Please try again.