Class: Perkins::BuildReport
- Defined in:
- lib/perkins/build_report.rb
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#build_status_report(sha) ⇒ Object
Status report to GITHUB repo.
- #enqueue ⇒ Object
- #github_state ⇒ Object
- #github_state_description ⇒ Object
- #github_state_url ⇒ Object
-
#retrieve_commit_info ⇒ Object
self.commit ||= $github_client.commits(repo.name, sha) Perkins::Commit.new(self.commit) end.
- #send_github_status(sha) ⇒ Object
- #start! ⇒ Object
- #stop! ⇒ Object
Instance Method Details
#as_json(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/perkins/build_report.rb', line 30 def as_json( = {}) data = {} unless fields = [:only] fields = [:id, :sha, :commit, :branch, :build_time, :status, :duration, :build_time, :response, :build_status] end fields.each { |k| data[k] = send(k) } data end |
#build_status_report(sha) ⇒ Object
Status report to GITHUB repo
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/perkins/build_report.rb', line 44 def build_status_report(sha) $github_client.create_status( self.repo.name, sha, github_state, { context: "Perkins CI", description: github_state_description , target_url: github_state_url } ) end |
#enqueue ⇒ Object
9 10 11 |
# File 'lib/perkins/build_report.rb', line 9 def enqueue BuildWorker.perform_async(self.id, sha, branch ) end |
#github_state ⇒ Object
55 56 57 |
# File 'lib/perkins/build_report.rb', line 55 def github_state self.status ? "success" : "failure" end |
#github_state_description ⇒ Object
59 60 61 62 |
# File 'lib/perkins/build_report.rb', line 59 def github_state_description d = "- The Perkins CI build" d = self.status ? "passed" : "fail" end |
#github_state_url ⇒ Object
64 65 66 |
# File 'lib/perkins/build_report.rb', line 64 def github_state_url "#{Perkins::Application.instance.sse_endpoint}/repos/#{repo.name}/builds/#{self.id}" end |
#retrieve_commit_info ⇒ Object
19 20 21 22 23 |
# File 'lib/perkins/build_report.rb', line 19 def retrieve_commit_info hsh = $github_client.commits(repo.name, sha).first.to_attrs self.commit = hsh self.save end |
#send_github_status(sha) ⇒ Object
25 26 27 28 |
# File 'lib/perkins/build_report.rb', line 25 def send_github_status(sha) self.repo.git self.build_status_report(sha) end |
#start! ⇒ Object
68 69 70 |
# File 'lib/perkins/build_report.rb', line 68 def start! update_attribute(:build_status, "started") end |
#stop! ⇒ Object
72 73 74 |
# File 'lib/perkins/build_report.rb', line 72 def stop! update_attribute(:build_status, "stopped") end |