Permalink
Browse files

Add the :fixed status and stop firing email on consecutive success bu…

…ilds
  • Loading branch information...
1 parent 139a67f commit a0a14e663ce7762c09be49dbf23578e103856aba @byroot byroot committed Mar 19, 2013
Showing with 43 additions and 0 deletions.
  1. +25 −0 lib/app/public/integrity.css
  2. +10 −0 lib/integrity/build.rb
  3. +8 −0 lib/integrity/notifier/email.rb
View
25 lib/app/public/integrity.css
@@ -214,6 +214,8 @@ a {
color: #337022; }
#content #projects li a.failed {
color: #ff1100; }
+ #content #projects li a.fixed {
+ color: #ddff88; }
#content #projects li a.building {
color: #777777; }
#content #projects li .meta {
@@ -241,6 +243,17 @@ a {
color: #77b466; }
#content #projects li.success a:hover, #content #previous_builds li.success a:hover {
background-color: #ddffcc; }
+
+ #content #projects li.fixed a, #content #previous_builds li.fixed a {
+ background-color: #bbf855;
+ border-color: #99d644;
+ color: #337011; }
+ #content #projects li.fixed a .attribution, #content #previous_builds li.fixed a .attribution {
+ color: #77b433; }
+ #content #projects li.fixed a:hover, #content #previous_builds li.fixed a:hover {
+ background-color: #ddff99; }
+
+
#content #projects li.failed a, #content #previous_builds li.failed a {
background-color: #ffbbaa;
border-color: #dd9988;
@@ -279,6 +292,18 @@ a {
#content #build.success .meta a:hover, #content #build.success .github a a:hover, #content #last_build.success .meta a:hover, #content #last_build.success .github a a:hover {
color: #bbf8aa;
background-color: #337022; }
+
+ #content #build.fixed h1, #content #build.fixed blockquote, #content #last_build.fixed h1, #content #last_build.fixed blockquote {
+ background-color: #bbf855;
+ border-color: #99d644 #ccff60 #ccff60 #99d644; }
+ #content #build.fixed h1, #content #last_build.fixed h1 {
+ color: #337011; }
+ #content #build.fixed .meta, #content #build.success .github a, #content #last_build.fixed .meta, #content #last_build.success .fixed a {
+ color: #77b433; }
+ #content #build.fixed .meta a:hover, #content #build.fixed .github a a:hover, #content #last_build.fixed .meta a:hover, #content #last_build.fixed .github a a:hover {
+ color: #bbf855;
+ background-color: #337011; }
+
#content #build.failed h1, #content #build.failed blockquote, #content #last_build.failed h1, #content #last_build.failed blockquote {
background-color: #ffbbaa;
border-color: #dd9988 #ffccbb #ffccbb #dd9988; }
View
10 lib/integrity/build.rb
@@ -4,6 +4,7 @@ class Build
HUMAN_STATUS = {
:success => "Built %s successfully",
+ :fixed => "%s has been fixed",
:failed => "Built %s and failed",
:pending => "%s hasn't been built yet",
:building => "%s is building"
@@ -34,6 +35,10 @@ class Build
end
end
+ def previous_build
+ @previous_build ||= Build.first(:order => [:id.desc], :id.lt => id, :project_id => project_id)
+ end
+
def run
Integrity.config.builder.enqueue(self)
end
@@ -46,6 +51,10 @@ def notify
project.enabled_notifiers.each { |n| n.notify(self) }
end
+ def fixed?
+ successful? && previous_build && previous_build.failed?
+ end
+
def successful?
successful == true
end
@@ -132,6 +141,7 @@ def status
case
when building? then :building
when pending? then :pending
+ when fixed? then :fixed
when successful? then :success
when failed? then :failed
end
View
8 lib/integrity/notifier/email.rb
@@ -10,6 +10,14 @@ class Notifier
class Email < Notifier::Base
attr_reader :to, :from
+ def self.notify(build, config)
+ if build.successful? && !build.fixed?
+ Integrity.logger.info("Skiped notifying of build #{build.sha1_short} with #{to_s}")
+ else
+ super
+ end
+ end
+
def self.to_haml
@haml ||= File.read(File.dirname(__FILE__) + "/email.haml")
end

4 comments on commit a0a14e6

@p
p commented on a0a14e6 Mar 21, 2013

Very nice.

@byroot

I'm glad you like It. I wanted to make a PR of it but I don't have much time right now.
But It's not really mature:

  • the previous build method is not properly cached if there is no previous builds
  • The colors for fixed build have been chosen almost randomly
  • I'm not sure if the notification silencing should apply only to email, or if it need some configuration.

Also it need some tests and I have weird issues with the actual one...

@p
p commented on a0a14e6 Mar 21, 2013

Yes, but most features that were implemented recently were done a small step at a time (e.g. json). Feel free to send a PR with just the N database queries fixed (e.g. by adding another column for previous build id). And test coverage would be awesome.

@p
p commented on a0a14e6 Mar 21, 2013

I'm not sure if the notification silencing should apply only to email, or if it need some configuration.

That is actually a great question.

Please sign in to comment.