manageiq-cross_repo 1.0.1 → 1.1.1
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/.codeclimate.yml +16 -0
- data/.rubocop.yml +4 -0
- data/.rubocop_cc.yml +4 -0
- data/.rubocop_local.yml +0 -0
- data/.travis.yml +1 -3
- data/README.md +2 -0
- data/exe/manageiq-cross_repo +19 -1
- data/lib/manageiq/cross_repo/repository.rb +15 -2
- data/lib/manageiq/cross_repo/runner.rb +104 -19
- data/lib/manageiq/cross_repo/version.rb +1 -1
- data/manageiq-cross_repo.gemspec +1 -0
- metadata +25 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cae79b4ed33115478d43ed4afef93fc5af092ab1fd03d540709704556fe25718
|
4
|
+
data.tar.gz: 8ba6a4011ac76bc19a9417e2c63342b1c44d145313336e10ae1107fc3cdfc336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d1083beae51b21b888b569aafad5a267908c816c71665969251ab1fc7b3e240854fa29102184dcd4e2dc031c044b5403b8e08a6c0845c9d5ad7a804c93680c8
|
7
|
+
data.tar.gz: 16cddb73598fc9c17684907e2f0ba272cded605c31764d50791fc43b2db72bd212000d6f1e3c568679d5b028321b15900e53b2d0f01994bfd0a2ec340bbd2161
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
prepare:
|
2
|
+
fetch:
|
3
|
+
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml
|
4
|
+
path: ".rubocop_base.yml"
|
5
|
+
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml
|
6
|
+
path: ".rubocop_cc_base.yml"
|
7
|
+
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/base.yml
|
8
|
+
path: styles/base.yml
|
9
|
+
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/cc_base.yml
|
10
|
+
path: styles/cc_base.yml
|
11
|
+
plugins:
|
12
|
+
rubocop:
|
13
|
+
enabled: true
|
14
|
+
config: ".rubocop_cc.yml"
|
15
|
+
channel: rubocop-0-82
|
16
|
+
version: '2'
|
data/.rubocop.yml
ADDED
data/.rubocop_cc.yml
ADDED
data/.rubocop_local.yml
ADDED
File without changes
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,8 @@ Options:
|
|
16
16
|
If any of the repositories in the list are a core repository that will
|
17
17
|
be used as the root repository, otherwise ManageIQ/manageiq@master will be the default.
|
18
18
|
Can also be passed as a REPOS environment variable.
|
19
|
+
-s, --script-cmd=<s> Optional, a command string for running the specs. Defaults to `bundle exec rake`.
|
20
|
+
(default: )
|
19
21
|
|
20
22
|
-v, --version Print version and exit
|
21
23
|
-h, --help Show this message
|
data/exe/manageiq-cross_repo
CHANGED
@@ -31,6 +31,18 @@ opts = Optimist.options do
|
|
31
31
|
Can also be passed as a REPOS environment variable.
|
32
32
|
EOS
|
33
33
|
|
34
|
+
opt :test_suite, <<~EOS, :type => :string, :default => ENV["TEST_SUITE"].presence
|
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 .travis.yml to conditionally perform different setup tasks
|
37
|
+
and also to run different test suites, e.g. spec:javascript.
|
38
|
+
EOS
|
39
|
+
|
40
|
+
opt :script_cmd, <<~EOS, :type => :string, :default => ENV["SCRIPT_CMD"].presence
|
41
|
+
Optional, a command string for running the specs.
|
42
|
+
If present this will override the the script section of the test_repo's .travis.yml
|
43
|
+
EOS
|
44
|
+
|
45
|
+
|
34
46
|
# Manually add these so they appear in the right order in the help output
|
35
47
|
banner ""
|
36
48
|
opt :version, "Print version and exit"
|
@@ -84,9 +96,15 @@ opts = Optimist.options do
|
|
84
96
|
end
|
85
97
|
|
86
98
|
opts[:repos] = opts[:repos].flatten.flat_map { |repo| repo.split(",").map(&:strip) }
|
99
|
+
test_repo, repos, test_suite, script_cmd = opts.values_at(:test_repo, :repos, :test_suite, :script_cmd)
|
87
100
|
|
88
101
|
begin
|
89
|
-
ManageIQ::CrossRepo.run(
|
102
|
+
ManageIQ::CrossRepo.run(
|
103
|
+
:test_repo => test_repo,
|
104
|
+
:repos => repos,
|
105
|
+
:test_suite => test_suite,
|
106
|
+
:script_cmd => script_cmd
|
107
|
+
)
|
90
108
|
rescue ArgumentError => e
|
91
109
|
Optimist.die e
|
92
110
|
end
|
@@ -34,7 +34,7 @@ module ManageIQ::CrossRepo
|
|
34
34
|
puts "Fetching #{tarball_url}"
|
35
35
|
|
36
36
|
Dir.mktmpdir do |dir|
|
37
|
-
Mixlib::Archive.new(
|
37
|
+
Mixlib::Archive.new(open_tarball_url(tarball_url)).extract(dir)
|
38
38
|
|
39
39
|
content_dir = Pathname.new(dir).children.detect(&:directory?)
|
40
40
|
FileUtils.mkdir_p(path.dirname)
|
@@ -147,12 +147,25 @@ module ManageIQ::CrossRepo
|
|
147
147
|
url && File.join(url, "tarball", sha)
|
148
148
|
end
|
149
149
|
|
150
|
+
def open_tarball_url(url)
|
151
|
+
archive = URI.open(tarball_url, "rb")
|
152
|
+
|
153
|
+
if archive.kind_of?(StringIO)
|
154
|
+
archive = Tempfile.new('cross_repo').tap do |f|
|
155
|
+
f.write(archive.string)
|
156
|
+
f.fsync
|
157
|
+
end.path
|
158
|
+
end
|
159
|
+
|
160
|
+
archive
|
161
|
+
end
|
162
|
+
|
150
163
|
def git_branch_to_sha(url, branch)
|
151
164
|
`git ls-remote #{url} #{branch}`.split("\t").first
|
152
165
|
end
|
153
166
|
|
154
167
|
def git_pr_to_sha(url, pr)
|
155
|
-
git_branch_to_sha(url, "refs/pull/#{pr}/head")
|
168
|
+
git_branch_to_sha(url, "refs/pull/#{pr}/merge") || git_branch_to_sha(url, "refs/pull/#{pr}/head")
|
156
169
|
end
|
157
170
|
end
|
158
171
|
end
|
@@ -3,9 +3,9 @@ require "active_support/core_ext/object/blank"
|
|
3
3
|
|
4
4
|
module ManageIQ::CrossRepo
|
5
5
|
class Runner
|
6
|
-
attr_reader :test_repo, :core_repo, :gem_repos
|
6
|
+
attr_reader :test_repo, :core_repo, :gem_repos, :test_suite, :script_cmd
|
7
7
|
|
8
|
-
def initialize(test_repo,
|
8
|
+
def initialize(test_repo:, repos:, test_suite: nil, script_cmd: nil)
|
9
9
|
@test_repo = Repository.new(test_repo || "ManageIQ/manageiq@master")
|
10
10
|
|
11
11
|
core_repos, @gem_repos = Array(repos).collect { |repo| Repository.new(repo) }.partition(&:core?)
|
@@ -20,34 +20,33 @@ module ManageIQ::CrossRepo
|
|
20
20
|
|
21
21
|
@core_repo ||= Repository.new("ManageIQ/manageiq@master")
|
22
22
|
end
|
23
|
+
|
24
|
+
@script_cmd = script_cmd.presence
|
25
|
+
@test_suite = test_suite.presence
|
23
26
|
end
|
24
27
|
|
25
28
|
def run
|
26
29
|
test_repo.ensure_clone
|
27
|
-
test_repo.core?
|
30
|
+
core_repo.ensure_clone unless test_repo.core?
|
31
|
+
prepare_gem_repos
|
32
|
+
run_tests
|
28
33
|
end
|
29
34
|
|
30
35
|
private
|
31
36
|
|
32
|
-
def
|
33
|
-
|
37
|
+
def bundle_path
|
38
|
+
app_path = Pathname.new(ENV["TRAVIS_BUILD_DIR"].presence || Pathname.pwd)
|
39
|
+
app_path.join("vendor", "bundle")
|
40
|
+
end
|
34
41
|
|
42
|
+
def run_tests
|
35
43
|
with_test_env do
|
36
|
-
|
37
|
-
system!("bin/setup")
|
38
|
-
system!("bundle exec rake")
|
44
|
+
run_test_script(build_test_script)
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
|
-
def
|
43
|
-
core_repo.
|
44
|
-
prepare_gem_repos
|
45
|
-
|
46
|
-
env_vars = {"MANAGEIQ_REPO" => core_repo.path.to_s}
|
47
|
-
with_test_env do
|
48
|
-
system!(env_vars, "bin/setup")
|
49
|
-
system!("bundle exec rake")
|
50
|
-
end
|
48
|
+
def env_vars
|
49
|
+
{"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}
|
51
50
|
end
|
52
51
|
|
53
52
|
def with_test_env
|
@@ -63,17 +62,26 @@ module ManageIQ::CrossRepo
|
|
63
62
|
repo = Dir.pwd.split("/").last(2).join("/")
|
64
63
|
puts "\e[36mDEBUG: #{repo} - #{args.join(" ")}\e[0m"
|
65
64
|
end
|
66
|
-
|
65
|
+
|
66
|
+
Process.wait(spawn(*args))
|
67
|
+
exit($?.exitstatus) unless $?.success?
|
67
68
|
end
|
68
69
|
|
69
70
|
def generate_bundler_d
|
70
71
|
bundler_d_path = core_repo.path.join("bundler.d")
|
71
72
|
override_path = bundler_d_path.join("overrides.rb")
|
72
73
|
|
74
|
+
require "fileutils"
|
75
|
+
|
73
76
|
if gem_repos.empty?
|
74
77
|
FileUtils.rm_f override_path
|
75
78
|
else
|
76
|
-
content = gem_repos.map
|
79
|
+
content = gem_repos.map do |gem|
|
80
|
+
# If there is a gemspec get the name of the gem from that instead of the repository
|
81
|
+
gem_name = gem.path.glob("*.gemspec")&.first&.basename(".gemspec") || gem.repo
|
82
|
+
"ensure_gem \"#{gem_name}\", :path => \"#{gem.path}\""
|
83
|
+
end.join("\n")
|
84
|
+
|
77
85
|
FileUtils.mkdir_p(bundler_d_path)
|
78
86
|
|
79
87
|
File.write(override_path, content)
|
@@ -84,5 +92,82 @@ module ManageIQ::CrossRepo
|
|
84
92
|
gem_repos.each { |gem_repo| gem_repo.ensure_clone }
|
85
93
|
generate_bundler_d
|
86
94
|
end
|
95
|
+
|
96
|
+
def run_test_script(test_script)
|
97
|
+
r, w = IO.pipe
|
98
|
+
w.write(test_script)
|
99
|
+
w.close
|
100
|
+
|
101
|
+
system!(env_vars, "/bin/bash -s", :in => r, :out => $stdout, :err => $stderr)
|
102
|
+
end
|
103
|
+
|
104
|
+
def build_test_script
|
105
|
+
load_travis_yml!
|
106
|
+
|
107
|
+
commands = environment_setup_commands
|
108
|
+
|
109
|
+
sections = %w[before_install install before_script script]
|
110
|
+
commands += sections.flat_map do |section|
|
111
|
+
# Travis sections can have a single command or an array of commands
|
112
|
+
section_commands = Array(travis_yml[section]).map { |cmd| "#{cmd} || exit $?" }
|
113
|
+
next if section_commands.blank?
|
114
|
+
|
115
|
+
[
|
116
|
+
"echo 'travis_fold:start:#{section}'",
|
117
|
+
*section_commands,
|
118
|
+
"echo 'travis_fold:end:#{section}'"
|
119
|
+
]
|
120
|
+
end.compact
|
121
|
+
|
122
|
+
<<~BASH_SCRIPT
|
123
|
+
#!/bin/bash
|
124
|
+
|
125
|
+
#{commands.join("\n")}
|
126
|
+
BASH_SCRIPT
|
127
|
+
end
|
128
|
+
|
129
|
+
def environment_setup_commands
|
130
|
+
setup_commands = []
|
131
|
+
|
132
|
+
if travis_yml["node_js"]
|
133
|
+
setup_commands << "source ~/.nvm/nvm.sh"
|
134
|
+
setup_commands += Array(travis_yml["node_js"]).map do |node_version|
|
135
|
+
"nvm install #{node_version}"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
setup_commands
|
140
|
+
end
|
141
|
+
|
142
|
+
def load_travis_yml!
|
143
|
+
# Load the test_repo's .travis.yml file
|
144
|
+
travis_yml
|
145
|
+
|
146
|
+
# Set missing travis sections to the proper defaults
|
147
|
+
travis_yml["install"] ||= travis_defaults[travis_yml["language"]]["install"]
|
148
|
+
|
149
|
+
travis_yml["script"] = script_cmd if script_cmd.present?
|
150
|
+
travis_yml["script"] ||= travis_defaults[travis_yml["language"]]["script"]
|
151
|
+
end
|
152
|
+
|
153
|
+
def travis_yml
|
154
|
+
@travis_yml ||= begin
|
155
|
+
require "yaml"
|
156
|
+
YAML.load_file(".travis.yml")
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def travis_defaults
|
161
|
+
@travis_defaults ||= {
|
162
|
+
"node_js" => {
|
163
|
+
"install" => "npm install",
|
164
|
+
"script" => "npm test"
|
165
|
+
},
|
166
|
+
"ruby" => {
|
167
|
+
"install" => "bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}",
|
168
|
+
"script" => "bundle exec rake"
|
169
|
+
}
|
170
|
+
}.freeze
|
171
|
+
end
|
87
172
|
end
|
88
173
|
end
|
data/manageiq-cross_repo.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
+
spec.add_development_dependency "manageiq-style"
|
25
26
|
spec.add_development_dependency "rake"
|
26
27
|
spec.add_development_dependency "rspec"
|
27
28
|
spec.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.1.1
|
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:
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: manageiq-style
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,14 +123,18 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
description: ManageIQ CrossRepo testing library
|
112
|
-
email:
|
126
|
+
email:
|
113
127
|
executables:
|
114
128
|
- manageiq-cross_repo
|
115
129
|
extensions: []
|
116
130
|
extra_rdoc_files: []
|
117
131
|
files:
|
132
|
+
- ".codeclimate.yml"
|
118
133
|
- ".gitignore"
|
119
134
|
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- ".rubocop_cc.yml"
|
137
|
+
- ".rubocop_local.yml"
|
120
138
|
- ".travis.yml"
|
121
139
|
- Gemfile
|
122
140
|
- LICENSE.txt
|
@@ -137,7 +155,7 @@ licenses:
|
|
137
155
|
metadata:
|
138
156
|
homepage_uri: https://github.com/ManageIQ/manageiq-cross_repo
|
139
157
|
source_code_uri: https://github.com/ManageIQ/manageiq-cross_repo
|
140
|
-
post_install_message:
|
158
|
+
post_install_message:
|
141
159
|
rdoc_options: []
|
142
160
|
require_paths:
|
143
161
|
- lib
|
@@ -152,8 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
170
|
- !ruby/object:Gem::Version
|
153
171
|
version: '0'
|
154
172
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
156
|
-
signing_key:
|
173
|
+
rubygems_version: 3.2.5
|
174
|
+
signing_key:
|
157
175
|
specification_version: 4
|
158
176
|
summary: ManageIQ CrossRepo testing library
|
159
177
|
test_files: []
|