manageiq-cross_repo 1.0.4 → 1.1.0

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: 054abc092ffedefe7b8dcd8bdefb3e010b8e1ed04607ed7ded476ec32e2d3c75
4
+ data.tar.gz: '080cdb1b599cdc5cb2f83738223a21077e31f6dce21b73ea1e959d140f82071a'
5
5
  SHA512:
6
- metadata.gz: 14c902452a16f84aaded53ac84934f7165212f574a085ebd9ae92e30c5504ae74a8636013098d75ace760b4b14d5bd2f07891f8c63612df62cbae98e6607889d
7
- data.tar.gz: 3abde6ca7b2665648cb11f91d64a4cb953d22d6dc7cd39cc443f6cec2915e4f58a3b4e203cfefeae1cf1d5413fdbc0e5652902a013aa12053212872a805f5ab8
6
+ metadata.gz: 97eb42a587763a8425ab9972942cacb09692caf996156c909f5e4bba27626a68ecbaae2529f7b1c523025ab98d6a7d071b7304ce662d08408c0767106ab26a06
7
+ data.tar.gz: 9ce7dfe06414015efdaf174fd872ce72ac342bca85012bb8982a787f536d5b9b4f531eaa7b7cb67d053ed1832b9b97da61fd580a8a75e9871251e3883158afad
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
@@ -148,7 +148,7 @@ module ManageIQ::CrossRepo
148
148
  end
149
149
 
150
150
  def open_tarball_url(url)
151
- archive = open(tarball_url, "rb")
151
+ archive = URI.open(tarball_url, "rb")
152
152
 
153
153
  if archive.kind_of?(StringIO)
154
154
  archive = Tempfile.new('cross_repo').tap do |f|
@@ -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
@@ -33,14 +36,12 @@ module ManageIQ::CrossRepo
33
36
 
34
37
  def run_tests
35
38
  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")
39
+ run_test_script(build_test_script)
39
40
  end
40
41
  end
41
42
 
42
43
  def env_vars
43
- {"MANAGEIQ_REPO" => core_repo.path.to_s}
44
+ {"MANAGEIQ_REPO" => core_repo.path.to_s, "TRAVIS_BUILD_DIR" => test_repo.path.to_s, "TEST_SUITE" => test_suite}
44
45
  end
45
46
 
46
47
  def with_test_env
@@ -56,13 +57,17 @@ module ManageIQ::CrossRepo
56
57
  repo = Dir.pwd.split("/").last(2).join("/")
57
58
  puts "\e[36mDEBUG: #{repo} - #{args.join(" ")}\e[0m"
58
59
  end
59
- exit($?.exitstatus) unless system(*args)
60
+
61
+ Process.wait(spawn(*args))
62
+ exit($?.exitstatus) unless $?.success?
60
63
  end
61
64
 
62
65
  def generate_bundler_d
63
66
  bundler_d_path = core_repo.path.join("bundler.d")
64
67
  override_path = bundler_d_path.join("overrides.rb")
65
68
 
69
+ require "fileutils"
70
+
66
71
  if gem_repos.empty?
67
72
  FileUtils.rm_f override_path
68
73
  else
@@ -71,6 +76,7 @@ module ManageIQ::CrossRepo
71
76
  gem_name = gem.path.glob("*.gemspec")&.first&.basename(".gemspec") || gem.repo
72
77
  "ensure_gem \"#{gem_name}\", :path => \"#{gem.path}\""
73
78
  end.join("\n")
79
+
74
80
  FileUtils.mkdir_p(bundler_d_path)
75
81
 
76
82
  File.write(override_path, content)
@@ -81,5 +87,82 @@ module ManageIQ::CrossRepo
81
87
  gem_repos.each { |gem_repo| gem_repo.ensure_clone }
82
88
  generate_bundler_d
83
89
  end
90
+
91
+ def run_test_script(test_script)
92
+ r, w = IO.pipe
93
+ w.write(test_script)
94
+ w.close
95
+
96
+ system!(env_vars, "/bin/bash -s", :in => r, :out => $stdout, :err => $stderr)
97
+ 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
84
167
  end
85
168
  end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module CrossRepo
3
- VERSION = "1.0.4"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -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.0.4
4
+ version: 1.1.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: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2021-02-05 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.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: []