octopusci 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/octopusci/queue.rb +5 -10
- data/lib/octopusci/version.rb +1 -1
- data/spec/lib/octopusci/queue_spec.rb +14 -14
- metadata +30 -30
data/lib/octopusci/queue.rb
CHANGED
@@ -3,31 +3,26 @@ require 'resque'
|
|
3
3
|
module Octopusci
|
4
4
|
module Queue
|
5
5
|
def self.enqueue(job_klass, proj_name, branch_name, github_payload, job_conf)
|
6
|
-
resque_opts = { "class" => job_klass, "args" => [proj_name, branch_name] }
|
7
6
|
gh_pl_key = github_payload_key(proj_name, branch_name)
|
8
7
|
|
9
|
-
if
|
8
|
+
if job_pending?('octopusci:commit', proj_name, branch_name)
|
10
9
|
self.redis.set(gh_pl_key, Resque::encode(github_payload))
|
11
10
|
|
12
11
|
job = Octopusci::JobStore.list_repo_branch(proj_name, branch_name, 0, 1).first
|
13
12
|
if job
|
14
13
|
Octopusci::JobStore.set(job['id'], job.merge(Octopusci::Helpers.gh_payload_to_job_attrs(github_payload)))
|
15
|
-
end
|
14
|
+
end
|
16
15
|
else
|
17
16
|
# Create a new job for this project with the appropriate data
|
18
17
|
job_id = Octopusci::JobStore.prepend(Octopusci::Helpers.gh_payload_to_job_attrs(github_payload).merge('status' => 'pending'))
|
19
|
-
resque_opts["args"] << job_id
|
20
|
-
resque_opts["args"] << job_conf
|
21
18
|
self.redis.set(gh_pl_key, Resque::encode(github_payload))
|
22
|
-
Resque.push('octopusci:commit',
|
19
|
+
Resque.push('octopusci:commit', { "class" => job_klass, "args" => [proj_name, branch_name, job_id, job_conf] })
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
26
|
-
def self.
|
23
|
+
def self.job_pending?(queue, proj_name, branch_name)
|
27
24
|
size = Resque.size(queue)
|
28
|
-
[Resque.peek(queue, 0, size)].flatten.any? { |v|
|
29
|
-
v == item
|
30
|
-
}
|
25
|
+
return [Resque.peek(queue, 0, size)].flatten.any? { |v| v["args"][0] == proj_name && v["args"][1] == branch_name }
|
31
26
|
end
|
32
27
|
|
33
28
|
def self.github_payload(project_name, branch_name)
|
data/lib/octopusci/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe "Octopusci::Queueu" do
|
|
8
8
|
@mock_redis.stub(:set)
|
9
9
|
Resque.stub(:push)
|
10
10
|
Octopusci::Helpers.stub(:gh_payload_to_job_attrs).and_return({})
|
11
|
-
Octopusci::Queue.stub(:
|
11
|
+
Octopusci::Queue.stub(:job_pending?).and_return(false)
|
12
12
|
Octopusci::JobStore.should_receive(:prepend)
|
13
13
|
Octopusci::Queue.enqueue('SomeTestJobKlass', 'repo-name', 'branch-name', github_payload, proj_info)
|
14
14
|
end
|
@@ -21,7 +21,7 @@ describe "Octopusci::Queueu" do
|
|
21
21
|
Octopusci::JobStore.stub(:prepend)
|
22
22
|
Octopusci::Queue.stub(:redis).and_return(r)
|
23
23
|
Octopusci::Helpers.stub(:gh_payload_to_job_attrs).and_return({})
|
24
|
-
Octopusci::Queue.stub(:
|
24
|
+
Octopusci::Queue.stub(:job_pending?).and_return(false)
|
25
25
|
r.should_receive(:set)
|
26
26
|
Octopusci::Queue.enqueue('SomeTestJobKlass', 'repo-name', 'branch-name', github_payload, proj_info)
|
27
27
|
end
|
@@ -32,7 +32,7 @@ describe "Octopusci::Queueu" do
|
|
32
32
|
Octopusci::JobStore.stub(:prepend)
|
33
33
|
@mock_redis.stub(:set)
|
34
34
|
Octopusci::Helpers.stub(:gh_payload_to_job_attrs).and_return({})
|
35
|
-
Octopusci::Queue.stub(:
|
35
|
+
Octopusci::Queue.stub(:job_pending?).and_return(false)
|
36
36
|
Resque.should_receive(:push)
|
37
37
|
Octopusci::Queue.enqueue('SomeTestJobKlass', 'repo-name', 'branch-name', github_payload, proj_info)
|
38
38
|
end
|
@@ -42,7 +42,7 @@ describe "Octopusci::Queueu" do
|
|
42
42
|
github_payload = { :some => 'github_payload' }
|
43
43
|
r = mock('redis')
|
44
44
|
Octopusci::JobStore.stub(:list_repo_branch).and_return([])
|
45
|
-
Octopusci::Queue.stub(:
|
45
|
+
Octopusci::Queue.stub(:job_pending?).and_return(true)
|
46
46
|
Octopusci::Queue.stub(:redis).and_return(r)
|
47
47
|
r.should_receive(:set).with(Octopusci::Queue.github_payload_key('repo-name', 'branch-name'), Resque::encode(github_payload))
|
48
48
|
Octopusci::Queue.enqueue('SomeTestJobKlass', 'repo-name', 'branch-name', github_payload, proj_info)
|
@@ -52,7 +52,7 @@ describe "Octopusci::Queueu" do
|
|
52
52
|
proj_info = { :some => 'proj_info' }
|
53
53
|
github_payload = { :some => 'github_payload' }
|
54
54
|
@mock_redis.stub(:set)
|
55
|
-
Octopusci::Queue.stub(:
|
55
|
+
Octopusci::Queue.stub(:job_pending?).and_return(true)
|
56
56
|
Octopusci::JobStore.should_receive(:list_repo_branch).with('repo-name', 'branch-name', 0, 1).and_return([])
|
57
57
|
Octopusci::Queue.enqueue('SomeTestJobKlass', 'repo-name', 'branch-name', github_payload, proj_info)
|
58
58
|
end
|
@@ -61,7 +61,7 @@ describe "Octopusci::Queueu" do
|
|
61
61
|
proj_info = { :some => 'proj_info' }
|
62
62
|
github_payload = { :some => 'github_payload' }
|
63
63
|
@mock_redis.stub(:set)
|
64
|
-
Octopusci::Queue.stub(:
|
64
|
+
Octopusci::Queue.stub(:job_pending?).and_return(true)
|
65
65
|
Octopusci::Helpers.stub(:gh_payload_to_job_attrs).and_return(github_payload)
|
66
66
|
Octopusci::JobStore.stub(:list_repo_branch).and_return([ { 'id' => 23 }.merge(github_payload) ])
|
67
67
|
Octopusci::JobStore.should_receive(:set).with(23, { 'id' => 23 }.merge(github_payload))
|
@@ -70,29 +70,29 @@ describe "Octopusci::Queueu" do
|
|
70
70
|
|
71
71
|
end
|
72
72
|
|
73
|
-
describe "#
|
73
|
+
describe "#job_pending?" do
|
74
74
|
it "should get the size of the provided queue" do
|
75
75
|
@mock_redis.stub(:lrange)
|
76
76
|
Resque.should_receive(:size).with("test:queue").and_return(0)
|
77
|
-
Octopusci::Queue.
|
77
|
+
Octopusci::Queue.job_pending?("test:queue", "test-proj-name", "test-branch-name")
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should get the entire list of queued jobs" do
|
81
81
|
Resque.stub(:size).and_return(2)
|
82
|
-
Resque.should_receive(:peek).with("test:queue", 0, 2)
|
83
|
-
Octopusci::Queue.
|
82
|
+
Resque.should_receive(:peek).with("test:queue", 0, 2).and_return([])
|
83
|
+
Octopusci::Queue.job_pending?("test:queue", "test-proj-name", "test-branch-name")
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should return true if the provided item exists in the queue identified by the provided queue name" do
|
87
87
|
Resque.stub(:size).and_return(2)
|
88
|
-
Resque.stub(:peek).and_return([ {
|
89
|
-
Octopusci::Queue.
|
88
|
+
Resque.stub(:peek).and_return([ { "args" => ["some-proj", "some-repo"] }, { "args" => ["test-proj-name", "test-branch-name"] } ])
|
89
|
+
Octopusci::Queue.job_pending?("test:queue", "test-proj-name", "test-branch-name").should == true
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should return false if the provided item does NOT exist in the queue identified by the given queue name" do
|
93
93
|
Resque.stub(:size).and_return(2)
|
94
|
-
Resque.stub(:peek).and_return([ {
|
95
|
-
Octopusci::Queue.
|
94
|
+
Resque.stub(:peek).and_return([ { "args" => ["some-proj", "some-repo"] }, { "args" => ["some-other-proj-name", "some-other-branch-name"] } ])
|
95
|
+
Octopusci::Queue.job_pending?("test:queue", "test-proj-name", "test-branch-name").should == false
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopusci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-11-
|
13
|
+
date: 2011-11-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|
17
|
-
requirement: &
|
17
|
+
requirement: &70209939639560 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70209939639560
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: json
|
28
|
-
requirement: &
|
28
|
+
requirement: &70209939638360 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70209939638360
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: resque
|
39
|
-
requirement: &
|
39
|
+
requirement: &70209939637360 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70209939637360
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: actionmailer
|
50
|
-
requirement: &
|
50
|
+
requirement: &70209939636720 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70209939636720
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: multi_json
|
61
|
-
requirement: &
|
61
|
+
requirement: &70209939635860 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70209939635860
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: time-ago-in-words
|
72
|
-
requirement: &
|
72
|
+
requirement: &70209939635160 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70209939635160
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: ansi2html
|
83
|
-
requirement: &
|
83
|
+
requirement: &70209939634180 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :runtime
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70209939634180
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rake
|
94
|
-
requirement: &
|
94
|
+
requirement: &70209939632520 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70209939632520
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rspec
|
105
|
-
requirement: &
|
105
|
+
requirement: &70209939632020 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *70209939632020
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: rack-test
|
116
|
-
requirement: &
|
116
|
+
requirement: &70209939631460 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ! '>='
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: '0'
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *70209939631460
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: guard
|
127
|
-
requirement: &
|
127
|
+
requirement: &70209939630660 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
@@ -132,10 +132,10 @@ dependencies:
|
|
132
132
|
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *70209939630660
|
136
136
|
- !ruby/object:Gem::Dependency
|
137
137
|
name: rb-fsevent
|
138
|
-
requirement: &
|
138
|
+
requirement: &70209939628140 !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
140
140
|
requirements:
|
141
141
|
- - ! '>='
|
@@ -143,10 +143,10 @@ dependencies:
|
|
143
143
|
version: '0'
|
144
144
|
type: :development
|
145
145
|
prerelease: false
|
146
|
-
version_requirements: *
|
146
|
+
version_requirements: *70209939628140
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: growl_notify
|
149
|
-
requirement: &
|
149
|
+
requirement: &70209939626500 !ruby/object:Gem::Requirement
|
150
150
|
none: false
|
151
151
|
requirements:
|
152
152
|
- - ! '>='
|
@@ -154,10 +154,10 @@ dependencies:
|
|
154
154
|
version: '0'
|
155
155
|
type: :development
|
156
156
|
prerelease: false
|
157
|
-
version_requirements: *
|
157
|
+
version_requirements: *70209939626500
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: guard-rspec
|
160
|
-
requirement: &
|
160
|
+
requirement: &70209939624700 !ruby/object:Gem::Requirement
|
161
161
|
none: false
|
162
162
|
requirements:
|
163
163
|
- - ! '>='
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
version: '0'
|
166
166
|
type: :development
|
167
167
|
prerelease: false
|
168
|
-
version_requirements: *
|
168
|
+
version_requirements: *70209939624700
|
169
169
|
description: A multi-branch Continous Integration server that integrates with GitHub
|
170
170
|
email:
|
171
171
|
- cyphactor@gmail.com
|