robot_sweatshop 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Rakefile +4 -0
- data/config.rb +7 -1
- data/config.yaml +6 -0
- data/kintama/data/payload_data.yaml +2 -0
- data/kintama/end-to-end_spec.rb +2 -0
- data/kintama/payload_parser_spec.rb +1 -2
- data/kintama/shared/helpers.rb +1 -1
- data/lib/job/assembler.rb +18 -5
- data/lib/job/worker.rb +2 -1
- data/lib/payload/lib/github.rb +1 -1
- data/robot_sweatshop.gemspec +1 -1
- metadata +2 -3
- data/workspaces/.keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5592f2b311bf3192547642a2bee4f295b8a2234
|
4
|
+
data.tar.gz: 1089c1b361eaeec881ce56d59cf605dded0e92ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f00071cbbfebef8bb00057d4c3cbf805a50b02bbfc3926bc8b8eed275c0f748fda6806d069a6c8e88934a82c1daa7651d74baa9ad18eb44ebb509b5363c0e78b
|
7
|
+
data.tar.gz: 455da1ed22b381fdac31c6c3a8e6130248446e40e4dfccfdb92ba9d196351cd2d7f5d0e29ea5847981b1ee2a4017ff91d8d73dfe8b7c249300a178fa0105e32e
|
data/README.md
CHANGED
@@ -19,7 +19,8 @@ You can see what jobs are available with `sweatshop job --list`.
|
|
19
19
|
|
20
20
|
Currently supported formats:
|
21
21
|
|
22
|
-
-
|
22
|
+
- Github (application/json format only)
|
23
|
+
- Bitbucket
|
23
24
|
|
24
25
|
# Configuration
|
25
26
|
|
@@ -35,7 +36,6 @@ _TODO: Support for running as a custom user via eye uid/gid_
|
|
35
36
|
|
36
37
|
# Roadmap
|
37
38
|
|
38
|
-
- Enable Github support
|
39
39
|
- CLI job running
|
40
40
|
- Common scrips such as git repo syncing
|
41
41
|
- Support for multiple workers
|
data/Rakefile
CHANGED
data/config.rb
CHANGED
@@ -2,6 +2,8 @@ require 'fileutils'
|
|
2
2
|
require 'configatron'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
+
# TODO: namespace to avoid collisions?
|
6
|
+
|
5
7
|
configurations = [
|
6
8
|
"#{__dir__}/config.yaml",
|
7
9
|
"#{__dir__}/config.user.yaml",
|
@@ -17,8 +19,12 @@ end
|
|
17
19
|
config_directories = [
|
18
20
|
configatron.common.logfile_directory,
|
19
21
|
configatron.common.pidfile_directory,
|
20
|
-
configatron.
|
22
|
+
configatron.common.user_config_directory,
|
23
|
+
configatron.queue.moneta_directory,
|
24
|
+
configatron.assembler.job_directory,
|
25
|
+
configatron.worker.workspace_directory
|
21
26
|
]
|
22
27
|
config_directories.each do |directory|
|
23
28
|
FileUtils.mkdir_p directory unless Dir.exists? directory
|
29
|
+
# TODO: set chmod to appropriate user
|
24
30
|
end
|
data/config.yaml
CHANGED
@@ -4,3 +4,5 @@ malformed: |
|
|
4
4
|
payload=%7B%22nothing%22%3A%22here%22%7D
|
5
5
|
bitbucket: |
|
6
6
|
payload=%7B%22repository%22%3A+%7B%22website%22%3A+%22%22%2C+%22fork%22%3A+false%2C+%22name%22%3A+%22Project+X%22%2C+%22scm%22%3A+%22git%22%2C+%22owner%22%3A+%22marcus%22%2C+%22absolute_url%22%3A+%22%2Fmarcus%2Fproject-x%2F%22%2C+%22slug%22%3A+%22project-x%22%2C+%22is_private%22%3A+true%7D%2C+%22truncated%22%3A+false%2C+%22commits%22%3A+%5B%7B%22node%22%3A+%22620ade18607a%22%2C+%22files%22%3A+%5B%7B%22type%22%3A+%22modified%22%2C+%22file%22%3A+%22README%22%7D%5D%2C+%22raw_author%22%3A+%22Marcus+Bertrand+%3Cmarcus%40somedomain.com%3E%22%2C+%22utctimestamp%22%3A+%222014-08-08+00%3A04%3A07%2B00%3A00%22%2C+%22author%22%3A+%22marcus%22%2C+%22timestamp%22%3A+%222014-08-08+02%3A04%3A07%22%2C+%22raw_node%22%3A+%22620ade18607ac42d872b568bb92acaa9a28620e9%22%2C+%22parents%22%3A+%5B%22702c70160afc%22%5D%2C+%22branch%22%3A+%22develop%22%2C+%22message%22%3A+%22Added+some+more+things+to+somefile.py%5Cn%22%2C+%22revision%22%3A+null%2C+%22size%22%3A+-1%7D%5D%2C+%22canon_url%22%3A+%22https%3A%2F%2Fbitbucket.org%22%2C+%22user%22%3A+%22marcus%22%7D
|
7
|
+
github: |
|
8
|
+
{"ref":"refs/heads/master","before":"ca8ad5b796be2edebd10563e20d56d6a58477ecc","after":"3aa2a0eff5fac9ea9faab8055229b363e4d44e56","created":false,"deleted":false,"forced":false,"base_ref":null,"compare":"https://github.com/JScott/configs/compare/ca8ad5b796be...3aa2a0eff5fa","commits":[{"id":"3aa2a0eff5fac9ea9faab8055229b363e4d44e56","distinct":true,"message":"test","timestamp":"2015-03-07T10:37:51-08:00","url":"https://github.com/JScott/configs/commit/3aa2a0eff5fac9ea9faab8055229b363e4d44e56","author":{"name":"Justin Scott","email":"jvscott@gmail.com","username":"JScott"},"committer":{"name":"Justin Scott","email":"jvscott@gmail.com","username":"JScott"},"added":["test"],"removed":[],"modified":[]}],"head_commit":{"id":"3aa2a0eff5fac9ea9faab8055229b363e4d44e56","distinct":true,"message":"test","timestamp":"2015-03-07T10:37:51-08:00","url":"https://github.com/JScott/configs/commit/3aa2a0eff5fac9ea9faab8055229b363e4d44e56","author":{"name":"Justin Scott","email":"jvscott@gmail.com","username":"JScott"},"committer":{"name":"Justin Scott","email":"jvscott@gmail.com","username":"JScott"},"added":["test"],"removed":[],"modified":[]},"repository":{"id":15853602,"name":"configs","full_name":"JScott/configs","owner":{"name":"JScott","email":"jvscott@gmail.com"},"private":false,"html_url":"https://github.com/JScott/configs","description":"Any dot files or build scripts that help me day to day. Maybe you can get some use out of them too!","fork":false,"url":"https://github.com/JScott/configs","forks_url":"https://api.github.com/repos/JScott/configs/forks","keys_url":"https://api.github.com/repos/JScott/configs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JScott/configs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JScott/configs/teams","hooks_url":"https://api.github.com/repos/JScott/configs/hooks","issue_events_url":"https://api.github.com/repos/JScott/configs/issues/events{/number}","events_url":"https://api.github.com/repos/JScott/configs/events","assignees_url":"https://api.github.com/repos/JScott/configs/assignees{/user}","branches_url":"https://api.github.com/repos/JScott/configs/branches{/branch}","tags_url":"https://api.github.com/repos/JScott/configs/tags","blobs_url":"https://api.github.com/repos/JScott/configs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JScott/configs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JScott/configs/git/refs{/sha}","trees_url":"https://api.github.com/repos/JScott/configs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JScott/configs/statuses/{sha}","languages_url":"https://api.github.com/repos/JScott/configs/languages","stargazers_url":"https://api.github.com/repos/JScott/configs/stargazers","contributors_url":"https://api.github.com/repos/JScott/configs/contributors","subscribers_url":"https://api.github.com/repos/JScott/configs/subscribers","subscription_url":"https://api.github.com/repos/JScott/configs/subscription","commits_url":"https://api.github.com/repos/JScott/configs/commits{/sha}","git_commits_url":"https://api.github.com/repos/JScott/configs/git/commits{/sha}","comments_url":"https://api.github.com/repos/JScott/configs/comments{/number}","issue_comment_url":"https://api.github.com/repos/JScott/configs/issues/comments{/number}","contents_url":"https://api.github.com/repos/JScott/configs/contents/{+path}","compare_url":"https://api.github.com/repos/JScott/configs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JScott/configs/merges","archive_url":"https://api.github.com/repos/JScott/configs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JScott/configs/downloads","issues_url":"https://api.github.com/repos/JScott/configs/issues{/number}","pulls_url":"https://api.github.com/repos/JScott/configs/pulls{/number}","milestones_url":"https://api.github.com/repos/JScott/configs/milestones{/number}","notifications_url":"https://api.github.com/repos/JScott/configs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JScott/configs/labels{/name}","releases_url":"https://api.github.com/repos/JScott/configs/releases{/id}","created_at":1389570979,"updated_at":"2015-03-07T18:34:54Z","pushed_at":1425753471,"git_url":"git://github.com/JScott/configs.git","ssh_url":"git@github.com:JScott/configs.git","clone_url":"https://github.com/JScott/configs.git","svn_url":"https://github.com/JScott/configs","homepage":null,"size":484,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","stargazers":0,"master_branch":"master"},"pusher":{"name":"JScott","email":"jvscott@gmail.com"},"sender":{"login":"JScott","id":25989,"avatar_url":"https://avatars.githubusercontent.com/u/25989?v=3","gravatar_id":"","url":"https://api.github.com/users/JScott","html_url":"https://github.com/JScott","followers_url":"https://api.github.com/users/JScott/followers","following_url":"https://api.github.com/users/JScott/following{/other_user}","gists_url":"https://api.github.com/users/JScott/gists{/gist_id}","starred_url":"https://api.github.com/users/JScott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JScott/subscriptions","organizations_url":"https://api.github.com/users/JScott/orgs","repos_url":"https://api.github.com/users/JScott/repos","events_url":"https://api.github.com/users/JScott/events{/privacy}","received_events_url":"https://api.github.com/users/JScott/received_events","type":"User","site_admin":false}}
|
data/kintama/end-to-end_spec.rb
CHANGED
@@ -19,7 +19,9 @@ describe 'Robot Sweatshop' do
|
|
19
19
|
context "POST git data to the HTTP Input" do
|
20
20
|
setup do
|
21
21
|
url = input_http_url for_job: @job_name
|
22
|
+
puts "posting..."
|
22
23
|
HTTP.post url, body: load_payload('bitbucket')
|
24
|
+
puts "post successful"
|
23
25
|
sleep $for_everything
|
24
26
|
end
|
25
27
|
|
@@ -16,8 +16,7 @@ describe 'the Payload Parser' do
|
|
16
16
|
clear_all_queues
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
['Bitbucket'].each do |format|
|
19
|
+
%w(Bitbucket Github).each do |format|
|
21
20
|
given "valid #{format} data in 'raw-payload'" do
|
22
21
|
setup do
|
23
22
|
payload = example_raw_payload(with_format: format)
|
data/kintama/shared/helpers.rb
CHANGED
@@ -48,7 +48,7 @@ module JobHelper
|
|
48
48
|
job_name: 'example'
|
49
49
|
end
|
50
50
|
def reset_test_file
|
51
|
-
test_file = File.expand_path "#{
|
51
|
+
test_file = File.expand_path "#{configatron.worker.workspace_directory}/example-testingid/test.txt"
|
52
52
|
FileUtils.rm_rf test_file
|
53
53
|
test_file
|
54
54
|
end
|
data/lib/job/assembler.rb
CHANGED
@@ -1,11 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'yaml'
|
3
3
|
require_relative '../queue-helper'
|
4
|
+
require_relative '../../config'
|
4
5
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def find_job_config_file(job_name)
|
7
|
+
configurations = [
|
8
|
+
"#{__dir__}/../../jobs",
|
9
|
+
configatron.assembler.job_directory
|
10
|
+
]
|
11
|
+
configurations.each do |config_path|
|
12
|
+
file_path = "#{config_path}/#{job_name}.yaml"
|
13
|
+
puts file_path
|
14
|
+
return file_path if File.file? file_path
|
15
|
+
end
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_config(for_job_name:)
|
20
|
+
job_config_path = find_job_config_file for_job_name
|
21
|
+
if job_config_path.nil?
|
9
22
|
puts "No config found for job '#{for_job_name}'"
|
10
23
|
return nil
|
11
24
|
end
|
@@ -13,7 +26,7 @@ def get_config(for_job_name:)
|
|
13
26
|
end
|
14
27
|
|
15
28
|
def assemble_job(data)
|
16
|
-
job_config =
|
29
|
+
job_config = load_config for_job_name: data['job_name']
|
17
30
|
return nil unless job_config
|
18
31
|
if job_config['branch_whitelist'].include? data['payload']['branch']
|
19
32
|
context = job_config['environment'].merge(data['payload'])
|
data/lib/job/worker.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'faker'
|
3
3
|
require 'fileutils'
|
4
4
|
require_relative '../queue-helper'
|
5
|
+
require_relative '../../config'
|
5
6
|
|
6
7
|
# TODO: check existing worker ids. it'd be disastrous to have two sharing a workspace
|
7
8
|
@worker_id = ARGV[0] || "#{Faker::Name.first_name}"
|
@@ -9,7 +10,7 @@ require_relative '../queue-helper'
|
|
9
10
|
def from_workspace(named: 'no_job_name')
|
10
11
|
workspace = "#{named}-#{@worker_id}"
|
11
12
|
puts "Workspace: #{workspace}"
|
12
|
-
path =
|
13
|
+
path = "#{configatron.worker.workspace_directory}/#{workspace}"
|
13
14
|
FileUtils.mkpath path
|
14
15
|
Dir.chdir(path) { yield if block_given? }
|
15
16
|
end
|
data/lib/payload/lib/github.rb
CHANGED
data/robot_sweatshop.gemspec
CHANGED
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.1.
|
4
|
+
version: 0.1.3
|
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-03-
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -202,7 +202,6 @@ files:
|
|
202
202
|
- robot_sweatshop.gemspec
|
203
203
|
- robot_sweatshop.production.eye
|
204
204
|
- robot_sweatshop.testing.eye
|
205
|
-
- workspaces/.keep
|
206
205
|
homepage: http://www.github.com/jscott/robot_sweatshop/
|
207
206
|
licenses:
|
208
207
|
- MIT
|
data/workspaces/.keep
DELETED
File without changes
|