ciquantum 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
25
25
  gem.add_runtime_dependency 'sinatra'
26
26
  gem.add_runtime_dependency 'choice'
27
27
  gem.add_runtime_dependency 'pony'
28
- gem.add_runtime_dependency 'sq_auth', '>= 0.0.21'
28
+ gem.add_runtime_dependency 'sq_auth', '>= 0.0.24'
29
29
  gem.add_development_dependency 'rack-test'
30
30
  gem.add_development_dependency 'mocha'
31
31
 
@@ -3,6 +3,8 @@ require 'ciquantum/version'
3
3
  require 'ciquantum/config'
4
4
  require 'ciquantum/unfuddle'
5
5
  require 'ciquantum/unfuddle/changeset'
6
+ require 'ciquantum/utils/mailer'
7
+ require 'ciquantum/utils/coverage_merger'
6
8
  require 'ciquantum/commit'
7
9
  require 'ciquantum/build'
8
10
  require 'ciquantum/server'
@@ -133,7 +133,7 @@ module CIQuantum
133
133
  end
134
134
 
135
135
  def git_update
136
- `cd #{@project_path} && git fetch origin && git reset --hard origin/#{git_branch}`
136
+ `cd #{@project_path} && git fetch origin && git submodule update && git reset --hard origin/#{git_branch}`
137
137
  run_hook "after-reset"
138
138
  end
139
139
 
@@ -48,16 +48,12 @@ module CIQuantum
48
48
 
49
49
  post '/build' do
50
50
  quantum.build quantum.repo_config.branch
51
-
52
- link_coverage_path
53
51
  redirect '/'
54
52
  end
55
53
 
56
54
  post '/switch_branch' do
57
55
  quantum.swith_branch params[:branch]
58
56
  quantum.build params[:branch]
59
-
60
- link_coverage_path
61
57
  redirect '/'
62
58
  end
63
59
 
@@ -77,7 +73,6 @@ module CIQuantum
77
73
  xml = request.body.read
78
74
  changeset = Unfuddle::Changeset.new(xml)
79
75
  quantum.build quantum.repo_config.branch
80
- link_coverage_path
81
76
  rescue Unfuddle::ChangesetError => e
82
77
  logger.error "[error] Changeset error: #{e.inspect}, Content: #{xml.inspect}"
83
78
  halt 400, "Changeset Error: #{e.message}"
@@ -85,6 +80,7 @@ module CIQuantum
85
80
  end
86
81
 
87
82
  get ["ci::view"], '/coverage?' do
83
+ link_coverage_path
88
84
  redirect "coverage/index.html"
89
85
  end
90
86
 
@@ -0,0 +1,22 @@
1
+ require 'json'
2
+
3
+ module CIQuantum
4
+ module Utils
5
+ module CoverageMerger
6
+
7
+ def self.merge *child_project_paths
8
+ coverage = {}
9
+ child_project_paths.each do |path|
10
+ resultset = JSON.parse File.read(File.join path, "coverage/.resultset.json")
11
+ resultset.each do |key, value|
12
+ coverage = value["coverage"].merge_resultset coverage
13
+ end
14
+ end
15
+
16
+ merged_result = ::SimpleCov::Result.from_hash({"Combined" => { "coverage" => coverage, "timestamp" => Time.now.to_i }})
17
+ ::SimpleCov::ResultMerger.store_result merged_result
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,63 @@
1
+ require 'erb'
2
+ require 'pony'
3
+ require 'json'
4
+ require 'cgi'
5
+
6
+ module CIQuantum
7
+ module Utils
8
+ class Mailer
9
+
10
+ Captions = {
11
+ failed: "Build failed",
12
+ still_failed: "Buils hasn't been repaired yet",
13
+ repaired: "Build repaired",
14
+ worked: "Build worked"
15
+ }
16
+
17
+ attr_accessor :roles_with_keys
18
+ attr_accessor :project
19
+
20
+ def initialize project, roles_with_keys
21
+ @project = project
22
+ @roles_with_keys = roles_with_keys
23
+ end
24
+
25
+ def send_mail type, subject, body
26
+ data = "email=" + CGI::escape({subject: subject, body: body, type: type}.to_json)
27
+ @roles_with_keys.each do |role, api_key|
28
+ uri = URI.parse "https://sqauth.socialquantum.com/send_email/#{@project}/#{role}/#{api_key}"
29
+ http = Net::HTTP.new(uri.host, uri.port)
30
+ http.use_ssl = true
31
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
32
+ response = http.post(uri.path, data, { 'Content-Type' => 'application/x-www-form-urlencoded' })
33
+ end
34
+ end
35
+
36
+ def template name, template_path = nil
37
+ template_path ||= File.expand_path "#{File.dirname __FILE__}/../views/mailer"
38
+ template = File.read(File.join template_path, "#{name}.erb")
39
+ ERB.new(template)
40
+ end
41
+
42
+ def send_template template, build, status
43
+ @build = build
44
+ @status = status
45
+ @caption = Captions[status]
46
+
47
+ body = template(template.to_s).result(binding)
48
+ subject = "CIServer: state on branch #{build.branch}"
49
+ send_mail template.to_s, subject, body
50
+
51
+ end
52
+
53
+ def send_html build, status
54
+ send_template :html, build, status
55
+ end
56
+
57
+ def send_plain build, status
58
+ send_template :text, build, status
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -1,3 +1,3 @@
1
1
  module CIQuantum
