robot_sweatshop 0.4.9 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0117fcc7d8e0d91f24a08a46a8b7e24f4cd0b65b
4
- data.tar.gz: e01c0e51398d698e8dc4d7a56f53c77fb35955e5
3
+ metadata.gz: b9ae5c44f98320bdde45d1f7cb315f29059a0b92
4
+ data.tar.gz: ea24dec2cb35c6eef63e03a5f3d251627701fdd1
5
5
  SHA512:
6
- metadata.gz: 1255a647775979d5da1d5fb2be512e23af38979b6aba58dd37906c45e1da4f25a34d72d0b31e48a13a50f2e08b8661b2da611c1bbb76ce98ffde092e8490599a
7
- data.tar.gz: 8dda97b15749001ff014e0500bf37663cffad1201d1f91066f057068b68fc752913b87ff638aa67e0386541c075def54d4c8f8e305ff7433e9382e4eda658698
6
+ metadata.gz: d1d9969540fee3705c050f823525ac671626a3dbd94746a710a2bdfe755cbd864b7ec702e0072b2e6dc7e5ce3d031735dfeba59f46052a23ca8e304a3f8bf4da
7
+ data.tar.gz: aad296f9bf18403b6ade6f6064bc706d750d98c338c57852a3b2bb58c6abf917183fd95f080efbeb91e7fb03c6d9bd9a824f1593730429f4244145162529965c
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [Unreleased][unreleased]
6
+ ### Added
7
+ - Multiple worker support
8
+
9
+ ## [0.4.11] - 2015-07-14
10
+ ### Fixed
11
+ - Config erroring out if you don't have a home path
12
+
13
+ ## [0.4.10] - 2015-07-13
14
+ ### Added
15
+ - Started using a change log
16
+
17
+ ### Removed
18
+ - `sweatshop config system` for convention over configuration
19
+
20
+ ### Changed
21
+ - Input server being transformed into the API server
22
+
23
+ ### Fixed
24
+ - Front-end hitting the the API server instead of always `localhost`
25
+
26
+ [0.4.9 and previous]: https://github.com/jscott/robot_sweatshop/compare/0.1.0...0.4.9
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- robot_sweatshop (0.4.8)
5
- bundler
4
+ robot_sweatshop (0.4.9)
6
5
  commander
7
6
  configatron
8
7
  contracts
data/bin/sweatshop CHANGED
@@ -7,7 +7,7 @@ require 'robot_sweatshop/config'
7
7
  require 'robot_sweatshop/create-config-directories'
8
8
 
9
9
  program :name, 'Robot Sweatshop'
10
- program :version, '0.4.9'
10
+ program :version, '0.4.11'
11
11
  program :description, 'A lightweight, nonopinionated CI server'
12
12
  program :help, 'Author', 'Justin Scott <jvscott@gmail.com>'
13
13
 
@@ -48,11 +48,8 @@ end
48
48
  command :start do |c|
49
49
  c.syntax = 'sweatshop start [options]'
50
50
  c.description = 'Start the Sweatshop.'
51
- c.option '--testing', 'Load the testing Eye configuration.'
52
51
  c.action do |_args, options|
53
- options.default testing: false
54
- environment = options.testing ? 'testing' : 'production'
55
- CLI::Start.sweatshop for_environment: environment
52
+ CLI::Start.sweatshop
56
53
  end
57
54
  end
58
55
 
@@ -64,6 +61,8 @@ command :stop do |c|
64
61
  end
65
62
  end
66
63
 
64
+ alias_command :restart, :start
65
+
67
66
  command :gears do |c|
68
67
  c.syntax = 'sweatshop gears ...'
69
68
  c.description = 'See `sweatshop-gears --help`'
@@ -7,7 +7,7 @@ require 'robot_sweatshop/connections'
7
7
  using ExtendedEZMQ
8
8
 
9
9
  configure do
10
- set :port, configatron.input_port
10
+ set :port, configatron.api_port
11
11
  set :bind, configatron.http_bind
12
12
  set :run, true
13
13
  set :conveyor, EZMQ::Client.new(port: configatron.conveyor_port)
