raykit 0.0.132 → 0.0.133
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 +4 -4
- data/lib/raykit/command.rb +25 -0
- data/lib/raykit/runner.rb +42 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13737148d0a3cc8fd632d9568447c182d496a315972d2960269c9c5030180998
|
4
|
+
data.tar.gz: 7c15b9a25f7cdf2e1a406215921fd92a233c4bbade62e8f5890b4138a8e8d180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 671eea11ea493b1bd65044515d473d249b157c6f53da672aa54aea3741fb8a6106dc0bbf108d47727c464482aea2ad66a4e6df3bf98f43fbbf10cc92cc2c7e43
|
7
|
+
data.tar.gz: fba5578258008cadcf86e5b94930879dc0671eafe8637ec0473ebc522034b30bd82a9a2fa153c950b3cc663b6ad60f9fe4946176c30302c6fbfb112c5fbdca14
|
data/lib/raykit/command.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'open3'
|
2
2
|
require 'timeout'
|
3
3
|
require 'json'
|
4
|
+
require 'yaml'
|
4
5
|
require 'logger'
|
5
6
|
require 'securerandom'
|
6
7
|
|
@@ -141,5 +142,29 @@ module Raykit
|
|
141
142
|
cmd.from_hash(JSON.parse(json))
|
142
143
|
cmd
|
143
144
|
end
|
145
|
+
|
146
|
+
def self.parse_yaml_commands(yaml)
|
147
|
+
commands=Array.new()
|
148
|
+
data = YAML.load(yaml)
|
149
|
+
commands = get_script_commands(data)
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.get_script_commands(hash)
|
153
|
+
commands=Array.new
|
154
|
+
if(hash.key?('script'))
|
155
|
+
hash['script'].each{|cmd|
|
156
|
+
commands << cmd
|
157
|
+
}
|
158
|
+
end
|
159
|
+
hash.each{|k,v|
|
160
|
+
if(v.is_a?(Hash))
|
161
|
+
subcommands=get_script_commands(v)
|
162
|
+
subcommands.each{|c|
|
163
|
+
commands << c
|
164
|
+
}
|
165
|
+
end
|
166
|
+
}
|
167
|
+
commands
|
168
|
+
end
|
144
169
|
end
|
145
170
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class Runner
|
5
|
+
def self.run(git_url)
|
6
|
+
commands=Array.new()
|
7
|
+
local_dir=Dir.mktmpdir('runner')
|
8
|
+
puts 'local_dir : ' + local_dir
|
9
|
+
commands << Raykit::Command.new("git clone #{git_url} #{local_dir}")
|
10
|
+
Dir.chdir(local_dir) do
|
11
|
+
commands << Raykit::Command.new("git log -n 1")
|
12
|
+
yaml=get_build_yaml(local_dir)
|
13
|
+
build_hash=YAML.load(yaml)
|
14
|
+
build_commands=Raykit::Command.parse_yaml_commands(yaml)
|
15
|
+
if(build_hash.key?('image'))
|
16
|
+
image=build_hash['image']
|
17
|
+
build_commands.insert(0,'cd home')
|
18
|
+
build_commands.insert(1,"git clone #{git_url} build")
|
19
|
+
build_commands.insert(2,'cd build')
|
20
|
+
build_commands_string=build_commands.join(';');
|
21
|
+
commands << Raykit::Command.new("docker run #{image} sh -c \"#{build_commands_string}\"")
|
22
|
+
else
|
23
|
+
build_commands.each{|cmd_string|
|
24
|
+
commands << Rakkit::Command.new(cmd_string)
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
FileUtils.rm_rf(local_dir)
|
29
|
+
commands
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.get_build_yaml(directory)
|
33
|
+
yaml=''
|
34
|
+
Dir.chdir(directory) do
|
35
|
+
if(File.exists?('.gitlab-ci.yml'))
|
36
|
+
yaml = File.open('.gitlab-ci.yml').read
|
37
|
+
end
|
38
|
+
end
|
39
|
+
yaml
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raykit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.133
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lou Parslow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/raykit/nugetpackage.rb
|
91
91
|
- lib/raykit/project.rb
|
92
92
|
- lib/raykit/rake.rb
|
93
|
+
- lib/raykit/runner.rb
|
93
94
|
- lib/raykit/secrets.rb
|
94
95
|
- lib/raykit/timer.rb
|
95
96
|
- lib/raykit/version.rb
|