manageiq-cross_repo 1.0.4 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a92b33e5752bf49917ffffbc780d309d198c10f52176d210c7fbf3415ba96bfc
4
- data.tar.gz: 3a40038eb6a34fc60c8f6865951f8970121031505d6e1063acd2cc5f3a2dc7f0
3
+ metadata.gz: 756d32fbaca87b4fcd09bcb95dca76ad5e4560561586431dd64c7ea050d56573
4
+ data.tar.gz: 9ddbaeb1080a02757d20113cf93f6161086e24d91cc03a8793893900b9933969
5
5
  SHA512:
6
- metadata.gz: 14c902452a16f84aaded53ac84934f7165212f574a085ebd9ae92e30c5504ae74a8636013098d75ace760b4b14d5bd2f07891f8c63612df62cbae98e6607889d
7
- data.tar.gz: 3abde6ca7b2665648cb11f91d64a4cb953d22d6dc7cd39cc443f6cec2915e4f58a3b4e203cfefeae1cf1d5413fdbc0e5652902a013aa12053212872a805f5ab8
6
+ metadata.gz: f23fd2b6b57843d2974b06058786d1da8321d8eb83599fe4fe4935006e822ab036d5615cebc407db51c68c25f8d24bb3d78a85e37eb745565b68e66b55b35082
7
+ data.tar.gz: bd339e043a899aef5fafd10d2a8f85a59fc0d813b19d17c3b738ded4a6809b3f246e548eb2bdba0a11a5298fba3933296ffd4b1583a9fce2808ac62b503c613f
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
@@ -0,0 +1,4 @@
1
+ inherit_gem:
2
+ manageiq-style: ".rubocop_base.yml"
3
+ inherit_from:
4
+ - ".rubocop_local.yml"
data/.rubocop_cc.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from:
2
+ - ".rubocop_base.yml"
3
+ - ".rubocop_cc_base.yml"
4
+ - ".rubocop_local.yml"
File without changes
data/.travis.yml CHANGED
@@ -1,9 +1,7 @@
1
- dist: xenial
2
1
  language: ruby
3
2
  rvm:
4
3
  - 2.5.5
5
- cache:
6
- bundler: true
4
+ cache: bundler
7
5
  addons:
8
6
  postgresql: '10'
9
7
  apt:
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
@@ -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(opts[:test_repo], opts[:repos])
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
@@ -31,7 +31,9 @@ module ManageIQ::CrossRepo
31
31
  require "tmpdir"
32
32
  require "zlib"
33
33
 
34
- puts "Fetching #{tarball_url}"
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
@@ -148,7 +156,7 @@ module ManageIQ::CrossRepo
148
156
  end
149
157
 
150
158
  def open_tarball_url(url)
151
- archive = open(tarball_url, "rb")
159
+ archive = URI.open(tarball_url, "rb")
152
160
 
153
161
  if archive.kind_of?(StringIO)
154
162
  archive = Tempfile.new('cross_repo').tap do |f|
@@ -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
@@ -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, repos)
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,6 +20,9 @@ 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
@@ -31,16 +34,19 @@ module ManageIQ::CrossRepo
31
34
 
32
35
  private
33
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
+
34
42
  def run_tests
35
43
  with_test_env do
36
- system!({"TRAVIS_BUILD_DIR" => test_repo.path.to_s}, "bash", "tools/ci/before_install.sh") if ENV["CI"] && File.exist?("tools/ci/before_install.sh")
37
- system!(env_vars, "bin/setup")
38
- system!("bundle exec rake")
44
+ run_test_script(build_test_script)
39
45
  end
40
46
  end
41
47
 
42
48
  def env_vars
43
- {"MANAGEIQ_REPO" => core_repo.path.to_s}
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}
44
50
  end
45
51
 
46
52
  def with_test_env
@@ -56,13 +62,17 @@ module ManageIQ::CrossRepo
56
62
  repo = Dir.pwd.split("/").last(2).join("/")
57
63
  puts "\e[36mDEBUG: #{repo} - #{args.join(" ")}\e[0m"
58
64
  end
59
- exit($?.exitstatus) unless system(*args)
65
+
66
+ Process.wait(spawn(*args))
67
+ exit($?.exitstatus) unless $?.success?
60
68
  end
61
69
 
62
70
  def generate_bundler_d
63
71
  bundler_d_path = core_repo.path.join("bundler.d")
64
72
  override_path = bundler_d_path.join("overrides.rb")
65
73
 
74
+ require "fileutils"
75
+
66
76
  if gem_repos.empty?
67
77
  FileUtils.rm_f override_path
68
78
  else
@@ -71,6 +81,7 @@ module ManageIQ::CrossRepo
71
81
  gem_name = gem.path.glob("*.gemspec")&.first&.basename(".gemspec") || gem.repo
72
82
  "ensure_gem \"#{gem_name}\", :path => \"#{gem.path}\""
73
83
  end.join("\n")
84
+
74
85
  FileUtils.mkdir_p(bundler_d_path)
75
86
 
76
87
  File.write(override_path, content)
@@ -81,5 +92,82 @@ module ManageIQ::CrossRepo
81
92
  gem_repos.each { |gem_repo| gem_repo.ensure_clone }
82
93
  generate_bundler_d
83
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
84
172
  end
85
173
  end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module CrossRepo
3
- VERSION = "1.0.4"
3
+ VERSION = "1.1.3"
4
4
  end
5
5
  end
@@ -22,11 +22,12 @@ 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"
28
29
 
29
- spec.add_dependency "activesupport"
30
+ spec.add_dependency "activesupport", "~> 6.0.3"
30
31
  spec.add_dependency "ffi-libarchive"
31
32
  spec.add_dependency "mixlib-archive"
32
33
  spec.add_dependency "optimist"
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.0.4
4
+ version: 1.1.3
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: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2021-08-27 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
@@ -56,16 +70,16 @@ dependencies:
56
70
  name: activesupport
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ">="
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: 6.0.3
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
82
+ version: 6.0.3
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: ffi-libarchive
71
85
  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.1.2
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: []