manageiq-cross_repo 1.0.2 → 1.1.2

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: 3ff6896410d55e14769981d4ee061c8557c409743968d191944476ea861c35d6
4
- data.tar.gz: 78a605b9ea4cfe657219b957cd3ef9444c026209aa4e62ce5d5598664a5760f5
3
+ metadata.gz: 30b6fb35d9af6ba3cf9708da6985849f8b06d6714e5562e78d0936e0f72ab518
4
+ data.tar.gz: eb2b41e92ee88223f39789b25bc3e4243bd887236a9e5656ad4c69473df1ffa4
5
5
  SHA512:
6
- metadata.gz: 98dcd86001183007093fef2b42335af5975672dc8a3bda97eb16bb6d8daa89f9d6b9e0e610bb0795098a202c3ffbb3e00d4fb6420932b26065413322820dedd6
7
- data.tar.gz: 6745a6f57b19d966f43b5684cc23a03c631f771f7610c8fe41da018b0acb1b65dc34f43e71dbadc483806b89256684e074b54beb968f006ff3fb959e4003b591
6
+ metadata.gz: 3ee7409e50673592f3816086cef4c22cad1e60418e572032a048414f3736844c4d6f30d1bfaf3f4a63434ba980d7437e62c64cfc6b25efb1b80b946a0fd125b6
7
+ data.tar.gz: 40ae9c79ca03f0329b24cc793a438f888aff92556b45c9d45dc448a8c777843f42d805e35ebe87fd60fadbc0b78fde96c98d808d2077a6bfaacb1f2401a22a3d
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|
@@ -165,7 +165,7 @@ module ManageIQ::CrossRepo
165
165
  end
166
166
 
167
167
  def git_pr_to_sha(url, pr)
168
- 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")
169
169
  end
170
170
  end
171
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, 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,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? ? run_core : run_plugin
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 run_core
33
- prepare_gem_repos
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
- system!({"TRAVIS_BUILD_DIR" => test_repo.path.to_s}, "bash", "tools/ci/before_install.sh") if ENV["CI"]
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 run_plugin
43
- core_repo.ensure_clone
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,13 +62,17 @@ 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
- exit($?.exitstatus) unless system(*args)
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
@@ -78,6 +81,7 @@ module ManageIQ::CrossRepo
78
81
  gem_name = gem.path.glob("*.gemspec")&.first&.basename(".gemspec") || gem.repo
79
82
  "ensure_gem \"#{gem_name}\", :path => \"#{gem.path}\""
80
83
  end.join("\n")
84
+
81
85
  FileUtils.mkdir_p(bundler_d_path)
82
86
 
83
87
  File.write(override_path, content)
@@ -88,5 +92,82 @@ module ManageIQ::CrossRepo
88
92
  gem_repos.each { |gem_repo| gem_repo.ensure_clone }
89
93
  generate_bundler_d
90
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
91
172
  end
92
173
  end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module CrossRepo
3
- VERSION = "1.0.2"
3
+ VERSION = "1.1.2"
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.2
4
+ version: 1.1.2
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-02-04 00:00:00.000000000 Z
11
+ date: 2021-05-13 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: []