robot_sweatshop 0.4.3 → 0.4.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44fc7ae765713f7f3d0375008ab550a19c034d0e
4
- data.tar.gz: a7fc84ba9891e3eb244b65407b80428144dbd516
3
+ metadata.gz: 9644e9dc1d94285d8c2d01852ba53210fb6e72dd
4
+ data.tar.gz: 8c0ecc30b95179b2a1dc348df433599c68332073
5
5
  SHA512:
6
- metadata.gz: 03420bcbf4f02120c1d3a2a72c915929d08b89df47615722083dd9100d5916226c6ab732920837fdb182dcef830b9790787e9abeeb56dae39e3c7889a6b3dca1
7
- data.tar.gz: 0f1c4c066484dee045d68334e501dda16d8d6b321c3d94797c3198a2e6f9496356744432cb4c955aea50b0de7abfcabece1fb615b69a7c85804420081b2c4aff
6
+ metadata.gz: 9a32bbd3c95489988b17675ab4ed5551ddb743bf9c2bf5386efe665867f253a184fa8bdb75a76cb42a5cea0a10e17a68871d64e56994e0bbce63996f7d294cee
7
+ data.tar.gz: bac318be912e59607b969eb0721c03131ba0b83ca736e5c45fcff372c008c11df313941eb0ae8ef3ba19812a7114a4a11178f2163e2ae58fc063022b643b1f47
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  jobs/*.yaml
4
4
  .robot_sweatshop
5
5
 
6
- Gemfile.lock
7
6
  .bundle
8
7
  vendor
9
8
  coverage
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - kintama/**/*
3
+ - test/**/*
4
4
  - vendor/**/*
5
5
 
6
6
  Style/Encoding:
data/Gemfile.lock ADDED
@@ -0,0 +1,114 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ robot_sweatshop (0.4.4)
5
+ bundler
6
+ commander
7
+ configatron
8
+ contracts
9
+ exponential-backoff
10
+ eye
11
+ ezmq
12
+ faker
13
+ oj
14
+ sinatra
15
+ sinatra-cross_origin
16
+ stubborn_queue
17
+ terminal-announce
18
+
19
+ GEM
20
+ remote: http://rubygems.org/
21
+ specs:
22
+ addressable (2.3.8)
23
+ celluloid (0.15.2)
24
+ timers (~> 1.1.0)
25
+ celluloid-io (0.15.0)
26
+ celluloid (>= 0.15.0)
27
+ nio4r (>= 0.5.0)
28
+ commander (4.3.4)
29
+ highline (~> 1.7.2)
30
+ configatron (4.5.0)
31
+ contracts (0.9)
32
+ daybreak (0.3.0)
33
+ docile (1.1.5)
34
+ domain_name (0.5.24)
35
+ unf (>= 0.0.5, < 1.0.0)
36
+ exponential-backoff (0.0.2)
37
+ eye (0.6.4)
38
+ celluloid (~> 0.15.0)
39
+ celluloid-io (~> 0.15.0)
40
+ sigar (~> 0.7.2)
41
+ state_machine
42
+ thor
43
+ ezmq (0.4.4)
44
+ ffi-rzmq (~> 2.0)
45
+ faker (1.4.3)
46
+ i18n (~> 0.5)
47
+ ffi (1.9.8)
48
+ ffi-rzmq (2.0.4)
49
+ ffi-rzmq-core (>= 1.0.1)
50
+ ffi-rzmq-core (1.0.3)
51
+ ffi (~> 1.9)
52
+ highline (1.7.2)
53
+ http (0.8.12)
54
+ addressable (~> 2.3)
55
+ http-cookie (~> 1.0)
56
+ http-form_data (~> 1.0.1)
57
+ http_parser.rb (~> 0.6.0)
58
+ http-cookie (1.0.2)
59
+ domain_name (~> 0.5)
60
+ http-form_data (1.0.1)
61
+ http_parser.rb (0.6.0)
62
+ i18n (0.7.0)
63
+ json (1.8.3)
64
+ kintama (0.1.13)
65
+ moneta (0.8.0)
66
+ nio4r (1.1.0)
67
+ oj (2.12.9)
68
+ rack (1.6.1)
69
+ rack-protection (1.5.3)
70
+ rack
71
+ rainbow (2.0.0)
72
+ rake (10.4.2)
73
+ redislike (0.2.5)
74
+ moneta (~> 0.8)
75
+ sigar (0.7.3)
76
+ simplecov (0.10.0)
77
+ docile (~> 1.1.0)
78
+ json (~> 1.8)
79
+ simplecov-html (~> 0.10.0)
80
+ simplecov-html (0.10.0)
81
+ sinatra (1.4.6)
82
+ rack (~> 1.4)
83
+ rack-protection (~> 1.4)
84
+ tilt (>= 1.3, < 3)
85
+ sinatra-cross_origin (0.3.2)
86
+ state_machine (1.2.0)
87
+ stubborn_queue (1.1.0)
88
+ bundler
89
+ daybreak
90
+ moneta
91
+ redislike
92
+ terminal-announce (1.0.0)
93
+ bundler
94
+ contracts
95
+ rainbow
96
+ thor (0.19.1)
97
+ tilt (2.0.1)
98
+ timers (1.1.0)
99
+ unf (0.1.4)
100
+ unf_ext
101
+ unf_ext (0.0.7.1)
102
+
103
+ PLATFORMS
104
+ ruby
105
+
106
+ DEPENDENCIES
107
+ http
108
+ kintama
109
+ rake
110
+ robot_sweatshop!
111
+ simplecov
112
+
113
+ BUNDLED WITH
114
+ 1.10.2
data/README.md CHANGED
@@ -44,11 +44,14 @@ You probably don't want to run Robot Sweatshop as a sudo user. Create a testing
44
44
  - Easier way to run multiple workers
