robot_sweatshop 0.4.3 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +114 -0
- data/README.md +4 -1
- data/Rakefile +0 -6
- data/bin/sweatshop +33 -16
- data/bin/sweatshop-assembler +13 -5
- data/bin/sweatshop-conveyor +0 -1
- data/bin/sweatshop-input +0 -1
- data/bin/sweatshop-job-dictionary +0 -1
- data/bin/sweatshop-payload-parser +0 -1
- data/bin/sweatshop-worker +18 -5
- data/config.defaults.yaml +1 -0
- data/lib/README.md +25 -1
- data/lib/robot_sweatshop/cli/common.rb +21 -34
- data/lib/robot_sweatshop/cli/config.rb +15 -11
- data/lib/robot_sweatshop/cli/job.rb +13 -9
- data/lib/robot_sweatshop/cli/start.rb +20 -19
- data/lib/robot_sweatshop/create-config-directories.rb +5 -2
- data/robot_sweatshop.gemspec +3 -3
- data/test/assembler_spec.rb +6 -2
- data/test/data/custom_script +2 -0
- data/test/data/scripts_job.yaml +3 -0
- data/test/shared/helpers/input.rb +8 -2
- data/test/shared/scaffolding.rb +8 -1
- data/test/worker_spec.rb +6 -1
- metadata +9 -6
- data/bin/README.md +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9644e9dc1d94285d8c2d01852ba53210fb6e72dd
|
4
|
+
data.tar.gz: 8c0ecc30b95179b2a1dc348df433599c68332073
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a32bbd3c95489988b17675ab4ed5551ddb743bf9c2bf5386efe665867f253a184fa8bdb75a76cb42a5cea0a10e17a68871d64e56994e0bbce63996f7d294cee
|
7
|
+
data.tar.gz: bac318be912e59607b969eb0721c03131ba0b83ca736e5c45fcff372c008c11df313941eb0ae8ef3ba19812a7114a4a11178f2163e2ae58fc063022b643b1f47
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
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
data/bin/sweatshop
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
require 'yaml'
|
4
4
|
require 'commander/import'
|
5
|
-
require '
|
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.
|
12
|
-
program :description, 'A lightweight,
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
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
|
-
|
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
|
data/bin/sweatshop-assembler
CHANGED
@@ -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
|
21
|
-
def
|
22
|
-
|
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:
|
37
|
+
context: create_job_context(definition['environment'], payload),
|
30
38
|
job_name: job[:job_name],
|
31
39
|
job_id: job[:job_id]
|
32
40
|
}
|
data/bin/sweatshop-conveyor
CHANGED
data/bin/sweatshop-input
CHANGED
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
|
27
|
-
def
|
28
|
-
|
29
|
-
|
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
data/lib/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Job
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module CLI
|
4
|
+
module Config
|
5
|
+
def self.default
|
6
|
+
File.read "#{__dir__}/../../../config.defaults.yaml"
|
7
|
+
end
|
6
8
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
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
|
8
|
-
|
9
|
-
end
|
9
|
+
def self.path_for(job)
|
10
|
+
"#{configatron.job_path}/#{job}.yaml"
|
11
|
+
end
|
10
12
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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
|
data/robot_sweatshop.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'robot_sweatshop'
|
3
|
-
gem.version = '0.4.
|
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,
|
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 '
|
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'
|
data/test/assembler_spec.rb
CHANGED
@@ -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
|
66
|
+
assert_equal ['PATH'], @worker_data[:context].keys
|
63
67
|
else
|
64
68
|
assert_equal 'value', @worker_data[:context]['test1']
|
65
69
|
end
|
@@ -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: {
|
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
|
}
|
data/test/shared/scaffolding.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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.
|
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
|
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:
|
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,
|
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
|
-
```
|