manageiq-cross_repo 1.1.1 → 1.2.1

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: cae79b4ed33115478d43ed4afef93fc5af092ab1fd03d540709704556fe25718
4
- data.tar.gz: 8ba6a4011ac76bc19a9417e2c63342b1c44d145313336e10ae1107fc3cdfc336
3
+ metadata.gz: 8b41a33500bc19d1787fc628f2b36526425dafe94b8176376205b3d77e6b8c56
4
+ data.tar.gz: fcb915b5746293c0f0969cda70116337a5b27795ec94673fe123dfb3357460d4
5
5
  SHA512:
6
- metadata.gz: 0d1083beae51b21b888b569aafad5a267908c816c71665969251ab1fc7b3e240854fa29102184dcd4e2dc031c044b5403b8e08a6c0845c9d5ad7a804c93680c8
7
- data.tar.gz: 16cddb73598fc9c17684907e2f0ba272cded605c31764d50791fc43b2db72bd212000d6f1e3c568679d5b028321b15900e53b2d0f01994bfd0a2ec340bbd2161
6
+ metadata.gz: f99033869bee7e81ccf5a3fa68ad5c0cbe4d775e50372cccdb79474a92385c9ea258be6754015ef1ca3deb2c4db2dfcd400115e3b571db1dfb956d0f61a84f66
7
+ data.tar.gz: '082df5577e2c09309900e1782f621c05764b8de1d25b22b63a41eecfe4d71d040cc1290d5abe241d6093547419be14f09d762587dda8d3b6ac759ed6a43ef05e'
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .rspec_status
12
12
 
13
13
  Gemfile.lock