45
45
  - Mascot
46
46
 
47
+ 1.1
48
+
49
+ - push/pull out node that worker streams output to
50
+
47
51
  Beyond
48
52
 
49
53
  - Jenkins-to-Sweatshop job converting script
50
54
  - Take a look at beefcake for data versioning/serialization
51
55
  - Better logging for the processes
52
56
  - CLI configuration via chomp and/or flags
53
- - Common scrips such as git repo syncing and creating a job run ID (see: [sweatshop-tears](https://github.com/JScott/sweatshop-tears))
54
57
  - Use [eye-http](https://github.com/kostya/eye-http) for the '/' route?
data/Rakefile CHANGED
@@ -1,11 +1,5 @@
1
1
  require 'bundler/setup'
2
- require 'simplecov'
3
2
 
4
3
  task :test do
5
- SimpleCov.command_name 'Kintama Tests'
6
- SimpleCov.start do
7
- add_filter "/vendor/"
8
- add_filter "/test/"
9
- end
10
4
  require_relative 'test/all'
11
5
  end
data/bin/sweatshop CHANGED
@@ -2,14 +2,14 @@
2
2
  require 'bundler/setup'
3
3
  require 'yaml'
4
4
  require 'commander/import'
5
- require 'colorize'
5
+ require 'terminal-announce'
6
6
  require 'robot_sweatshop/cli'
7
7
  require 'robot_sweatshop/config'
8
8
  require 'robot_sweatshop/create-config-directories'
9
9
 
10
10
  program :name, 'Robot Sweatshop'
11
- program :version, '0.4.3'
12
- program :description, 'A lightweight, unopinionated CI server'
11
+ program :version, '0.4.5'
12
+ program :description, 'A lightweight, nonopinionated CI server'
13
13
  program :help, 'Author', 'Justin Scott <jvscott@gmail.com>'
14
14
 
15
15
  command :job do |c|
@@ -18,14 +18,18 @@ command :job do |c|
18
18
  c.option '--auto', 'Create the file without opening the editor.'
19
19
  c.action do |args, options|
20
20
  options.default :auto => false
21
- if args.count < 1
22
- notify :failure, "Specify a job name as the command argument."
23
- exit 1
24
- else
25
- job_file = get_job_path for_job: args.first
26
- create job_file, with_contents: default_job
27
- edit job_file unless options.auto
28
- end
21
+ raise "Specify a job name as the command argument." if args.count < 1
22
+ job_file = CLI::Job.path_for args.first
23
+ CLI.create job_file, with_contents: CLI::Job.default
24
+ CLI.edit job_file unless options.auto
25
+ end
26
+ end
27
+
28
+ command :'job-list' do |c|
29
+ c.syntax = 'sweatshop job-list'
30
+ c.description = 'Lists available job configurations.'
31
+ c.action do |args, options|
32
+ CLI::Job.list
29
33
  end
30
34
  end
31
35
 
@@ -35,9 +39,10 @@ command :config do |c|
35
39
  c.option '--auto', 'Create the file without opening the editor.'
36
40
  c.action do |args, options|
37
41
  options.default :auto => false
38
- config_file = get_config_path for_scope: args.first
39
- create config_file, with_contents: default_config
40
- edit config_file unless options.auto
42
+ for_scope = args.first || 'local'
43
+ config_file = CLI::Config.path for_scope
44
+ CLI.create config_file, with_contents: CLI::Config.default
45
+ CLI.edit config_file unless options.auto
41
46
  end
42
47
  end
43
48
 
@@ -48,7 +53,7 @@ command :start do |c|
48
53
  c.action do |_args, options|
49
54
  options.default :testing => false
50
55
  environment = options.testing ? 'testing' : 'production'
51
- start_sweatshop for_environment: environment
56
+ CLI::Start.sweatshop for_environment: environment
52
57
  end
53
58
  end
54
59
 
@@ -56,6 +61,18 @@ command :stop do |c|
56
61
  c.syntax = 'sweatshop stop'
57
62
  c.description = 'Stop the Sweatshop.'
58
63
  c.action do
59
- notify :info, `eye stop robot_sweatshop`
64
+ Announce.info `eye stop robot_sweatshop`
65
+ end
66
+ end
67
+
68
+ command :gears do |c|
69
+ c.syntax = 'sweatshop gears ...'
70
+ c.description = 'See `sweatshop-gears --help`'
71
+ c.action do |args, options|
72
+ begin
73
+ `sweatshop-gears #{args.join ' '}`
74
+ rescue Errno::ENOENT
75
+ Announce.failure 'Sweatshop Gears not found. Run `gem install sweatshop-gears`'
76
+ end
60
77
  end
61
78
  end
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'bundler/setup'
3
2
  require 'yaml'
4
3
  require 'contracts'
5
4
  require 'exponential_backoff'
@@ -17,16 +16,25 @@ def sanitize(data)
17
16
  data.reduce(:merge)
18
17
  end
19
18
 
20
- Contract Hash, Hash => Hash
21
- def job_context(job_environment, context_from_payload)
22
- sanitize job_environment.merge(context_from_payload)
19
+ Contract Hash => String
20
+ def extended_path_for(environment)
21
+ environment['PATH'] ||= ENV['PATH']
22
+ scripts_path = File.expand_path configatron.scripts_path
23
+ "#{environment['PATH']}:#{scripts_path}"
24
+ end
25
+
26
+ Contract Maybe[Hash], Hash => Hash
27
+ def create_job_context(job_environment, payload)
28
+ environment = (job_environment || {}).merge payload
29
+ environment = sanitize environment
30
+ environment.merge 'PATH' => extended_path_for(environment)
23
31
  end
24
32
 
25
33
  Contract Hash, Hash, Hash => Hash
26
34
  def assemble(job, payload, definition)
27
35
  {
28
36
  commands: definition['commands'],
29
- context: job_context(definition['environment'] || {}, payload),
37
+ context: create_job_context(definition['environment'], payload),
30
38
  job_name: job[:job_name],
31
39
  job_id: job[:job_id]
32
40
  }
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'bundler/setup'
3
2
  require 'ezmq'
4
3
  require 'stubborn_queue'
5
4
  require 'contracts'
data/bin/sweatshop-input CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'bundler/setup'
3
2
  require 'sinatra'
4
3
  require 'sinatra/cross_origin'
5
4
  require 'ezmq'
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'bundler/setup'
3
2
  require 'oj'
4
3
  require 'ezmq'
5
4
  require 'contracts'
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'bundler/setup'
3
2
  require 'oj'
4
3
  require 'ezmq'
5
4
  require 'contracts'
data/bin/sweatshop-worker CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'bundler/setup'
3
2
  require 'ezmq'
4
3
  require 'faker'
5
4
  require 'fileutils'
@@ -23,15 +22,29 @@ def from_workspace(named:)
23
22
  Dir.chdir(path) { yield if block_given? }
24
23
  end
25
24
 
26
- Contract Hash, String => nil
27
- def execute(context, command)
28
- puts "Executing '#{command}'..."
29
- # TODO: path.split(' ') to bypass the shell when we're not using env vars
25
+ Contract String => String
26
+ def ensure_shell_for(command)
27
+ "#{command};"
28
+ end
29
+
30
+ Contract Hash, String => Maybe[IO]
31
+ def stream_command(context, command)
32
+ command = ensure_shell_for command
30
33
  IO.popen(context, command) do |io_stream|
31
34
  while line = io_stream.gets
32
35
  puts line
33
36
  end
34
37
  end
38
+ end
39
+
40
+ Contract Hash, String => nil
41
+ def execute(context, command)
42
+ puts "Executing '#{command}'"
43
+ begin
44
+ stream_command context, command
45
+ rescue Errno::ENOENT => error
46
+ puts error.message
47
+ end
35
48
  puts "Execution complete with exit status: #{$?.exitstatus}"
36
49
  end
37
50
 
data/config.defaults.yaml CHANGED
@@ -4,6 +4,7 @@ logfile_path: .robot_sweatshop/log
4
4
  job_path: .robot_sweatshop/jobs
5
5
  workspace_path: .robot_sweatshop/workspaces
6
6
  database_path: .robot_sweatshop/db
7
+ scripts_path: .robot_sweatshop/scripts
7
8
  http_port: 8080
8
9
  http_bind: 0.0.0.0
9
10
  http_cross_origin: true
data/lib/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Job lifecycle:
1
+ # Job Lifecycle
2
2
 
3
3
  ```
4
4
  input -> conveyor
@@ -19,3 +19,27 @@ assembler -> worker
19
19
 
20
20
  context is passed around with string keys because it's user provided
21
21
  everything else is passed with symbol keys
22
+
23
+ # Services
24
+
25
+ sweatshop-conveyor
26
+ ```
27
+ { method:, data: }
28
+
29
+ id = enqueue(item)
30
+ id = dequeue
31
+ item = lookup(id)
32
+ something = finish(id)
33
+ ```
34
+
35
+ sweatshop-payload-parser
36
+ ```
37
+ req: { payload:, user_agent: }
38
+ rep: { data:, error: }
39
+ ```
40
+
41
+ sweatshop-job-dictionary
42
+ ```
43
+ req: { job_name: }
44
+ rep: { data:, error: }
45
+ ```
@@ -1,41 +1,28 @@
1
1
  require 'fileutils'
2
2
  require 'robot_sweatshop/config'
3
+ require 'terminal-announce'
3
4
 
4
- def notify(type = :success, string)
5
- color = case type
6
- when :success
7
- :green
8
- when :failure
9
- :red
10
- when :warning
11
- :yellow
12
- when :info
13
- :light_blue
14
- else
15
- ''
5
+ module CLI
6
+ def self.edit(file)
7
+ editor = ENV['EDITOR']
8
+ if editor
9
+ Announce.info "Manually editing file '#{file}'"
10
+ system editor, file
11
+ else
12
+ Announce.warning "No editor specified in $EDITOR environment variable"
13
+ Announce.info "Displaying file contents instead"
14
+ system 'cat', file
15
+ end
16
16
  end
17
- puts "[#{type.to_s.capitalize.colorize(color)}] #{string}"
18
- end
19
-
20
- def edit(file)
21
- edit = ENV['EDITOR']
22
- if edit
23
- notify :info, "Manually editing file '#{file}'"
24
- system edit, file
25
- else
26
- notify :warning, "No editor specified in $EDITOR environment variable"
27
- notify :info, "Displaying file contents instead"
28
- system 'cat', file
29
- end
30
- end
31
17
 
32
- def create(file, with_contents: '')
33
- file = File.expand_path file
34
- if File.file?(file)
35
- notify :info, "'#{file}' already exists"
36
- else
37
- FileUtils.mkdir_p File.dirname(file)
38
- File.write file, with_contents
39
- notify :success, "Created new file '#{file}'"
18
+ def self.create(file, with_contents: '')
19
+ file = File.expand_path file
20
+ if File.file?(file)
21
+ Announce.info "'#{file}' already exists"
22
+ else
23
+ FileUtils.mkdir_p File.dirname(file)
24
+ File.write file, with_contents
25
+ Announce.success "Created new file '#{file}'"
26
+ end
40
27
  end
41
28
  end
@@ -1,16 +1,20 @@
1
1
  require 'robot_sweatshop/config'
2
2
 
3
- def default_config
4
- File.read "#{__dir__}/../../../config.defaults.yaml"
5
- end
3
+ module CLI
4
+ module Config
5
+ def self.default
6
+ File.read "#{__dir__}/../../../config.defaults.yaml"
7
+ end
6
8
 
7
- def get_config_path(for_scope: 'local')
8
- case for_scope
9
- when 'system'
10
- "/etc/robot_sweatshop/config.yaml"
11
- when 'user'
12
- "~/.robot_sweatshop/config.yaml"
13
- else
14
- ".robot_sweatshop/config.yaml"
9
+ def self.path(scope)
10
+ case scope
11
+ when 'system'
12
+ "/etc/robot_sweatshop/config.yaml"
13
+ when 'user'
14
+ "~/.robot_sweatshop/config.yaml"
15
+ else
16
+ ".robot_sweatshop/config.yaml"
17
+ end
18
+ end
15
19
  end
16
20
  end
@@ -1,14 +1,18 @@
1
1
  require 'robot_sweatshop/config'
2
2
 
3
- def default_job
4
- "---\n# branch_whitelist:\n# - master\n\ncommands:\n- echo \"Hello $WORLD!\"\n\nenvironment:\n WORLD: Earth\n"
5
- end
3
+ module CLI
4
+ module Job
5
+ def self.default
6
+ "---\n# branch_whitelist:\n# - master\n\ncommands:\n- echo \"Hello $WORLD!\"\n\nenvironment:\n WORLD: Earth\n"
7
+ end
6
8
 
7
- def get_job_path(for_job: nil)
8
- "#{configatron.job_path}/#{for_job}.yaml"
9
- end
9
+ def self.path_for(job)
10
+ "#{configatron.job_path}/#{job}.yaml"
11
+ end
10
12
 
11
- def list_jobs
12
- job_path = File.expand_path configatron.job_path
13
- puts Dir.glob("#{job_path}/*.yaml").map { |file| File.basename(file, '.yaml') }
13
+ def self.list
14
+ job_path = File.expand_path configatron.job_path
15
+ puts Dir.glob("#{job_path}/*.yaml").map { |file| File.basename(file, '.yaml') }
16
+ end
17
+ end
14
18
  end
@@ -1,25 +1,26 @@
1
1
  require 'yaml'
2
+ require 'terminal-announce'
2
3
  require 'robot_sweatshop/config'
3
4
 
4
- def store_config_for_eye
5
- config = configatron.to_h
6
- config = config.each do |key, value|
7
- config[key] = File.expand_path value if key.to_s.match /_path/
8
- end
9
- config[:working_path] = Dir.pwd
10
- File.write('/tmp/.robot_sweatshop-eye-config.yaml', config.to_yaml)
11
- end
5
+ module CLI
6
+ module Start
7
+ def self.store_config_for_eye
8
+ config = configatron.to_h
9
+ config = config.each do |key, value|
10
+ config[key] = File.expand_path value if key.to_s.match /_path/
11
+ end
12
+ config[:working_path] = Dir.pwd
13
+ File.write '/tmp/.robot_sweatshop-eye-config.yaml', config.to_yaml
14
+ end
12
15
 
13
- def start_sweatshop(for_environment:)
14
- store_config_for_eye
15
- eye_config = File.expand_path "#{__dir__}/../../../robot_sweatshop.eye"
16
- output = `eye load #{eye_config}`
17
- if $?.exitstatus != 0
18
- notify :failure, output
19
- exit 1
20
- else
21
- notify :success, "Robot Sweatshop loaded with a #{for_environment} configuration"
22
- notify :info, `eye restart robot_sweatshop`
23
- notify :info, 'Run \'eye --help\' for more info on debugging'
16
+ def self.sweatshop(for_environment:)
17
+ store_config_for_eye
18
+ eye_config = File.expand_path "#{__dir__}/../../../robot_sweatshop.eye"
19
+ output = `eye load #{eye_config}`
20
+ raise output if $?.exitstatus != 0
21
+ Announce.success "Robot Sweatshop loaded with a #{for_environment} configuration"
22
+ Announce.info `eye restart robot_sweatshop`
23
+ Announce.info 'Run \'eye --help\' for more info on debugging'
24
+ end
24
25
  end
25
26
  end
@@ -11,7 +11,10 @@ end
11
11
  config = configatron.to_h
12
12
  config.each do |key, value|
13
13
  if key.to_s.match /_path/
14
- path = File.expand_path value
15
- create_path path
14
+ create_path File.expand_path(value)
16
15
  end
17
16
  end
17
+ %w(pidfile_path logfile_path).each do |path|
18
+ p File.expand_path("#{configatron[path]}/gears")
19
+ create_path File.expand_path("#{configatron[path]}/gears")
20
+ end
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'robot_sweatshop'
3
- gem.version = '0.4.3'
3
+ gem.version = '0.4.5'
4
4
  gem.licenses = 'MIT'
5
5
  gem.authors = ['Justin Scott']
6
6
  gem.email = 'jvscott@gmail.com'
7
7
  gem.homepage = 'http://www.github.com/jscott/robot_sweatshop/'
8
8
  gem.summary = 'Robot Sweatshop'
9
- gem.description = 'A lightweight, unopinionated CI server.'
9
+ gem.description = 'A lightweight, nonopinionated CI server.'
10
10
 
11
11
  gem.files = `git ls-files`.split("\n")
12
12
  gem.test_files = `git ls-files -- test/**/*`.split("\n")
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.add_runtime_dependency 'faker'
20
20
  gem.add_runtime_dependency 'commander'
21
21
  gem.add_runtime_dependency 'eye'
22
- gem.add_runtime_dependency 'colorize' # TODO: replace with rainbow
22
+ gem.add_runtime_dependency 'terminal-announce'
23
23
  gem.add_runtime_dependency 'configatron'
24
24
  gem.add_runtime_dependency 'contracts'
25
25
  gem.add_runtime_dependency 'sinatra'
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'kintama'
3
2
  require 'ezmq'
4
3
  require 'timeout'
@@ -55,11 +54,16 @@ describe 'the Job Assembler' do
55
54
  end
56
55
  end
57
56
 
57
+ should 'append scripts_path to the PATH and add it to the context' do
58
+ scripts_path = File.expand_path configatron.scripts_path
59
+ assert_match /#{scripts_path}/, @worker_data[:context]['PATH']
60
+ end
61
+
58
62
  should 'build the context with a parsed payload' do
59
63
  if request == 'Git'
60
64
  assert_equal 'develop', @worker_data[:context]['branch']
61
65
  elsif request == 'EmptyJSON'
62
- assert_equal true, @worker_data[:context].empty?
66
+ assert_equal ['PATH'], @worker_data[:context].keys
63
67
  else
64
68
  assert_equal 'value', @worker_data[:context]['test1']
65
69
  end
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ puts "custom"
@@ -0,0 +1,3 @@
1
+ ---
2
+ commands:
3
+ - custom_script
@@ -37,9 +37,15 @@ module InputHelper
37
37
  {
38
38
  commands: [
39
39
  'echo $custom',
40
- 'echo $custom > test.txt'
40
+ 'echo $custom > test.txt',
41
+ 'custom_script',
42
+ 'custom_script >> test.txt',
43
+ 'bad command about nothing'
41
44
  ],
42
- context: {'custom' => 'hello world'},
45
+ context: {
46
+ 'PATH' => "#{ENV['PATH']}:#{File.expand_path configatron.scripts_path}",
47
+ 'custom' => 'hello world'
48
+ },
43
49
  job_name: 'test_job',
44
50
  job_id: 1
45
51
  }
@@ -13,7 +13,14 @@ module Setup
13
13
 
14
14
  def self.populate_test_jobs
15
15
  test_jobs = Dir.glob "#{__dir__}/../data/*_job.yaml"
16
- test_jobs.each { |test_job| FileUtils.cp test_job, configatron.job_path }
16
+ job_path = File.expand_path configatron.job_path
17
+ test_jobs.each { |job| FileUtils.cp job, job_path }
18
+ end
19
+
20
+ def self.populate_scripts
21
+ test_scripts = Dir.glob "#{__dir__}/../data/*_script"
22
+ scripts_path = File.expand_path configatron.scripts_path
23
+ test_scripts.each { |script| FileUtils.cp script, scripts_path }
17
24
  end
18
25
  end
19
26
 
data/test/worker_spec.rb CHANGED
@@ -11,6 +11,7 @@ $stdout.sync = true
11
11
  Kintama.on_start do
12
12
  Setup.empty_conveyor
13
13
  @pids = TestProcess.start %w(worker)
14
+ Setup.populate_scripts
14
15
  end
15
16
 
16
17
  Kintama.on_finish do
@@ -48,7 +49,11 @@ describe 'the Worker' do
48
49
  end
49
50
 
50
51
  should 'run with the context as environment variables' do
51
- assert_equal "hello world\n", File.read(worker_output)
52
+ assert_match /hello world/, File.read(worker_output)
53
+ end
54
+
55
+ should 'run with custom scripts in the path' do
56
+ assert_match /custom/, File.read(worker_output)
52
57
  end
53
58
 
54
59
  should 'tell the conveyor that job is complete' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robot_sweatshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.5
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-05-26 00:00:00.000000000 Z
11
+ date: 2015-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: colorize
70
+ name: terminal-announce
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -248,10 +248,9 @@ dependencies:
248
248
  - - ">="
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
- description: A lightweight, unopinionated CI server.
251
+ description: A lightweight, nonopinionated CI server.
252
252
  email: jvscott@gmail.com
253
253
  executables:
254
- - README.md
255
254
  - sweatshop
256
255
  - sweatshop-assembler
257
256
  - sweatshop-conveyor
@@ -265,10 +264,10 @@ files:
265
264
  - ".gitignore"
266
265
  - ".rubocop.yml"
267
266
  - Gemfile
267
+ - Gemfile.lock
268
268
  - LICENSE
269
269
  - README.md
270
270
  - Rakefile
271
- - bin/README.md
272
271
  - bin/sweatshop
273
272
  - bin/sweatshop-assembler
274
273
  - bin/sweatshop-conveyor
@@ -298,10 +297,12 @@ files:
298
297
  - test/all.rb
299
298
  - test/assembler_spec.rb
300
299
  - test/conveyor_spec.rb
300
+ - test/data/custom_script
301
301
  - test/data/empty_job.yaml
302
302
  - test/data/git_job.yaml
303
303
  - test/data/minimal_job.yaml
304
304
  - test/data/payload_data.yaml
305
+ - test/data/scripts_job.yaml
305
306
  - test/data/test_job.yaml
306
307
  - test/data/weird_job.yaml
307
308
  - test/end-to-end_spec.rb
@@ -339,10 +340,12 @@ signing_key:
339
340
  specification_version: 4
340
341
  summary: Robot Sweatshop
341
342
  test_files:
343
+ - test/data/custom_script
342
344
  - test/data/empty_job.yaml
343
345
  - test/data/git_job.yaml
344
346
  - test/data/minimal_job.yaml
345
347
  - test/data/payload_data.yaml
348
+ - test/data/scripts_job.yaml
346
349
  - test/data/test_job.yaml
347
350
  - test/data/weird_job.yaml
348
351
  - test/shared/helpers.rb
data/bin/README.md DELETED
@@ -1,23 +0,0 @@
1
- # Services
2
-
3
- sweatshop-conveyor
4
- ```
5
- { method:, data: }
6
-
7
- id = enqueue(item)
8
- id = dequeue
9
- item = lookup(id)
10
- something = finish(id)
11
- ```
12
-
13
- sweatshop-payload-parser
14
- ```
15
- req: { payload:, user_agent: }
16
- rep: { data:, error: }
17
- ```
18
-
19
- sweatshop-job-dictionary
20
- ```
21
- req: { job_name: }
22
- rep: { data:, error: }
23
- ```