Skip to content

Commit

Permalink
[api] include some headers in the build fail mail header
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Dec 14, 2013
1 parent 66eacaa commit 6231f4d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
9 changes: 9 additions & 0 deletions src/api/app/models/event/build.rb
Expand Up @@ -46,6 +46,15 @@ def expanded_payload
payload.merge('faillog' => faillog)
end

def custom_headers
h = super
h['X-OBS-Package'] = "#{payload['project']}/#{payload['package']}"
h['X-OBS-Repository'] = "#{payload['repository']}/#{payload['arch']}"
h['X-OBS-Worker'] = payload['workerid']
h['X-OBS-Rebuild-Reason'] = payload['reason']
h
end

end

class Event::BuildUnchanged < Event::Build
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/event_mailer/build_fail.text.erb
Expand Up @@ -3,7 +3,7 @@ Visit <%= url_for(controller: 'webui/package', action: :live_build_log, project:
Package <%= @e['project'] %>/<%= @e['package']%> failed to build in <%= @e['repository']%>/<%= @e['arch']%>

Check out the package for editing:
osc checkout <%= @e['project']%> <%= @e['package']%>
osc checkout <%= @e['project']%> <%= @e['package']%>
<% if @e['faillog'] -%>

Last lines of build log:
Expand Down
29 changes: 25 additions & 4 deletions src/api/test/fixtures/event_mailer/build_fail
@@ -1,13 +1,34 @@
Visit http://localhost/package/live_build_log/home:Iggy/TestPack/10.2/i586
From: obs-email@opensuse.org
Reply-To: obs-email@opensuse.org
To: Iggy@pop.org
Message-ID: <test@localhost>
Subject: Build failure of home:Iggy/TestPack in 10.2/i586
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Precedence: bulk
X-Mailer: OBS Notification System
X-OBS-URL: http://localhost
Auto-Submitted: auto-generated
X-OBS-event-type: build_fail
X-OBS-Package: home:Iggy/TestPack
X-OBS-Repository: 10.2/i586
X-OBS-Worker: build12
X-OBS-Rebuild-Reason: new build

Visit http://localhost/package/live_build_log/home:Iggy/TestPack/10.2/i58=
6

Package home:Iggy/TestPack failed to build in 10.2/i586

Check out the package for editing:
osc checkout home:Iggy TestPack
osc checkout home:Iggy TestPack

Last lines of build log:
[1] this is my dummy logfile -> ümlaut
[1] this is my dummy logfile -> =C3=BCmlaut

-- =

--
Configure notifications at http://localhost/user/notifications
Open Build Service (http://localhost/)
3 changes: 1 addition & 2 deletions src/api/test/fixtures/events.yml
Expand Up @@ -91,8 +91,7 @@ events_5:
build_failure_for_iggy:
id: 6
eventtype: Event::BuildFail
payload: '{"project":"home:Iggy","package":"TestPack","repository":"10.2","arch":"i586","release":"42.1","versrel":"1.0-42","readytime":"1377958901","srcmd5":"1ac07842727acaf13d0e2b3213b47785","rev":"2","revtime":"1377958897","reason":"new
build","bcnt":"1","verifymd5":"1ac07842727acaf13d0e2b3213b47785"}'
payload: '{"project":"home:Iggy","package":"TestPack","repository":"10.2","arch":"i586","release":"42.1","versrel":"1.0-42","readytime":"1377958901","srcmd5":"1ac07842727acaf13d0e2b3213b47785","rev":"2","revtime":"1377958897","reason":"new build","bcnt":"1","verifymd5":"1ac07842727acaf13d0e2b3213b47785","workerid":"build12"}'
queued: 0
lock_version: 0
created_at: 2013-08-31 14:56:52.000000000 Z
Expand Down
11 changes: 7 additions & 4 deletions src/api/test/unit/event_mailer_test.rb
Expand Up @@ -3,6 +3,12 @@
class EventMailerTest < ActionMailer::TestCase
fixtures :all

def verify_email(fixture_name, email)
email.message_id = '<test@localhost>'
should = load_fixture("event_mailer/#{fixture_name}").chomp
assert_equal should, email.encoded.lines.map(&:chomp).select { |l| l !~ %r{^Date:} }.join("\n")
end

test "commit event" do

mail = EventMailer.event(users(:adrian), events(:pack1_commit))
Expand All @@ -20,9 +26,6 @@ class EventMailerTest < ActionMailer::TestCase
Suse::Backend.wait_for_scheduler_start

mail = EventMailer.event(users(:Iggy), events(:build_failure_for_iggy))
assert_equal "Build failure of home:Iggy/TestPack in 10.2/i586", mail.subject
assert_equal ["Iggy@pop.org"], mail.to
assert_equal read_fixture('build_fail').join, mail.body.to_s

verify_email('build_fail', mail)
end
end

0 comments on commit 6231f4d

Please sign in to comment.