2
- Version = VERSION = "0.0.6"
2
+ Version = VERSION = "0.0.8"
3
3
  end
@@ -0,0 +1,48 @@
1
+ <head>
2
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
3
+ <title>[<%= @project %>] CIServer: state on branch <%= @build.branch %></title>
4
+ <style type="text/css">
5
+
6
+ .title {
7
+ font-size: 120%;
8
+ font-family: Verdana, Arial, Helvetica, sans-serif;
9
+ border: 1px solid black;
10
+ margin: 10px 20px;
11
+ padding: 20px 10px;
12
+ }
13
+
14
+ .failed {
15
+ background-color: #CC0000;
16
+ }
17
+
18
+ .worked {
19
+ background-color: #00CC00;
20
+ }
21
+
22
+ pre {
23
+ border: 1px solid black;
24
+ background-color: #E0E0E0;
25
+ }
26
+
27
+ </style>
28
+ </head>
29
+ <body>
30
+ <div class="title <%= @build.status.to_s %>"><%= @caption %></div><br>
31
+ <div class="text">
32
+ Last build <%= @project %> on branch <%= @build.branch %> <%= @build.status.to_s %>."<br><br>
33
+
34
+ Details: <%= @build.commit.url %><br>
35
+ Author: <%= @build.commit.author %><br>
36
+ Message: <%= @build.commit.message %><br>
37
+ </div>
38
+ <% if @build.status == :failed %>
39
+ <br>
40
+ <code>
41
+ <pre>
42
+ Output:<br>
43
+ <%= @build.clean_output %>
44
+ </pre>
45
+ </code>
46
+ <% end %>
47
+ <br><br><br>
48
+ </body>
@@ -0,0 +1,48 @@
1
+ <head>
2
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
3
+ <title>[<%= @project %>] CIServer: state on branch <%= @build.branch %></title>
4
+ <style type="text/css">
5
+
6
+ .title {
7
+ font-size: 120%;
8
+ font-family: Verdana, Arial, Helvetica, sans-serif;
9
+ border: 1px solid black;
10
+ margin: 10px 20px;
11
+ padding: 20px 10px;
12
+ }
13
+
14
+ .failed {
15
+ background-color: #CC0000;
16
+ }
17
+
18
+ .worked {
19
+ background-color: #00CC00;
20
+ }
21
+
22
+ pre {
23
+ border: 1px solid black;
24
+ background-color: #E0E0E0;
25
+ }
26
+
27
+ </style>
28
+ </head>
29
+ <body>
30
+ <div class="title <%= @build.status.to_s %>"><%= @caption %></div><br>
31
+ <div class="text">
32
+ Last build <%= @project %> on branch <%= @build.branch %> <%= @build.status.to_s %>."<br><br>
33
+
34
+ Details: <%= @build.commit.url %><br>
35
+ Author: <%= @build.commit.author %><br>
36
+ Message: <%= @build.commit.message %><br>
37
+ </div>
38
+ <% if @build.status == :failed %>
39
+ <br>
40
+ <code>
41
+ <pre>
42
+ Output:<br>
43
+ <%= @build.clean_output %>
44
+ </pre>
45
+ </code>
46
+ <% end %>
47
+ <br><br><br>
48
+ </body>
@@ -0,0 +1,12 @@
1
+ <%= @caption %>
2
+
3
+ Last build <%= @project %> on branch <%= @build.branch %> <%= @build.status.to_s %>.
4
+
5
+ Details: <%= @build.commit.url %>
6
+ Author: <%= @build.commit.author %>
7
+ Message: <%= @build.commit.message %>
8
+
9
+ <% if @build.status == :failed %>
10
+ Output:
11
+ <%= @build.clean_output %>
12
+ <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ciquantum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-05-03 00:00:00.000000000 Z
14
+ date: 2012-05-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -132,7 +132,7 @@ dependencies:
132
132
  requirements:
133
133
  - - ! '>='
134
134
  - !ruby/object:Gem::Version
135
- version: 0.0.21
135
+ version: 0.0.24
136
136
  type: :runtime
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
@@ -140,7 +140,7 @@ dependencies:
140
140
  requirements:
141
141
  - - ! '>='
142
142
  - !ruby/object:Gem::Version
143
- version: 0.0.21
143
+ version: 0.0.24
144
144
  - !ruby/object:Gem::Dependency
145
145
  name: rack-test
146
146
  requirement: !ruby/object:Gem::Requirement
@@ -202,8 +202,13 @@ files:
202
202
  - lib/ciquantum/server.rb
203
203
  - lib/ciquantum/unfuddle.rb
204
204
  - lib/ciquantum/unfuddle/changeset.rb
205
+ - lib/ciquantum/utils/coverage_merger.rb
206
+ - lib/ciquantum/utils/mailer.rb
205
207
  - lib/ciquantum/version.rb
206
208
  - lib/ciquantum/views/json.erb
209
+ - lib/ciquantum/views/mail.erb
210
+ - lib/ciquantum/views/mailer/html.erb
211
+ - lib/ciquantum/views/mailer/text.erb
207
212
  - lib/ciquantum/views/template.erb
208
213
  - sample.rb
209
214
  - test/fixtures/payload.json