mason-server 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,21 +8,23 @@ GIT
8
8
  PATH
9
9
  remote: /data/homedirs/ey/sr/buildozor/client
10
10
  specs:
11
- mason-client (0)
11
+ mason-client (0.0.1)
12
12
  json
13
13
  rack
14
14
 
15
15
  PATH
16
16
  remote: .
17
17
  specs:
18
- mason-server (0.0.1)
18
+ mason-server (0.0.3)
19
19
  dm-aggregates (~> 1.0.2)
20
20
  dm-core (~> 1.0.2)
21
21
  dm-migrations (~> 1.0.2)
22
22
  dm-postgres-adapter (~> 1.0.2)
23
23
  dm-timestamps (~> 1.0.2)
24
+ dm-validations (~> 1.0.2)
24
25
  json (~> 1.4.6)
25
26
  open4 (~> 1.0)
27
+ resque (~> 1.10.0)
26
28
  sinatra (~> 1.0)
27
29
 
28
30
  GEM
@@ -47,6 +49,8 @@ GEM
47
49
  do_postgres (~> 0.10.2)
48
50
  dm-timestamps (1.0.2)
49
51
  dm-core (~> 1.0.2)
52
+ dm-validations (1.0.2)
53
+ dm-core (~> 1.0.2)
50
54
  do_postgres (0.10.2)
51
55
  data_objects (= 0.10.2)
52
56
  extlib (0.9.15)
@@ -56,8 +60,18 @@ GEM
56
60
  rack-test (0.5.4)
57
61
  rack (>= 1.0)
58
62
  rake (0.8.7)
63
+ redis (2.0.9)
64
+ redis-namespace (0.8.0)
65
+ redis (< 3.0.0)
66
+ resque (1.10.0)
67
+ json (~> 1.4.6)
68
+ redis-namespace (~> 0.8.0)
69
+ sinatra (>= 0.9.2)
70
+ vegas (~> 0.1.2)
59
71
  sinatra (1.0)
60
72
  rack (>= 1.0)
73
+ vegas (0.1.7)
74
+ rack (>= 1.0.0)
61
75
 
62
76
  PLATFORMS
63
77
  ruby
@@ -70,10 +84,12 @@ DEPENDENCIES
70
84
  dm-migrations (~> 1.0.2)
71
85
  dm-postgres-adapter (~> 1.0.2)
72
86
  dm-timestamps (~> 1.0.2)
87
+ dm-validations (~> 1.0.2)
73
88
  json (~> 1.4.6)
74
89
  mason-client!
75
90
  mason-server!
76
91
  open4 (~> 1.0)
77
92
  rack-test
78
93
  rake
94
+ resque (~> 1.10.0)
79
95
  sinatra (~> 1.0)
@@ -2,15 +2,18 @@ require "pathname"
2
2
  require "uri"
3
3
 
4
4
  require "dm-core"
5
+ require "dm-validations"
5
6
  require "dm-aggregates"
6
7
  require "dm-timestamps"
7
8
  require "dm-migrations"
8
9
  require "json"
9
10
  require "sinatra"
10
11
  require "open4"
12
+ require "resque"
11
13
 
12
- require "mason_server/build"
13
14
  require "mason_server/app"
15
+ require "mason_server/build"
16
+ require "mason_server/build_job"
14
17
  require "mason_server/command_runner"
15
18
 
16
19
  module MasonServer
@@ -25,6 +28,8 @@ module MasonServer
25
28
  def self.setup(url, directory)
26
29
  @url = URI(url)
27
30
  @directory = Pathname(directory)
31
+
32
+ DataMapper::Model.raise_on_save_failure = true
28
33
  end
29
34
 
30
35
  def self.app
@@ -3,10 +3,10 @@ module MasonServer
3
3
  include DataMapper::Resource
4
4
 
5
5
  property :id, Serial
6
- property :repo, String, :required => true
7
- property :ref, String, :required => true
8
- property :command, String, :required => true
9
- property :callback, String, :required => true
6
+ property :repo, String, :required => true, :length => 255
7
+ property :ref, String, :required => true, :length => 255
8
+ property :command, String, :required => true, :length => 255
9
+ property :callback, String, :required => true, :length => 255
10
10
  property :status, Integer
11
11
  property :output, Text
12
12
  property :started_at, DateTime
@@ -15,17 +15,13 @@ module MasonServer
15
15
  timestamps :at
16
16
 
17
17
  def self.run(request)
