manageiq-cross_repo 1.1.0 → 1.2.0
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/.gitignore +1 -0
- data/exe/manageiq-cross_repo +2 -2
- data/lib/manageiq/cross_repo/repository.rb +15 -1
- data/lib/manageiq/cross_repo/runner/base.rb +102 -0
- data/lib/manageiq/cross_repo/runner/github.rb +30 -0
- data/lib/manageiq/cross_repo/runner/travis.rb +20 -0
- data/lib/manageiq/cross_repo/runner.rb +14 -73
- data/lib/manageiq/cross_repo/version.rb +1 -1
- data/manageiq-cross_repo.gemspec +1 -1
- data/repos/.gitkeep +0 -0
- metadata +15 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 303420d045bf57bacab3391945b7652115e42e2dece17c37c9c15b6bfe4e07bd
|
4
|
+
data.tar.gz: fd8e604e86f2ed8abb7c383ad08403cb4b20970caeba3fdae913d55fb87543ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94020cc0c92e37dca3df2c0eb78ec3b61e3874ea79d5fa09f5d16949d0acf28a99095c2396d3b3ae7b8ca92d8de7d7889084bf6cdce2fbde77c6efe0928aacdf
|
7
|
+
data.tar.gz: 040c9f3265bce6a0d51c7e0ab46cf414f7c8b7fb798a34725ee5e162adb137907ec699cbe004d7ab084e868a72fa41ed78f9e208332bb66fc546c43df68c4a81
|
data/.gitignore
CHANGED
data/exe/manageiq-cross_repo
CHANGED
@@ -33,13 +33,13 @@ opts = Optimist.options do
|
|
33
33
|
|
34
34
|
opt :test_suite, <<~EOS, :type => :string, :default => ENV["TEST_SUITE"].presence
|
35
35
|
Optional, the name of a rake test suite to pass as an environment variable to the test being run.
|
36
|
-
This is commonly used by the
|
36
|
+
This is commonly used by the CI config to conditionally perform different setup tasks
|
37
37
|
and also to run different test suites, e.g. spec:javascript.
|
38
38
|
EOS
|
39
39
|
|
40
40
|
opt :script_cmd, <<~EOS, :type => :string, :default => ENV["SCRIPT_CMD"].presence
|
41
41
|
Optional, a command string for running the specs.
|
42
|
-
If present this will override the the script section of the test_repo's
|
42
|
+
If present this will override the the script section of the test_repo's CI config
|
43
43
|
EOS
|
44
44
|
|
45
45
|
|
@@ -31,7 +31,9 @@ module ManageIQ::CrossRepo
|
|
31
31
|
require "tmpdir"
|
32
32
|
require "zlib"
|
33
33
|
|
34
|
-
|
34
|
+
retries ||= 0
|
35
|
+
|
36
|
+
puts "Fetching #{tarball_url}#{retry_count(retries)}"
|
35
37
|
|
36
38
|
Dir.mktmpdir do |dir|
|
37
39
|
Mixlib::Archive.new(open_tarball_url(tarball_url)).extract(dir)
|
@@ -40,6 +42,12 @@ module ManageIQ::CrossRepo
|
|
40
42
|
FileUtils.mkdir_p(path.dirname)
|
41
43
|
FileUtils.mv(content_dir, path)
|
42
44
|
end
|
45
|
+
rescue => e
|
46
|
+
retries += 1
|
47
|
+
raise if retries > 3
|
48
|
+
|
49
|
+
sleep 1
|
50
|
+
retry
|
43
51
|
end
|
44
52
|
|
45
53
|
private
|
@@ -167,5 +175,11 @@ module ManageIQ::CrossRepo
|
|
167
175
|
def git_pr_to_sha(url, pr)
|
168
176
|
git_branch_to_sha(url, "refs/pull/#{pr}/merge") || git_branch_to_sha(url, "refs/pull/#{pr}/head")
|
169
177
|
end
|
178
|
+
|
179
|
+
def retry_count(num)
|
180
|
+
return if num == 0
|
181
|
+
|
182
|
+
" (retry #{num}/3)"
|
183
|
+
end
|
170
184
|
end
|
171
185
|
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require "active_support/core_ext/object/blank"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module ManageIQ::CrossRepo
|
5
|
+
class Runner
|
6
|
+
class Base
|
7
|
+
attr_accessor :script_cmd
|
8
|
+
|
9
|
+
def initialize(script_cmd = nil)
|
10
|
+
@script_cmd = script_cmd.presence
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_test_script
|
14
|
+
load_config!
|
15
|
+
build_script
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def environment_setup_commands
|
21
|
+
commands = []
|
22
|
+
|
23
|
+
if config["node_js"]
|
24
|
+
commands << "source ~/.nvm/nvm.sh"
|
25
|
+
commands += Array(config["node_js"]).map do |node_version|
|
26
|
+
"nvm install #{node_version}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
commands.any? ? build_section("environment", *commands) : commands
|
31
|
+
end
|
32
|
+
|
33
|
+
def section_commands
|
34
|
+
sections = %w[before_install install before_script script]
|
35
|
+
sections.flat_map do |section|
|
36
|
+
commands = build_section_commands(section)
|
37
|
+
build_section(section, *commands) if commands.present?
|
38
|
+
end.compact
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_commands
|
42
|
+
environment_setup_commands + section_commands
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_section_commands(section)
|
46
|
+
# Travis sections can have a single command or an array of commands
|
47
|
+
Array(config[section]).map { |cmd| "#{cmd} || exit $?" }
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_section(section, *commands)
|
51
|
+
[
|
52
|
+
"echo 'travis_fold:start:#{section}'",
|
53
|
+
*commands,
|
54
|
+
"echo 'travis_fold:end:#{section}'"
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_script
|
59
|
+
<<~BASH_SCRIPT
|
60
|
+
#!/bin/bash
|
61
|
+
|
62
|
+
#{build_commands.join("\n")}
|
63
|
+
BASH_SCRIPT
|
64
|
+
end
|
65
|
+
|
66
|
+
def load_config!
|
67
|
+
config
|
68
|
+
end
|
69
|
+
|
70
|
+
def config
|
71
|
+
@config ||= travis_config.tap do |config|
|
72
|
+
# Set missing sections to the proper defaults
|
73
|
+
config["install"] ||= defaults[config["language"]]["install"]
|
74
|
+
|
75
|
+
config["script"] = script_cmd if script_cmd.present?
|
76
|
+
config["script"] ||= defaults[config["language"]]["script"]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def travis_config
|
81
|
+
raise NotImplementedError, "must be implemented in a subclass"
|
82
|
+
end
|
83
|
+
|
84
|
+
def defaults
|
85
|
+
@defaults ||= {
|
86
|
+
"node_js" => {
|
87
|
+
"language" => "node_js",
|
88
|
+
"node_js" => ["12"],
|
89
|
+
"install" => "npm install",
|
90
|
+
"script" => "npm test"
|
91
|
+
},
|
92
|
+
"ruby" => {
|
93
|
+
"language" => "ruby",
|
94
|
+
"rvm" => ["2.7"],
|
95
|
+
"install" => "bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}",
|
96
|
+
"script" => "bundle exec rake"
|
97
|
+
}
|
98
|
+
}.freeze
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "./base"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module ManageIQ::CrossRepo
|
5
|
+
class Runner
|
6
|
+
class Github < Base
|
7
|
+
CONFIG_FILE = ".github/workflows/ci.yaml".freeze
|
8
|
+
|
9
|
+
def self.available?
|
10
|
+
File.exist?(CONFIG_FILE)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def travis_config
|
16
|
+
steps = github_config["jobs"]["ci"]["steps"]
|
17
|
+
language = steps.any? { |s| s["uses"] == "ruby/setup-ruby@v1" } ? "ruby" : "node_js"
|
18
|
+
|
19
|
+
defaults[language].clone.tap do |config|
|
20
|
+
script_step = steps.detect { |s| s["name"] == "Run tests" }
|
21
|
+
config["script"] = script_step["run"] if script_step
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def github_config
|
26
|
+
YAML.load_file(CONFIG_FILE)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative "./base"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module ManageIQ::CrossRepo
|
5
|
+
class Runner
|
6
|
+
class Travis < Base
|
7
|
+
CONFIG_FILE = ".travis.yml".freeze
|
8
|
+
|
9
|
+
def self.available?
|
10
|
+
File.exist?(CONFIG_FILE)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def travis_config
|
16
|
+
YAML.load_file(CONFIG_FILE)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require "manageiq/cross_repo/repository"
|
2
|
+
require "active_support/core_ext/class/subclasses"
|
2
3
|
require "active_support/core_ext/object/blank"
|
4
|
+
Dir.glob(File.join(__dir__, "runner", "*")).sort.each { |f| require f }
|
3
5
|
|
4
6
|
module ManageIQ::CrossRepo
|
5
7
|
class Runner
|
@@ -16,8 +18,6 @@ module ManageIQ::CrossRepo
|
|
16
18
|
|
17
19
|
@core_repo = @test_repo
|
18
20
|
else
|
19
|
-
raise ArgumentError, "You must pass at least one repo when running a plugin test." if repos.blank?
|
20
|
-
|
21
21
|
@core_repo ||= Repository.new("ManageIQ/manageiq@master")
|
22
22
|
end
|
23
23
|
|
@@ -34,14 +34,20 @@ module ManageIQ::CrossRepo
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
+
def bundle_path
|
38
|
+
app_path = Pathname.new(ENV["TRAVIS_BUILD_DIR"].presence || Pathname.pwd)
|
39
|
+
app_path.join("vendor", "bundle")
|
40
|
+
end
|
41
|
+
|
37
42
|
def run_tests
|
38
43
|
with_test_env do
|
39
|
-
|
44
|
+
test_script = script_source.new(script_cmd).build_test_script
|
45
|
+
run_test_script(test_script)
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
43
49
|
def env_vars
|
44
|
-
{"MANAGEIQ_REPO" => core_repo.path.to_s, "TRAVIS_BUILD_DIR" => test_repo.path.to_s, "TEST_SUITE" => test_suite}
|
50
|
+
{"MANAGEIQ_REPO" => core_repo.path.to_s, "TRAVIS_BUILD_DIR" => test_repo.path.to_s, "BUNDLE_PATH" => bundle_path.to_s, "TEST_SUITE" => test_suite}
|
45
51
|
end
|
46
52
|
|
47
53
|
def with_test_env
|
@@ -62,6 +68,10 @@ module ManageIQ::CrossRepo
|
|
62
68
|
exit($?.exitstatus) unless $?.success?
|
63
69
|
end
|
64
70
|
|
71
|
+
def script_source
|
72
|
+
Base.descendants.detect(&:available?)
|
73
|
+
end
|
74
|
+
|
65
75
|
def generate_bundler_d
|
66
76
|
bundler_d_path = core_repo.path.join("bundler.d")
|
67
77
|
override_path = bundler_d_path.join("overrides.rb")
|
@@ -95,74 +105,5 @@ module ManageIQ::CrossRepo
|
|
95
105
|
|
96
106
|
system!(env_vars, "/bin/bash -s", :in => r, :out => $stdout, :err => $stderr)
|
97
107
|
end
|
98
|
-
|
99
|
-
def build_test_script
|
100
|
-
load_travis_yml!
|
101
|
-
|
102
|
-
commands = environment_setup_commands
|
103
|
-
|
104
|
-
sections = %w[before_install install before_script script]
|
105
|
-
commands += sections.flat_map do |section|
|
106
|
-
# Travis sections can have a single command or an array of commands
|
107
|
-
section_commands = Array(travis_yml[section]).map { |cmd| "#{cmd} || exit $?" }
|
108
|
-
next if section_commands.blank?
|
109
|
-
|
110
|
-
[
|
111
|
-
"echo 'travis_fold:start:#{section}'",
|
112
|
-
*section_commands,
|
113
|
-
"echo 'travis_fold:end:#{section}'"
|
114
|
-
]
|
115
|
-
end.compact
|
116
|
-
|
117
|
-
<<~BASH_SCRIPT
|
118
|
-
#!/bin/bash
|
119
|
-
|
120
|
-
#{commands.join("\n")}
|
121
|
-
BASH_SCRIPT
|
122
|
-
end
|
123
|
-
|
124
|
-
def environment_setup_commands
|
125
|
-
setup_commands = []
|
126
|
-
|
127
|
-
if travis_yml["node_js"]
|
128
|
-
setup_commands << "source ~/.nvm/nvm.sh"
|
129
|
-
setup_commands += Array(travis_yml["node_js"]).map do |node_version|
|
130
|
-
"nvm install #{node_version}"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
setup_commands
|
135
|
-
end
|
136
|
-
|
137
|
-
def load_travis_yml!
|
138
|
-
# Load the test_repo's .travis.yml file
|
139
|
-
travis_yml
|
140
|
-
|
141
|
-
# Set missing travis sections to the proper defaults
|
142
|
-
travis_yml["install"] ||= travis_defaults[travis_yml["language"]]["install"]
|
143
|
-
|
144
|
-
travis_yml["script"] = script_cmd if script_cmd.present?
|
145
|
-
travis_yml["script"] ||= travis_defaults[travis_yml["language"]]["script"]
|
146
|
-
end
|
147
|
-
|
148
|
-
def travis_yml
|
149
|
-
@travis_yml ||= begin
|
150
|
-
require "yaml"
|
151
|
-
YAML.load_file(".travis.yml")
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def travis_defaults
|
156
|
-
@travis_defaults ||= {
|
157
|
-
"node_js" => {
|
158
|
-
"install" => "npm install",
|
159
|
-
"script" => "npm test"
|
160
|
-
},
|
161
|
-
"ruby" => {
|
162
|
-
"install" => "bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}",
|
163
|
-
"script" => "bundle exec rake"
|
164
|
-
}
|
165
|
-
}.freeze
|
166
|
-
end
|
167
108
|
end
|
168
109
|
end
|
data/manageiq-cross_repo.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "rspec"
|
28
28
|
spec.add_development_dependency "simplecov"
|
29
29
|
|
30
|
-
spec.add_dependency "activesupport"
|
30
|
+
spec.add_dependency "activesupport", "~> 6.0.3"
|
31
31
|
spec.add_dependency "ffi-libarchive"
|
32
32
|
spec.add_dependency "mixlib-archive"
|
33
33
|
spec.add_dependency "optimist"
|
data/repos/.gitkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manageiq-cross_repo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ManageIQ Authors
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: manageiq-style
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 6.0.3
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 6.0.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: ffi-libarchive
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: ManageIQ CrossRepo testing library
|
126
|
-
email:
|
126
|
+
email:
|
127
127
|
executables:
|
128
128
|
- manageiq-cross_repo
|
129
129
|
extensions: []
|
@@ -147,15 +147,19 @@ files:
|
|
147
147
|
- lib/manageiq/cross_repo.rb
|
148
148
|
- lib/manageiq/cross_repo/repository.rb
|
149
149
|
- lib/manageiq/cross_repo/runner.rb
|
150
|
+
- lib/manageiq/cross_repo/runner/base.rb
|
151
|
+
- lib/manageiq/cross_repo/runner/github.rb
|
152
|
+
- lib/manageiq/cross_repo/runner/travis.rb
|
150
153
|
- lib/manageiq/cross_repo/version.rb
|
151
154
|
- manageiq-cross_repo.gemspec
|
155
|
+
- repos/.gitkeep
|
152
156
|
homepage: https://github.com/ManageIQ/manageiq-cross_repo
|
153
157
|
licenses:
|
154
158
|
- MIT
|
155
159
|
metadata:
|
156
160
|
homepage_uri: https://github.com/ManageIQ/manageiq-cross_repo
|
157
161
|
source_code_uri: https://github.com/ManageIQ/manageiq-cross_repo
|
158
|
-
post_install_message:
|
162
|
+
post_install_message:
|
159
163
|
rdoc_options: []
|
160
164
|
require_paths:
|
161
165
|
- lib
|
@@ -170,8 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
174
|
- !ruby/object:Gem::Version
|
171
175
|
version: '0'
|
172
176
|
requirements: []
|
173
|
-
rubygems_version: 3.2.
|
174
|
-
signing_key:
|
177
|
+
rubygems_version: 3.2.27
|
178
|
+
signing_key:
|
175
179
|
specification_version: 4
|
176
180
|
summary: ManageIQ CrossRepo testing library
|
177
181
|
test_files: []
|