14
+ /repos/
data/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [1.2.1] - 2022-01-11
8
+ ### Fixed
9
+ - Fix unpacking the hash for ruby 3 support
10
+
11
+ ## [1.2.0] - 2021-12-15
12
+ ### Changed
13
+ - Add support for test repos using Github Actions
14
+
15
+ ### Fixed
16
+ - If the list of repos is empty default to the core repo
17
+
18
+ ## [1.1.3] - 2021-08-27
19
+ ### Changed
20
+ - Add retry to ensure_clone (#74)
21
+
22
+ ## [1.1.2] - 2021-05-13
23
+ ### Changed
24
+ - Fix newer activesupport pulling in newer tzinfo and causing automate engine specs to fail
25
+
26
+ ## [1.1.1] - 2021-02-22
27
+ ### Changed
28
+ - [#71] Pass BUNDLE_PATH env var to test script
29
+
30
+ ## [1.1.0] - 2021-02-05
31
+ ### Changed
32
+ - Fix a warning from Kernel#open
33
+ - Add a --script-cmd and SCRIPT_CMD option
34
+ - Parse .travis.yml and run before_*/install/script sections
35
+
36
+ ## [1.0.4] - 2020-04-14
37
+ ### Changed
38
+ - Run tools/ci/before_install.sh for all plugins
39
+
40
+ ## [1.0.3] - 2020-03-05
41
+ ### Changed
42
+ - Prefer testing using the merge commit if it exists rather than the PR head
43
+
44
+ ## [1.0.2] - 2020-02-04
45
+ ### Changed
46
+ - Fix an issue extracting tgz files smaller than 10Kb
47
+ - Fix an issue overriding gems whose repo name doesn't match
48
+
49
+ [Unreleased]: https://github.com/ManageIQ/more_core_extensions/compare/v1.2.1...HEAD
50
+ [1.2.1]: https://github.com/ManageIQ/more_core_extensions/compare/v1.2.0...v1.2.1
51
+ [1.2.0]: https://github.com/ManageIQ/more_core_extensions/compare/v1.1.3...v1.2.0
52
+ [1.1.3]: https://github.com/ManageIQ/more_core_extensions/compare/v1.1.2...v1.1.3
53
+ [1.1.2]: https://github.com/ManageIQ/more_core_extensions/compare/v1.1.1...v1.1.2
54
+ [1.1.1]: https://github.com/ManageIQ/more_core_extensions/compare/v1.1.0...v1.1.1
55
+ [1.1.0]: https://github.com/ManageIQ/more_core_extensions/compare/v1.0.4...v1.1.0
56
+ [1.0.4]: https://github.com/ManageIQ/more_core_extensions/compare/v1.0.3...v1.0.4
57
+ [1.0.3]: https://github.com/ManageIQ/more_core_extensions/compare/v1.0.2...v1.0.3
58
+ [1.0.2]: https://github.com/ManageIQ/more_core_extensions/compare/v1.0.1...v1.0.2
data/README.md CHANGED
@@ -16,8 +16,12 @@ 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
19
  (default: )
20
+ -e, --test-suite=<s> Optional, the name of a rake test suite to pass as an environment variable to the test being run.
21
+ This is commonly used by the CI config to conditionally perform different setup tasks
22
+ and also to run different test suites, e.g. spec:javascript.
23
+ -s, --script-cmd=<s> Optional, a command string for running the specs.
24
+ If present this will override the the script section of the test_repo's CI config
21
25
 
22
26
  -v, --version Print version and exit
23
27
  -h, --help Show this message
@@ -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 .travis.yml to conditionally perform different setup tasks
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 .travis.yml
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
- 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
@@ -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
 
@@ -41,7 +41,8 @@ module ManageIQ::CrossRepo
41
41
 
42
42
  def run_tests
43
43
  with_test_env do
44
- run_test_script(build_test_script)
44
+ test_script = script_source.new(script_cmd).build_test_script
45
+ run_test_script(test_script)
45
46
  end
46
47
  end
47
48
 
@@ -67,6 +68,10 @@ module ManageIQ::CrossRepo
67
68
  exit($?.exitstatus) unless $?.success?
68
69
  end
69
70
 
71
+ def script_source
72
+ Base.descendants.detect(&:available?)
73
+ end
74
+
70
75
  def generate_bundler_d
71
76
  bundler_d_path = core_repo.path.join("bundler.d")
72
77
  override_path = bundler_d_path.join("overrides.rb")
@@ -100,74 +105,5 @@ module ManageIQ::CrossRepo
100
105
 
101
106
  system!(env_vars, "/bin/bash -s", :in => r, :out => $stdout, :err => $stderr)
102
107
  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
172
108
  end
173
109
  end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module CrossRepo
3
- VERSION = "1.1.1"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -7,8 +7,8 @@ module ManageIQ
7
7
  module CrossRepo
8
8
  REPOS_DIR = Pathname.pwd.join("repos")
9
9
 
10
- def self.run(*args)
11
- Runner.new(*args).run
10
+ def self.run(**args)
11
+ Runner.new(**args).run
12
12
  end
13
13
  end
14
14
  end
@@ -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.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Authors
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-22 00:00:00.000000000 Z
11
+ date: 2022-01-11 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: '0'
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: '0'
82
+ version: 6.0.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ffi-libarchive
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +136,7 @@ files:
136
136
  - ".rubocop_cc.yml"
137
137
  - ".rubocop_local.yml"
138
138
  - ".travis.yml"
139
+ - CHANGELOG.md
139
140
  - Gemfile
140
141
  - LICENSE.txt
141
142
  - README.md
@@ -147,8 +148,12 @@ files:
147
148
  - lib/manageiq/cross_repo.rb
148
149
  - lib/manageiq/cross_repo/repository.rb
149
150
  - lib/manageiq/cross_repo/runner.rb
151
+ - lib/manageiq/cross_repo/runner/base.rb
152
+ - lib/manageiq/cross_repo/runner/github.rb
153
+ - lib/manageiq/cross_repo/runner/travis.rb
150
154
  - lib/manageiq/cross_repo/version.rb
151
155
  - manageiq-cross_repo.gemspec
156
+ - repos/.gitkeep
152
157
  homepage: https://github.com/ManageIQ/manageiq-cross_repo
153
158
  licenses:
154
159
  - MIT
@@ -170,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
175
  - !ruby/object:Gem::Version
171
176
  version: '0'
172
177
  requirements: []
173
- rubygems_version: 3.2.5
178
+ rubygems_version: 3.1.6
174
179
  signing_key:
175
180
  specification_version: 4
176
181
  summary: ManageIQ CrossRepo testing library