raykit 0.0.471 → 0.0.473
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +20 -20
- data/bin/raykit +6 -6
- data/lib/raykit/command.rb +341 -343
- data/lib/raykit/conan/buildinfo.rb +69 -69
- data/lib/raykit/conanpackage.rb +49 -49
- data/lib/raykit/console.rb +272 -274
- data/lib/raykit/dir.rb +49 -49
- data/lib/raykit/dotnet.rb +115 -115
- data/lib/raykit/environment.rb +109 -109
- data/lib/raykit/filesystem.rb +34 -34
- data/lib/raykit/git/commit.rb +16 -16
- data/lib/raykit/git/directory.rb +216 -186
- data/lib/raykit/git/files.rb +46 -46
- data/lib/raykit/git/repositories.rb +89 -89
- data/lib/raykit/git/repository.rb +244 -244
- data/lib/raykit/installer.rb +17 -17
- data/lib/raykit/log.rb +80 -80
- data/lib/raykit/logevent.rb +49 -49
- data/lib/raykit/logging.rb +57 -59
- data/lib/raykit/markdown.rb +21 -23
- data/lib/raykit/msbuild.rb +54 -54
- data/lib/raykit/nugetpackage.rb +54 -54
- data/lib/raykit/nunit.rb +13 -13
- data/lib/raykit/project.rb +339 -340
- data/lib/raykit/rake.rb +39 -39
- data/lib/raykit/runner.rb +42 -42
- data/lib/raykit/secrets.rb +38 -38
- data/lib/raykit/sourceImport.rb +74 -74
- data/lib/raykit/sourceImports.rb +43 -43
- data/lib/raykit/string.rb +18 -18
- data/lib/raykit/tasks.rb +100 -99
- data/lib/raykit/text.rb +32 -32
- data/lib/raykit/timer.rb +31 -31
- data/lib/raykit/version.rb +103 -103
- data/lib/raykit/vstest.rb +24 -24
- data/lib/raykit/wt.rb +28 -28
- data/lib/raykit/zip.rb +73 -73
- data/lib/raykit.rb +116 -103
- metadata +2 -2
data/lib/raykit/rake.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "time"
|
4
|
-
|
5
|
-
module Raykit
|
6
|
-
class Rake
|
7
|
-
def self.run(remote, branch, task = "default")
|
8
|
-
repo = Raykit::Git::Repository.new(remote)
|
9
|
-
rel_dir = repo.relative_path
|
10
|
-
commit = repo.latest_commit(branch)
|
11
|
-
log_filename = "#{Environment.get_dev_dir("log")}/RayKit.Runner/#{rel_dir}/#{branch}/#{commit}.json"
|
12
|
-
if File.exist?(log_filename)
|
13
|
-
Command.parse(File.read(log_filename))
|
14
|
-
else
|
15
|
-
run_dir = "#{Environment.get_dev_dir("tmp")}/#{rel_dir}.#{branch}.#{commit}"
|
16
|
-
unless Dir.exist?(run_dir)
|
17
|
-
parent_dir = File.expand_path("..", run_dir)
|
18
|
-
FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
|
19
|
-
cmd = Command.new("git clone #{remote} #{run_dir}")
|
20
|
-
end
|
21
|
-
Dir.chdir(run_dir) do
|
22
|
-
cmd = Command.new("rake #{task}")
|
23
|
-
parent_dir = File.dirname(log_filename)
|
24
|
-
FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
|
25
|
-
File.open(log_filename, "w") do |f|
|
26
|
-
f.write(JSON.generate(cmd.to_hash))
|
27
|
-
end
|
28
|
-
return cmd
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.rake(rakefile, task)
|
34
|
-
Dir.chdir(File.dirname(rakefile)) do
|
35
|
-
Raykit::TopLevel.run("rake #{task}", true)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
module Raykit
|
6
|
+
class Rake
|
7
|
+
def self.run(remote, branch, task = "default")
|
8
|
+
repo = Raykit::Git::Repository.new(remote)
|
9
|
+
rel_dir = repo.relative_path
|
10
|
+
commit = repo.latest_commit(branch)
|
11
|
+
log_filename = "#{Environment.get_dev_dir("log")}/RayKit.Runner/#{rel_dir}/#{branch}/#{commit}.json"
|
12
|
+
if File.exist?(log_filename)
|
13
|
+
Command.parse(File.read(log_filename))
|
14
|
+
else
|
15
|
+
run_dir = "#{Environment.get_dev_dir("tmp")}/#{rel_dir}.#{branch}.#{commit}"
|
16
|
+
unless Dir.exist?(run_dir)
|
17
|
+
parent_dir = File.expand_path("..", run_dir)
|
18
|
+
FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
|
19
|
+
cmd = Command.new("git clone #{remote} #{run_dir}")
|
20
|
+
end
|
21
|
+
Dir.chdir(run_dir) do
|
22
|
+
cmd = Command.new("rake #{task}")
|
23
|
+
parent_dir = File.dirname(log_filename)
|
24
|
+
FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
|
25
|
+
File.open(log_filename, "w") do |f|
|
26
|
+
f.write(JSON.generate(cmd.to_hash))
|
27
|
+
end
|
28
|
+
return cmd
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.rake(rakefile, task)
|
34
|
+
Dir.chdir(File.dirname(rakefile)) do
|
35
|
+
Raykit::TopLevel.run("rake #{task}", true)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/raykit/runner.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "yaml"
|
4
|
-
|
5
|
-
module Raykit
|
6
|
-
class Runner
|
7
|
-
def self.run(git_url)
|
8
|
-
commands = []
|
9
|
-
local_dir = Dir.mktmpdir("runner")
|
10
|
-
puts "local_dir : #{local_dir}"
|
11
|
-
commands << Raykit::Command.new("git clone #{git_url} #{local_dir}")
|
12
|
-
Dir.chdir(local_dir) do
|
13
|
-
commands << Raykit::Command.new("git log -n 1")
|
14
|
-
yaml = get_build_yaml(local_dir)
|
15
|
-
build_hash = YAML.safe_load(yaml)
|
16
|
-
build_commands = Raykit::Command.parse_yaml_commands(yaml)
|
17
|
-
if build_hash.key?("image")
|
18
|
-
image = build_hash["image"]
|
19
|
-
build_commands.insert(0, "cd home")
|
20
|
-
build_commands.insert(1, "git clone #{git_url} build")
|
21
|
-
build_commands.insert(2, "cd build")
|
22
|
-
build_commands_string = build_commands.join(";")
|
23
|
-
commands << Raykit::Command.new("docker run #{image} sh -c \"#{build_commands_string}\"")
|
24
|
-
else
|
25
|
-
build_commands.each do |cmd_string|
|
26
|
-
commands << Rakkit::Command.new(cmd_string)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
FileUtils.rm_rf(local_dir)
|
31
|
-
commands
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.get_build_yaml(directory)
|
35
|
-
yaml = ""
|
36
|
-
Dir.chdir(directory) do
|
37
|
-
yaml = File.open(".gitlab-ci.yml").read if File.exist?(".gitlab-ci.yml")
|
38
|
-
end
|
39
|
-
yaml
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
module Raykit
|
6
|
+
class Runner
|
7
|
+
def self.run(git_url)
|
8
|
+
commands = []
|
9
|
+
local_dir = Dir.mktmpdir("runner")
|
10
|
+
puts "local_dir : #{local_dir}"
|
11
|
+
commands << Raykit::Command.new("git clone #{git_url} #{local_dir}")
|
12
|
+
Dir.chdir(local_dir) do
|
13
|
+
commands << Raykit::Command.new("git log -n 1")
|
14
|
+
yaml = get_build_yaml(local_dir)
|
15
|
+
build_hash = YAML.safe_load(yaml)
|
16
|
+
build_commands = Raykit::Command.parse_yaml_commands(yaml)
|
17
|
+
if build_hash.key?("image")
|
18
|
+
image = build_hash["image"]
|
19
|
+
build_commands.insert(0, "cd home")
|
20
|
+
build_commands.insert(1, "git clone #{git_url} build")
|
21
|
+
build_commands.insert(2, "cd build")
|
22
|
+
build_commands_string = build_commands.join(";")
|
23
|
+
commands << Raykit::Command.new("docker run #{image} sh -c \"#{build_commands_string}\"")
|
24
|
+
else
|
25
|
+
build_commands.each do |cmd_string|
|
26
|
+
commands << Rakkit::Command.new(cmd_string)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
FileUtils.rm_rf(local_dir)
|
31
|
+
commands
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.get_build_yaml(directory)
|
35
|
+
yaml = ""
|
36
|
+
Dir.chdir(directory) do
|
37
|
+
yaml = File.open(".gitlab-ci.yml").read if File.exist?(".gitlab-ci.yml")
|
38
|
+
end
|
39
|
+
yaml
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/raykit/secrets.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "time"
|
4
|
-
|
5
|
-
module Raykit
|
6
|
-
# Provides functionality to record the time execution times
|
7
|
-
class Secrets < Hash
|
8
|
-
def initialize
|
9
|
-
if ENV.key?("RAYKIT_SECRETS_PATH")
|
10
|
-
secrets_file = ENV["RAYKIT_SECRETS_PATH"]
|
11
|
-
if File.exist?(secrets_file)
|
12
|
-
text = IO.read(secrets_file)
|
13
|
-
if text.length > 7
|
14
|
-
data = JSON.parse(text)
|
15
|
-
data.each do |key, value|
|
16
|
-
self[key] = value
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def hide(text)
|
24
|
-
hidden = text
|
25
|
-
each do |_k, v|
|
26
|
-
hidden = hidden.gsub(v, "****") if !v.nil? && v.length.positive?
|
27
|
-
end
|
28
|
-
hidden
|
29
|
-
end
|
30
|
-
|
31
|
-
def save
|
32
|
-
if ENV.key?("RAYKIT_SECRETS_PATH")
|
33
|
-
secrets_file = ENV["RAYKIT_SECRETS_PATH"]
|
34
|
-
File.open(secrets_file, "w") { |f| f.puts to_json }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
module Raykit
|
6
|
+
# Provides functionality to record the time execution times
|
7
|
+
class Secrets < Hash
|
8
|
+
def initialize
|
9
|
+
if ENV.key?("RAYKIT_SECRETS_PATH")
|
10
|
+
secrets_file = ENV["RAYKIT_SECRETS_PATH"]
|
11
|
+
if File.exist?(secrets_file)
|
12
|
+
text = IO.read(secrets_file)
|
13
|
+
if text.length > 7
|
14
|
+
data = JSON.parse(text)
|
15
|
+
data.each do |key, value|
|
16
|
+
self[key] = value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def hide(text)
|
24
|
+
hidden = text
|
25
|
+
each do |_k, v|
|
26
|
+
hidden = hidden.gsub(v, "****") if !v.nil? && v.length.positive?
|
27
|
+
end
|
28
|
+
hidden
|
29
|
+
end
|
30
|
+
|
31
|
+
def save
|
32
|
+
if ENV.key?("RAYKIT_SECRETS_PATH")
|
33
|
+
secrets_file = ENV["RAYKIT_SECRETS_PATH"]
|
34
|
+
File.open(secrets_file, "w") { |f| f.puts to_json }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/raykit/sourceImport.rb
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class SourceImport < Hash
|
5
|
-
def initialize(url, source, glob, target, commit)
|
6
|
-
self["remote"] = url
|
7
|
-
self["source"] = source
|
8
|
-
self["glob"] = glob
|
9
|
-
self["target"] = target
|
10
|
-
self["commit"] = commit
|
11
|
-
end
|
12
|
-
|
13
|
-
def remote
|
14
|
-
self["remote"]
|
15
|
-
end
|
16
|
-
|
17
|
-
def source
|
18
|
-
self["source"]
|
19
|
-
end
|
20
|
-
|
21
|
-
def target
|
22
|
-
self["target"]
|
23
|
-
end
|
24
|
-
|
25
|
-
def glob
|
26
|
-
self["glob"]
|
27
|
-
end
|
28
|
-
|
29
|
-
def update
|
30
|
-
work = self["remote"].work_dir
|
31
|
-
work_parent = File.dirname(work)
|
32
|
-
FileUtils.mkdir_p(work_parent) unless Dir.exist?(work_parent)
|
33
|
-
if Dir.exist?(work)
|
34
|
-
Dir.chdir(work) do
|
35
|
-
cmd = Command.new("git pull")
|
36
|
-
end
|
37
|
-
else
|
38
|
-
PROJECT.run("git clone #{remote} #{work}")
|
39
|
-
end
|
40
|
-
|
41
|
-
Dir.chdir(work) do
|
42
|
-
text = `git log -n 1`
|
43
|
-
scan = text.scan(/commit (\w+)\s/)
|
44
|
-
self["commit"] = scan[0][0].to_s
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def copy
|
49
|
-
if target.length.zero?
|
50
|
-
puts "target has not been specified"
|
51
|
-
else
|
52
|
-
FileUtils.remove_dir(target) if Dir.exist?(target)
|
53
|
-
count = 0
|
54
|
-
source_names = []
|
55
|
-
work = self["remote"].work_dir
|
56
|
-
Dir.chdir(work) do
|
57
|
-
cmd = Command.new("rake clean") if File.exist?("rakefile.rb")
|
58
|
-
Dir.chdir(source) do
|
59
|
-
source_names = Dir.glob(self["glob"])
|
60
|
-
end
|
61
|
-
end
|
62
|
-
source_names.each do |source_name|
|
63
|
-
source_file = "#{work}/#{source}/#{source_name}"
|
64
|
-
target_name = "#{target}/#{source_name}"
|
65
|
-
target_parent = File.dirname(target_name)
|
66
|
-
FileUtils.mkdir_p(target_parent) unless Dir.exist?(target_parent)
|
67
|
-
FileUtils.copy(source_file, target_name)
|
68
|
-
count += 1
|
69
|
-
end
|
70
|
-
puts " copied #{count} files to #{target}"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class SourceImport < Hash
|
5
|
+
def initialize(url, source, glob, target, commit)
|
6
|
+
self["remote"] = url
|
7
|
+
self["source"] = source
|
8
|
+
self["glob"] = glob
|
9
|
+
self["target"] = target
|
10
|
+
self["commit"] = commit
|
11
|
+
end
|
12
|
+
|
13
|
+
def remote
|
14
|
+
self["remote"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def source
|
18
|
+
self["source"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def target
|
22
|
+
self["target"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def glob
|
26
|
+
self["glob"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
work = self["remote"].work_dir
|
31
|
+
work_parent = File.dirname(work)
|
32
|
+
FileUtils.mkdir_p(work_parent) unless Dir.exist?(work_parent)
|
33
|
+
if Dir.exist?(work)
|
34
|
+
Dir.chdir(work) do
|
35
|
+
cmd = Command.new("git pull")
|
36
|
+
end
|
37
|
+
else
|
38
|
+
PROJECT.run("git clone #{remote} #{work}")
|
39
|
+
end
|
40
|
+
|
41
|
+
Dir.chdir(work) do
|
42
|
+
text = `git log -n 1`
|
43
|
+
scan = text.scan(/commit (\w+)\s/)
|
44
|
+
self["commit"] = scan[0][0].to_s
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def copy
|
49
|
+
if target.length.zero?
|
50
|
+
puts "target has not been specified"
|
51
|
+
else
|
52
|
+
FileUtils.remove_dir(target) if Dir.exist?(target)
|
53
|
+
count = 0
|
54
|
+
source_names = []
|
55
|
+
work = self["remote"].work_dir
|
56
|
+
Dir.chdir(work) do
|
57
|
+
cmd = Command.new("rake clean") if File.exist?("rakefile.rb")
|
58
|
+
Dir.chdir(source) do
|
59
|
+
source_names = Dir.glob(self["glob"])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
source_names.each do |source_name|
|
63
|
+
source_file = "#{work}/#{source}/#{source_name}"
|
64
|
+
target_name = "#{target}/#{source_name}"
|
65
|
+
target_parent = File.dirname(target_name)
|
66
|
+
FileUtils.mkdir_p(target_parent) unless Dir.exist?(target_parent)
|
67
|
+
FileUtils.copy(source_file, target_name)
|
68
|
+
count += 1
|
69
|
+
end
|
70
|
+
puts " copied #{count} files to #{target}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/raykit/sourceImports.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class SourceImports < Array
|
5
|
-
def initialize(urls)
|
6
|
-
urls.each do |url|
|
7
|
-
self << SourceImport.new(url, "src", "**/*.cs", "dep", "")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def update
|
12
|
-
each(&:update)
|
13
|
-
end
|
14
|
-
|
15
|
-
def copy
|
16
|
-
each(&:copy)
|
17
|
-
end
|
18
|
-
|
19
|
-
def targets_exist?
|
20
|
-
each do |si|
|
21
|
-
return false unless Dir.exist?(si.target)
|
22
|
-
end
|
23
|
-
true
|
24
|
-
end
|
25
|
-
|
26
|
-
def save(filename)
|
27
|
-
File.open(filename, "w") do |f|
|
28
|
-
f.write(JSON.pretty_generate(self))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.load(filename)
|
33
|
-
sourceImports = SourceImports.new([])
|
34
|
-
array = JSON.parse(IO.read(filename))
|
35
|
-
array.each do |hash|
|
36
|
-
sourceImport = SourceImport.new(hash["remote"], hash["source"], hash["glob"], hash["target"],
|
37
|
-
hash["commit"])
|
38
|
-
sourceImports << sourceImport
|
39
|
-
end
|
40
|
-
sourceImports
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class SourceImports < Array
|
5
|
+
def initialize(urls)
|
6
|
+
urls.each do |url|
|
7
|
+
self << SourceImport.new(url, "src", "**/*.cs", "dep", "")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
each(&:update)
|
13
|
+
end
|
14
|
+
|
15
|
+
def copy
|
16
|
+
each(&:copy)
|
17
|
+
end
|
18
|
+
|
19
|
+
def targets_exist?
|
20
|
+
each do |si|
|
21
|
+
return false unless Dir.exist?(si.target)
|
22
|
+
end
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def save(filename)
|
27
|
+
File.open(filename, "w") do |f|
|
28
|
+
f.write(JSON.pretty_generate(self))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.load(filename)
|
33
|
+
sourceImports = SourceImports.new([])
|
34
|
+
array = JSON.parse(IO.read(filename))
|
35
|
+
array.each do |hash|
|
36
|
+
sourceImport = SourceImport.new(hash["remote"], hash["source"], hash["glob"], hash["target"],
|
37
|
+
hash["commit"])
|
38
|
+
sourceImports << sourceImport
|
39
|
+
end
|
40
|
+
sourceImports
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/raykit/string.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative("./environment")
|
4
|
-
|
5
|
-
class String
|
6
|
-
def work_dir
|
7
|
-
rel_name = sub("https://", "").gsub("http://", "").gsub(".git", "")
|
8
|
-
"#{Raykit::Environment.get_dev_dir("work")}/#{rel_name}"
|
9
|
-
end
|
10
|
-
|
11
|
-
def latest_commit
|
12
|
-
Dir.chdir(self) do
|
13
|
-
text = `git log -n 1`
|
14
|
-
scan = text.scan(/commit (\w+)\s/)
|
15
|
-
return scan[0][0].to_s
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative("./environment")
|
4
|
+
|
5
|
+
class String
|
6
|
+
def work_dir
|
7
|
+
rel_name = sub("https://", "").gsub("http://", "").gsub(".git", "")
|
8
|
+
"#{Raykit::Environment.get_dev_dir("work")}/#{rel_name}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def latest_commit
|
12
|
+
Dir.chdir(self) do
|
13
|
+
text = `git log -n 1`
|
14
|
+
scan = text.scan(/commit (\w+)\s/)
|
15
|
+
return scan[0][0].to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|