data/config.defaults.yaml CHANGED
@@ -8,9 +8,10 @@ scripts_path: .robot_sweatshop/scripts
8
8
  http_bind: 0.0.0.0
9
9
  http_cross_origin: true
10
10
  overseer_port: 10554
11
- input_port: 10555
11
+ api_port: 10555
12
12
  conveyor_port: 10556
13
13
  payload_parser_port: 10557
14
14
  job_dictionary_port: 10558
15
15
  worker_port: 10559
16
+ api_url: http://localhost:10555
16
17
  job_timeout_length: 300 # 5 minutes
data/docs/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  POST payload /run/:job
11
11
  ```
12
12
 
13
- ## input
13
+ ## api
14
14
 
15
15
  ```
16
16
  PUSH {
@@ -2,26 +2,26 @@ digraph architecture {
2
2
  label="Robot Sweatshop process interaction"
3
3
  labelloc="top"
4
4
 
5
- O [label="Overseer",shape=box]
6
- I [label="Input"]
7
- A [label="Assembler"]
8
- W [label="Worker"]
5
+ overseer [label="Overseer",shape=box]
6
+ api [label="API"]
7
+ assembler [label="Assembler"]
8
+ worker [label="Worker"]
9
9
  subgraph cluster_services {
10
10
  label="Req/Rep Services"
11
11
  labelloc="bottom"
12
12
  style="dashed"
13
- C [label="Conveyor"]
14
- P [label="Payload Parser"]
15
- D [label="Job Dictionary"]
13
+ conveyor [label="Conveyor"]
14
+ parser [label="Payload Parser"]
15
+ dictionary [label="Job Dictionary"]
16
16
  }
17
17
 
18
- O->I
19
- I->C
20
- A->C [dir="both"]
21
- A->P [dir="both"]
22
- A->D [dir="both"]
23
- A->W [headlabel="1..*",labeldistance=2]
24
- W->C
18
+ overseer->api
19
+ api->conveyor
20
+ assembler->conveyor [dir="both"]
21
+ assembler->parser [dir="both"]
22
+ assembler->dictionary [dir="both"]
23
+ assembler->worker [headlabel="1..*",labeldistance=2]
24
+ worker->conveyor
25
25
 
26
- { rank=same; I W A }
26
+ { rank=same; api worker assembler }
27
27
  }
Binary file
@@ -9,10 +9,7 @@ module CLI
9
9
  end
10
10
 
11
11
  def self.path(scope)
12
- case scope
13
- when 'system'
14
- '/etc/robot_sweatshop/config.yaml'
15
- when 'user'
12
+ if scope == 'user'
16
13
  '~/.robot_sweatshop/config.yaml'
17
14
  else
18
15
  '.robot_sweatshop/config.yaml'
@@ -5,12 +5,12 @@ require 'robot_sweatshop/config'
5
5
  module CLI
6
6
  # Methods for starting Robot Sweatshop
7
7
  module Start
8
- def self.sweatshop(for_environment:)
8
+ def self.sweatshop
9
9
  Config.compile_to_file
10
10
  eye_config = File.expand_path "#{__dir__}/../../../robot_sweatshop.eye"
11
11
  output = `eye load #{eye_config}`
12
12
  fail output if $?.exitstatus != 0
13
- Announce.success "Robot Sweatshop loaded with a #{for_environment} configuration"
13
+ Announce.success "Robot Sweatshop loaded"
14
14
  Announce.info `eye restart robot_sweatshop`
15
15
  Announce.info 'Run \'eye --help\' for more info on debugging'
16
16
  end
@@ -1,5 +1,6 @@
1
1
  require 'configatron'
2
2
  require 'yaml'
3
+ require 'terminal-announce'
3
4
 
4
5
  configatron.reset!
5
6
 
@@ -16,6 +17,8 @@ configurations.each do |config_path|
16
17
  hash = YAML.load_file config_path
17
18
  configatron.configure_from_hash hash
18
19
  end
20
+ rescue ArgumentError => error
21
+ Announce.info "Couldn't load '#{config_path}': #{error.message}"
19
22
  end
20
23
 
21
24
  require 'robot_sweatshop/create-config-directories'
@@ -3,20 +3,20 @@ require 'erubis'
3
3
  # Helper methods for the Overseer Sinatra server
4
4
  module OverseerHelper
5
5
  def log_list
6
- %w(assembler conveyor input job-dictionary payload-parser worker)
6
+ log_path = File.expand_path "#{configatron.logfile_path}"
7
+ Dir.glob("#{log_path}/*.log").map { |path| File.basename path, '.log' }
7
8
  end
8
9
 
9
10
  def job_list
10
- log_path = File.expand_path "#{configatron.job_path}"
11
- p log_path, Dir.glob("#{log_path}/*.yaml")
12
- Dir.glob("#{log_path}/*.yaml").map { |path| File.basename path, '.yaml' }
11
+ job_path = File.expand_path "#{configatron.job_path}"
12
+ Dir.glob("#{job_path}/*.yaml").map { |path| File.basename path, '.yaml' }
13
13
  end
14
14
 
15
15
  def frontpage
16
16
  context = {
17
17
  jobs: job_list,
18
18
  logs: log_list,
19
- input_port: configatron.input_port
19
+ api_url: configatron.api_url
20
20
  }
21
21
  template = File.read "#{__dir__}/templates/index.html.eruby"
22
22
  eruby = Erubis::Eruby.new template
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  # branch_whitelist:
3
- # - master
3
+ # - master
4
4
 
5
5
  commands:
6
- - echo "Hello $WORLD!"
6
+ - echo "Hello $WORLD!"
7
7
 
8
8
  environment:
9
9
  WORLD: Earth
@@ -8,8 +8,8 @@
8
8
  var QueueJob = function() {
9
9
  var job = $('select#job').val();
10
10
  var data = $('textarea#data').val();
11
- console.log("http://localhost:<%= input_port %>/run/"+job);
12
- $.post("http://localhost:<%= input_port %>/run/"+job, data);
11
+ console.log("POST <%= api_url %>/run/"+job);
12
+ $.post("<%= api_url %>/run/"+job, data);
13
13
  }
14
14
  </script>
15
15
  <style>
@@ -3,6 +3,9 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <title>Robot Sweatshop - <%= process %> log</title>
6
+ <style>
7
+ pre { word-wrap: break-word; }
8
+ </style>
6
9
  </head>
7
10
 
8
11
  <body>
data/robot_sweatshop.eye CHANGED
@@ -42,10 +42,10 @@ Eye.application :robot_sweatshop do
42
42
  start_command "#{__dir__}/bin/sweatshop-overseer"
43
43
  daemonize true
44
44
  end
45
- process :input do
46
- pid_file "#{PID_PATH}/input.pid"
47
- stdall "#{LOG_PATH}/input.log"
48
- start_command "#{__dir__}/bin/sweatshop-input"
45
+ process :api do
46
+ pid_file "#{PID_PATH}/api.pid"
47
+ stdall "#{LOG_PATH}/api.log"
48
+ start_command "#{__dir__}/bin/sweatshop-api"
49
49
  daemonize true
50
50
  end
51
51
  process :assembler do
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'robot_sweatshop'
3
- gem.version = '0.4.9'
3
+ gem.version = '0.4.11'
4
4
  gem.licenses = 'MIT'
5
5
  gem.authors = ['Justin Scott']
6
6
  gem.email = 'jvscott@gmail.com'
@@ -15,7 +15,6 @@ Gem::Specification.new do |gem|
15
15
 
16
16
  gem.required_ruby_version = '>= 2.1'
17
17
 
18
- gem.add_runtime_dependency 'bundler'
19
18
  gem.add_runtime_dependency 'faker'
20
19
  gem.add_runtime_dependency 'commander'
21
20
  gem.add_runtime_dependency 'eye'
data/test/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ Please run these with `bundle exec`. There's so many self-references that it just makes sense.
2
+
1
3
  You can run individual `_spec.rb` files with Ruby or `all.rb` to go through each. There's no way to run everything together with the way processes are set up but this hasn't been a problem so far.
2
4
 
3
- Because I'm lazy, TestProcess::Stub uses the UNIX `lsof` to check if ports are in use. There's probably a better, more portable way to do this.
5
+ Because I'm lazy, `TestProcess::Stub.running?` uses the UNIX `lsof` to check if ports are in use. There's probably a better, more portable way to do this.
data/test/all.rb CHANGED
@@ -19,7 +19,7 @@ def non_zero(array)
19
19
  end
20
20
 
21
21
  tests = %w(
22
- input
22
+ api
23
23
  conveyor
24
24
  payload_parser
25
25
  job_dictionary
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'kintama'
3
2
  require 'ezmq'
4
3
  require 'oj'
@@ -10,7 +9,7 @@ require_relative 'shared/helpers'
10
9
  $stdout.sync = true
11
10
 
12
11
  Kintama.on_start do
13
- @pids = TestProcess.start %w(input)
12
+ @pids = TestProcess.start %w(api)
14
13
  sleep $a_while
15
14
  end
16
15
 
@@ -26,7 +25,7 @@ given 'the HTTP Input' do
26
25
  context "POSTing #{format} data" do
27
26
  setup do
28
27
  @conveyor = TestProcess.stub :conveyor
29
- url = input_url for_job: 'test_job'
28
+ url = job_running_url for_job: 'test_job'
30
29
  Timeout.timeout($a_while) do
31
30
  @response = HTTP.post url, body: example_raw_payload(format)
32
31
  end
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'kintama'
3
2
  require 'ezmq'
4
3
  require 'timeout'
@@ -1,7 +1,7 @@
1
- require 'bundler/setup'
2
1
  require 'kintama'
3
2
  require 'ezmq'
4
3
  require 'http'
4
+ require 'timeout'
5
5
  require_relative 'shared/scaffolding'
6
6
  require_relative 'shared/helpers'
7
7
 
@@ -11,7 +11,7 @@ describe 'Robot Sweatshop' do
11
11
 
12
12
  setup do
13
13
  Setup.empty_conveyor
14
- @pids = TestProcess.start %w(input conveyor payload-parser job-dictionary assembler worker)
14
+ @pids = TestProcess.start %w(api conveyor payload-parser job-dictionary assembler worker)
15
15
  Setup.populate_test_jobs
16
16
  sleep $a_while
17
17
  end
@@ -20,10 +20,10 @@ describe 'Robot Sweatshop' do
20
20
  TestProcess.stop @pids
21
21
  end
22
22
 
23
- context "POSTing data to the HTTP Input" do
23
+ context "POSTing data to the API" do
24
24
  setup do
25
25
  clear_worker_output
26
- url = input_url for_job: 'test_job'
26
+ url = job_running_url for_job: 'test_job'
27
27
  Timeout.timeout($a_while) { @response = HTTP.post url, body: example_raw_payload('JSON') }
28
28
  end
29
29
 
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'kintama'
3
2
  require 'ezmq'
4
3
  require 'timeout'
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'kintama'
3
2
  require 'timeout'
4
3
  require 'http'
@@ -24,7 +23,7 @@ given 'the Overseer' do
24
23
  should('respond') { assert_equal 200, @response.code }
25
24
  should('link to process logs') do
26
25
  page = Nokogiri::HTML(@response.to_s)
27
- links = page.css('a').select { |link| link.text.include? 'worker' }
26
+ links = page.css('a').select { |link| link.text.include? 'overseer' }
28
27
  assert_not_equal 0, links.count
29
28
  end
30
29
  should('have a form for running jobs') do
@@ -37,12 +36,12 @@ given 'the Overseer' do
37
36
  setup { Timeout.timeout($a_while) { @response = HTTP.get overseer_url('log') } }
38
37
  should('redirect') { assert_equal 303, @response.code }
39
38
  end
40
- context '/log?for=worker' do
41
- setup { Timeout.timeout($a_while) { @response = HTTP.get overseer_url('log?for=worker') } }
39
+ context '/log?for=overseer' do
40
+ setup { Timeout.timeout($a_while) { @response = HTTP.get overseer_url('log?for=overseer') } }
42
41
  should('respond') { assert_equal 200, @response.code }
43
42
  should('show logs from file') do
44
43
  page = Nokogiri::HTML(@response.to_s)
45
- log = File.read "#{configatron.logfile_path}/worker.log"
44
+ log = File.read "#{configatron.logfile_path}/overseer.log"
46
45
  output = page.css('.raw_log').first
47
46
  assert_equal log, output.text, 'Expected raw log output'
48
47
  end
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'kintama'
3
2
  require 'ezmq'
4
3
  require 'timeout'
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'yaml'
3
2
  require 'oj'
4
3
  require 'robot_sweatshop/payload'
@@ -10,8 +9,8 @@ module InputHelper
10
9
  payload_strings[format.downcase]
11
10
  end
12
11
 
13
- def input_url(for_job: 'test_job')
14
- "http://localhost:#{configatron.input_port}/run/#{for_job}"
12
+ def job_running_url(for_job: 'test_job')
13
+ "http://localhost:#{configatron.api_port}/run/#{for_job}"
15
14
  end
16
15
 
17
16
  def conveyor_enqueue(type)
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'fileutils'
3
2
  require 'robot_sweatshop/payload'
4
3
  require 'robot_sweatshop/config'
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'robot_sweatshop/config'
3
2
 
4
3
  module OverseerHelper
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'fileutils'
3
2
  require 'oj'
4
3
  require 'robot_sweatshop/config'
@@ -28,9 +27,9 @@ module TestProcess
28
27
  def self.start(name_list)
29
28
  pids = []
30
29
  name_list.each do |name|
31
- input_script = File.expand_path "#{__dir__}/../../bin/sweatshop-#{name}"
32
- input_script += ' testingid' if name == 'worker'
33
- pids.push spawn(input_script, out: '/dev/null', err: '/dev/null')
30
+ command = File.expand_path "#{__dir__}/../../bin/sweatshop-#{name}"
31
+ command += ' testingid' if name == 'worker'
32
+ pids.push spawn(command, out: '/dev/null', err: '/dev/null')
34
33
  end
35
34
  pids
36
35
  end
data/test/worker_spec.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'kintama'
3
2
  require 'ezmq'
4
3
  require 'timeout'
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robot_sweatshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Scott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: faker
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -280,9 +266,9 @@ description: A lightweight, nonopinionated CI server.
280
266
  email: jvscott@gmail.com
281
267
  executables:
282
268
  - sweatshop
269
+ - sweatshop-api
283
270
  - sweatshop-assembler
284
271
  - sweatshop-conveyor
285
- - sweatshop-input
286
272
  - sweatshop-job-dictionary
287
273
  - sweatshop-overseer
288
274
  - sweatshop-payload-parser
@@ -292,15 +278,16 @@ extra_rdoc_files: []
292
278
  files:
293
279
  - ".gitignore"
294
280
  - ".rubocop.yml"
281
+ - CHANGELOG.md
295
282
  - Gemfile
296
283
  - Gemfile.lock
297
284
  - LICENSE
298
285
  - README.md
299
286
  - Rakefile
300
287
  - bin/sweatshop
288
+ - bin/sweatshop-api
301
289
  - bin/sweatshop-assembler
302
290
  - bin/sweatshop-conveyor
303
- - bin/sweatshop-input
304
291
  - bin/sweatshop-job-dictionary
305
292
  - bin/sweatshop-overseer
306
293
  - bin/sweatshop-payload-parser
@@ -331,6 +318,7 @@ files:
331
318
  - robot_sweatshop.gemspec
332
319
  - test/README.md
333
320
  - test/all.rb
321
+ - test/api_spec.rb
334
322
  - test/assembler_spec.rb
335
323
  - test/conveyor_spec.rb
336
324
  - test/data/custom_script
@@ -342,7 +330,6 @@ files:
342
330
  - test/data/test_job.yaml
343
331
  - test/data/weird_job.yaml
344
332
  - test/end-to-end_spec.rb
345
- - test/input_spec.rb
346
333
  - test/job_dictionary_spec.rb
347
334
  - test/overseer_spec.rb
348
335
  - test/payload_parser_spec.rb