18
- build = new(
18
+ build = create(
19
19
  :repo => request.repo,
20
20
  :ref => request.ref,
21
21
  :command => request.command,
22
22
  :callback => request.callback
23
23
  )
24
24
 
25
- unless build.save
26
- raise Error, "failed to create build for #{request.inspect}"
27
- end
28
-
29
25
  # TODO need aync
30
26
  build.run
31
27
  build.url
@@ -36,6 +32,10 @@ module MasonServer
36
32
  end
37
33
 
38
34
  def run
35
+ BuildJob.enqueue(id)
36
+ end
37
+
38
+ def run!
39
39
  start
40
40
  setup_checkout
41
41
  run_command
@@ -44,9 +44,7 @@ module MasonServer
44
44
  end
45
45
 
46
46
  def start
47
- unless update(:started_at => Time.now)
48
- raise Error, "failed to start build"
49
- end
47
+ update(:started_at => Time.now)
50
48
  end
51
49
 
52
50
  def setup_checkout
@@ -57,9 +55,7 @@ module MasonServer
57
55
  output_handler(chunk)
58
56
  end
59
57
 
60
- unless update(:status => status)
61
- raise Error, "could not set status"
62
- end
58
+ update(:status => status)
63
59
  end
64
60
 
65
61
  def output_handler(chunk)
@@ -71,13 +67,11 @@ module MasonServer
71
67
  end
72
68
 
73
69
  def complete
74
- unless update(:completed_at => Time.now)
75
- raise Error, "failed to complete build"
76
- end
70
+ update(:completed_at => Time.now)
77
71
  end
78
72
 
79
73
  def notify
80
- Net::HTTP.post_form(URI(callback.to_s), "payload" => payload.to_json)
74
+ Net::HTTP.post_form(URI(callback), "payload" => payload.to_json)
81
75
  end
82
76
 
83
77
  def payload
@@ -0,0 +1,15 @@
1
+ module MasonServer
2
+ class BuildJob
3
+ def self.queue
4
+ "mason"
5
+ end
6
+
7
+ def self.enqueue(build)
8
+ Resque.enqueue(self, build.id)
9
+ end
10
+
11
+ def self.perform(id)
12
+ Build.get!(id).run!
13
+ end
14
+ end
15
+ end
@@ -1,17 +1,19 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mason-server"
3
- s.version = "0.0.3"
3
+ s.version = "0.0.4"
4
4
  s.summary = "builds things"
5
5
 
6
6
  s.add_dependency "dm-core", "~>1.0.2"
7
+ s.add_dependency "dm-validations", "~>1.0.2"
7
8
  s.add_dependency "dm-aggregates", "~>1.0.2"
8
- s.add_dependency "dm-migrations", "~>1.0.2"
9
9
  s.add_dependency "dm-timestamps", "~>1.0.2"
10
+ s.add_dependency "dm-migrations", "~>1.0.2"
10
11
  s.add_dependency "dm-postgres-adapter", "~>1.0.2"
11
12
 
12
13
  s.add_dependency "open4", "~>1.0"
13
14
  s.add_dependency "sinatra", "~>1.0"
14
15
  s.add_dependency "json", "~>1.4.6"
16
+ s.add_dependency "resque", "~>1.10.0"
15
17
 
16
18
  s.files = `git ls-files`.split("\n")
17
19
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors: []
12
12
 
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-19 00:00:00 +02:00
17
+ date: 2010-09-20 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: dm-aggregates
35
+ name: dm-validations
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  requirements:
@@ -46,7 +46,7 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: dm-migrations
49
+ name: dm-aggregates
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  requirements:
@@ -74,7 +74,7 @@ dependencies:
74
74
  type: :runtime
75
75
  version_requirements: *id004
76
76
  - !ruby/object:Gem::Dependency
77
- name: dm-postgres-adapter
77
+ name: dm-migrations
78
78
  prerelease: false
79
79
  requirement: &id005 !ruby/object:Gem::Requirement
80
80
  requirements:
@@ -88,7 +88,7 @@ dependencies:
88
88
  type: :runtime
89
89
  version_requirements: *id005
90
90
  - !ruby/object:Gem::Dependency
91
- name: open4
91
+ name: dm-postgres-adapter
92
92
  prerelease: false
93
93
  requirement: &id006 !ruby/object:Gem::Requirement
94
94
  requirements:
@@ -97,11 +97,12 @@ dependencies:
97
97
  segments:
98
98
  - 1
99
99
  - 0
100
- version: "1.0"
100
+ - 2
101
+ version: 1.0.2
101
102
  type: :runtime
102
103
  version_requirements: *id006
103
104
  - !ruby/object:Gem::Dependency
104
- name: sinatra
105
+ name: open4
105
106
  prerelease: false
106
107
  requirement: &id007 !ruby/object:Gem::Requirement
107
108
  requirements:
@@ -114,9 +115,22 @@ dependencies:
114
115
  type: :runtime
115
116
  version_requirements: *id007
116
117
  - !ruby/object:Gem::Dependency
117
- name: json
118
+ name: sinatra
118
119
  prerelease: false
119
120
  requirement: &id008 !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ segments:
125
+ - 1
126
+ - 0
127
+ version: "1.0"
128
+ type: :runtime
129
+ version_requirements: *id008
130
+ - !ruby/object:Gem::Dependency
131
+ name: json
132
+ prerelease: false
133
+ requirement: &id009 !ruby/object:Gem::Requirement
120
134
  requirements:
121
135
  - - ~>
122
136
  - !ruby/object:Gem::Version
@@ -126,7 +140,21 @@ dependencies:
126
140
  - 6
127
141
  version: 1.4.6
128
142
  type: :runtime
129
- version_requirements: *id008
143
+ version_requirements: *id009
144
+ - !ruby/object:Gem::Dependency
145
+ name: resque
146
+ prerelease: false
147
+ requirement: &id010 !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ~>
150
+ - !ruby/object:Gem::Version
151
+ segments:
152
+ - 1
153
+ - 10
154
+ - 0
155
+ version: 1.10.0
156
+ type: :runtime
157
+ version_requirements: *id010
130
158
  description:
131
159
  email:
132
160
  executables: []
@@ -145,6 +173,7 @@ files:
145
173
  - lib/mason_server.rb
146
174
  - lib/mason_server/app.rb
147
175
  - lib/mason_server/build.rb
176
+ - lib/mason_server/build_job.rb
148
177
  - lib/mason_server/command_runner.rb
149
178
  - mason-server.gemspec
150
179
  - test/command_runner_test.rb