-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have every `Event::Build` subclass in a different file, as it is normally done in Rails.
- Loading branch information
Showing
4 changed files
with
65 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class Event::BuildFail < Event::Build | ||
include BuildLogSupport | ||
|
||
self.description = 'Package has failed to build' | ||
receiver_roles :maintainer, :bugowner, :reader, :watcher | ||
after_create_commit :send_to_bus | ||
|
||
def self.message_bus_routing_key | ||
"#{Configuration.amqp_namespace}.package.build_fail" | ||
end | ||
|
||
def subject | ||
"Build failure of #{payload['project']}/#{payload['package']} in #{payload['repository']}/#{payload['arch']}" | ||
end | ||
|
||
def faillog | ||
begin | ||
size = get_size_of_log(payload['project'], payload['package'], payload['repository'], payload['arch']) | ||
offset = size - 18 * 1024 | ||
offset = 0 if offset < 0 | ||
log = raw_log_chunk(payload['project'], payload['package'], payload['repository'], payload['arch'], offset, size) | ||
begin | ||
log.encode!(invalid: :replace, undef: :replace, universal_newline: true) | ||
rescue Encoding::UndefinedConversionError | ||
# encode is documented not to throw it if undef: is :replace, but at least we tried - and ruby 1.9.3 is buggy | ||
end | ||
log = log.chomp.lines | ||
if log.length > 30 | ||
log = log.slice(-29, log.length) | ||
end | ||
log.join | ||
rescue ActiveXML::Transport::Error | ||
nil | ||
end | ||
end | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Event::BuildSuccess < Event::Build | ||
self.description = 'Package has succeeded building' | ||
after_create_commit :send_to_bus | ||
|
||
def self.message_bus_routing_key | ||
"#{Configuration.amqp_namespace}.package.build_success" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Event::BuildUnchanged < Event::Build | ||
self.description = 'Package has succeeded building with unchanged result' | ||
after_create_commit :send_to_bus | ||
|
||
def self.message_bus_routing_key | ||
"#{Configuration.amqp_namespace}.package.build_unchanged" | ||
end | ||
end |