lib/perkins/build_report.rb in perkins-0.0.2 vs lib/perkins/build_report.rb in perkins-0.0.3

- old
+ new

@@ -5,10 +5,15 @@ def commit self.repo.load_git @commit ||= Perkins::Commit.new(self.sha, self.repo) end + def send_github_status(sha) + self.repo.git + self.build_status_report(sha) + end + def as_json(options = {}) data = {} unless fields = options[:only] fields = [:id, :sha, :commit, :branch, :build_time, @@ -16,9 +21,37 @@ end fields.each { |k| data[k] = send(k) } data + end + + + + # Status report to GITHUB repo + + 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 + + def github_state + self.status ? "success" : "failure" + end + + def github_state_description + d = "- The Perkins CI build" + d = self.status ? "passed" : "fail" + end + + def github_state_url + "#{Perkins::Application.instance.sse_endpoint}/repos/#{repo.name}/builds/#{self.id}" end end end \ No newline at end of file