ciquantum 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -16,3 +16,20 @@ RubyGems:
16
16
  $ ciquantum yourrepo
17
17
 
18
18
  Anvanced details see on [original repo](https://github.com/defunkt/cijoe)
19
+
20
+ Usage details
21
+ -------------
22
+ At current moment gem uses Unfuddle adapter, and must be configured for proper working with it
23
+
24
+ Expected options:
25
+ -----------------
26
+
27
+ git config --add ciquantum.runner "command to do on build"
28
+ git config --add ciquantum.branch branch_name
29
+ git config --add ciquantum.buildqueue true
30
+ git config --add ciquantum.projectname project_name_to_show
31
+ git config --add ciquantum.coverage_path relative_path_to_coverage_report
32
+
33
+ *Unfuddle (default) adapter:*
34
+ git config --add ciquantum.unfuddle.project unfuddle_user_name
35
+ git config --add ciquantum.unfuddle.user unfuddle_project_id
data/lib/ciquantum.rb CHANGED
@@ -145,11 +145,12 @@ class CIQuantum
145
145
  end
146
146
 
147
147
  def git_user_and_project
148
- Adapter.default_adapter.git_user_and_project
148
+ adapter_config = repo_config.send Adapter.default_adapter.name
149
+ Adapter.default_adapter.git_user_and_project adapter_config
149
150
  end
150
151
 
151
152
  def project_url
152
- Adapter.default_adapter.project_url
153
+ Adapter.default_adapter.project_url @user, @project
153
154
  end
154
155
 
155
156
  def git_branches
@@ -182,7 +183,7 @@ class CIQuantum
182
183
  ENV.clear
183
184
  data.each{ |k, v| ENV[k] = v }
184
185
  output = `cd #{@project_path} && #{file}`
185
-
186
+
186
187
  ENV.clear
187
188
  orig_ENV.to_hash.each{ |k, v| ENV[k] = v}
188
189
  output
@@ -2,10 +2,14 @@ require 'ciquantum/unfuddle_adapter'
2
2
 
3
3
  class CIQuantum
4
4
  class Adapter
5
+ class << self
6
+
7
+ attr_writer :default_adapter
8
+
9
+ def default_adapter
10
+ @default_adapter ||= CIQuantum::UnfuddleAdapter
11
+ end
5
12
 
6
- def self.default_adapter
7
- CIQuantum::UnfuddleAdapter
8
13
  end
9
-
10
14
  end
11
15
  end
@@ -30,6 +30,13 @@ class CIQuantum
30
30
  @parent ? "#{@parent.config_string}.#{@command}" : @command
31
31
  end
32
32
 
33
+ def set value
34
+ git_command = "cd #{@project_path} && git config --replace-all #{config_string} #{value.to_s}"
35
+ puts "Executing command: #{git_command}"
36
+ `#{git_command} 2>&1`
37
+ successful_command? $?
38
+ end
39
+
33
40
  private
34
41
 
35
42
  def successful_command?(process_status)
@@ -82,7 +82,7 @@ ul.posts {
82
82
  ul.posts li {
83
83
  line-height: 1.75em;
84
84
  }
85
-
85
+
86
86
  ul.posts .date,
87
87
  ul.posts .duration {
88
88
  color: #aaa;
@@ -28,18 +28,24 @@ class CIQuantum
28
28
  end
29
29
 
30
30
  post '/?' do
31
+ puts params
31
32
  unless params[:rebuild]
32
33
  payload = JSON.parse(params[:payload])
33
34
  pushed_branch = payload["ref"].split('/').last
34
35
  end
35
-
36
+
36
37
  # Only build if we were given an explicit branch via `?branch=blah`
37
- # or the payload exists and the "ref" property matches our
38
+ # or the payload exists and the "ref" property matches our
38
39
  # specified build branch.
39
40
  if params[:branch] || params[:rebuild] || pushed_branch == quantum.git_branch
40
41
  quantum.build(params[:branch])
41
42
  end
42
43
 
44
+ if params[:switch] == "Switch branch"
45
+ quantum.repo_config.branch.set params[:branch] if quantum.git_branches.include? params[:branch]
46
+ end
47
+
48
+
43
49
  redirect request.path
44
50
  end
45
51
 
@@ -1,19 +1,21 @@
1
1
  class CIQuantum
2
2
  class UnfuddleAdapter
3
3
 
4
+ def self.name
5
+ "unfuddle"
6
+ end
7
+
4
8
  def self.commit_url commit
5
9
  "http://#{commit.user}.unfuddle.com/a#/repositories/#{commit.project}/commit?commit=#{commit.sha}"
6
10
  end
7
11
 
8
- def self.git_user_and_project
9
- ["linkfeed", "17607"]
12
+ def self.git_user_and_project config
13
+ [ (config.user.empty? ? "linkfeed" : config.user), (config.project.empty? ? "17607" : config.project)]
10
14
  end
11
15
 
12
- def self.project_url
13
- user, project = git_user_and_project
14
- "https://#{user}.unfuddle.com/a#/repositories/#{project}/browse"
16
+ def self.project_url user, project
17
+ "https://#{user}.unfuddle.com/a#/repositories/#{project}/browse"
15
18
  end
16
19
 
17
-
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  class CIQuantum
2
- Version = VERSION = "0.0.1"
2
+ Version = VERSION = "0.0.2"
3
3
  end
@@ -33,7 +33,8 @@
33
33
  <option value="<%= @branch %>" <%= "selected=\"selected\"" if (@branch == quantum.git_branch) %> >"<%= @branch %>"</option>
34
34
  <% end %>
35
35
  </select>
36
- <input type="submit" value="Build"/>
36
+ <input type="submit" name="switch" value="Build once"/>
37
+ <input type="submit" name="switch" value="Switch branch"/>
37
38
  </form>
38
39
  </li>
39
40
  <% end %>
data/test/test_hooks.rb CHANGED
@@ -5,7 +5,7 @@ class File
5
5
  class << self
6
6
  alias orig_exists? exists?
7
7
  alias orig_executable? executable?
8
-
8
+
9
9
  def exists?(f)
10
10
  return true if $hook_override
11
11
  orig_exists? f
@@ -22,12 +22,12 @@ class CIQuantum
22
22
  attr_writer :last_build
23
23
  alias orig_path_in_project path_in_project
24
24
  alias orig_git_user_and_project git_user_and_project
25
-
25
+
26
26
  def path_in_project(f)
27
27
  return '/tmp/test' if $hook_override
28
28
  orig_path_in_project
29
29
  end
30
-
30
+
31
31
  def git_user_and_project
32
32
  return ['mine','yours'] if $hook_override
33
33
  orig_git_user_and_project
@@ -44,7 +44,7 @@ class TestHooks < Test::Unit::TestCase
44
44
  def teardown
45
45
  $hook_override = nil
46
46
  end
47
-
47
+
48
48
  def setup
49
49
  $hook_override = true
50
50
  open("/tmp/test",'w') do |file|
@@ -53,26 +53,26 @@ class TestHooks < Test::Unit::TestCase
53
53
  file.write "export test=foo\n"
54
54
  end
55
55
  File.chmod(0777,'/tmp/test')
56
-
56
+
57
57
  @ciquantum = CIQuantum.new('/tmp')
58
58
  @ciquantum.last_build = CIQuantum::Build.new "path", "user", "project", Time.now, Time.now,
59
59
  "deadbeef", :failed, "output", nil
60
60
  @ciquantum.last_build.commit.raw_commit = "Author: commit author\nDate: now"
61
61
  end
62
-
62
+
63
63
  def test_leave_env_intact
64
64
  ENV['AUTHOR'] = 'foo'
65
65
  @ciquantum.run_hook("/tmp/test")
66
66
  assert ENV.size != 0, 'ENV is empty but should not be'
67
67
  assert ENV['AUTHOR'] == 'foo', 'ENV munged a value'
68
68
  end
69
-
69
+
70
70
  def test_empty_hook_env
71
71
  ENV["test"] = 'should not be shown'
72
72
  output = @ciquantum.run_hook("/tmp/test")
73
73
  assert_equal "\ncommit author\n", output
74
74
  end
75
-
75
+
76
76
  def test_hook_munge_env
77
77
  ENV['test'] = 'bar'
78
78
  output = @ciquantum.run_hook("/tmp/test")
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: