manageiq-cross_repo 1.1.3 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 756d32fbaca87b4fcd09bcb95dca76ad5e4560561586431dd64c7ea050d56573
4
- data.tar.gz: 9ddbaeb1080a02757d20113cf93f6161086e24d91cc03a8793893900b9933969
3
+ metadata.gz: ab950b0d16326800267d3cb3444863d955faf40b445bb53f9c825260b6140e97
4
+ data.tar.gz: 5bae7ad852de74a91a342ca79579609a077971fffb413f3e103dff6d702827bc
5
5
  SHA512:
6
- metadata.gz: f23fd2b6b57843d2974b06058786d1da8321d8eb83599fe4fe4935006e822ab036d5615cebc407db51c68c25f8d24bb3d78a85e37eb745565b68e66b55b35082
7
- data.tar.gz: bd339e043a899aef5fafd10d2a8f85a59fc0d813b19d17c3b738ded4a6809b3f246e548eb2bdba0a11a5298fba3933296ffd4b1583a9fce2808ac62b503c613f
6
+ metadata.gz: 4dbde8d0c81851702335545def9156efa18573cc91852b05d01aa99921d6cab3517fc9d0bf13a10aa87920826bda255e334708fa74fcb873cb4065dcf712b887
7
+ data.tar.gz: a607ee34daf7cb9b41263f538a3ba23c4e0ed78c243b939509e8904db020a041ae876fe5991b41b1b0fd476e773f2edfa6b2c8b0156b25b411ba6f23203c97e1
@@ -0,0 +1,22 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ ci:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby-version:
11
+ - '2.5'
12
+ - '2.6'
13
+ - '2.7'
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true
21
+ - name: Run tests
22
+ run: bundle exec rake
@@ -0,0 +1,52 @@
1
+ name: ManageIQ Cross Repo Workflow
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ test-repos:
7
+ required: true
8
+ type: string
9
+ repos:
10
+ required: true
11
+ type: string
12
+ test-suite:
13
+ required: false
14
+ type: string
15
+
16
+ jobs:
17
+ ci:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ test-repo: ${{ fromJson(inputs.test-repos) }}
23
+ services:
24
+ postgres:
25
+ image: manageiq/postgresql:10
26
+ env:
27
+ POSTGRESQL_USER: root
28
+ POSTGRESQL_PASSWORD: smartvm
29
+ POSTGRESQL_DATABASE: vmdb_test
30
+ options: --health-cmd pg_isready --health-interval 2s --health-timeout 5s --health-retries 5
31
+ ports:
32
+ - 5432:5432
33
+ env:
34
+ TEST_SUITE: ${{ inputs.test-suite }}
35
+ REPOS: ${{ inputs.repos }}
36
+ TEST_REPO: ${{ matrix.test-repo }}
37
+ PGHOST: localhost
38
+ PGPASSWORD: smartvm
39
+ steps:
40
+ - uses: actions/checkout@v2
41
+ - name: Set up Ruby
42
+ uses: ruby/setup-ruby@v1
43
+ with:
44
+ ruby-version: 2.7
45
+ bundler-cache: true
46
+ - name: Set up Node
47
+ uses: actions/setup-node@v2
48
+ with:
49
+ node-version: 12
50
+ registry-url: https://npm.manageiq.org/
51
+ - name: Run tests
52
+ run: bundle exec manageiq-cross_repo
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .rspec_status
12
12
 
13
13
  Gemfile.lock
14
+ /repos/
data/.whitesource ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "settingsInheritedFrom": "ManageIQ/whitesource-config@master"
3
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,70 @@
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
+ ## [2.1.0] - 2022-02-21
8
+ ### Changed
9
+ - Update nodejs version to v16 (#79)
10
+
11
+ ## [2.0.0] - 2022-02-08
12
+ ### Changed
13
+ - Announce the cross repo run information (#81)
14
+ - Use Github Actions for CI (#82)
15
+ - Replace Travis with Github Actions (#83)
16
+
17
+ ## [1.2.1] - 2022-01-11
18
+ ### Fixed
19
+ - Fix unpacking the hash for ruby 3 support
20
+
21
+ ## [1.2.0] - 2021-12-15
22
+ ### Changed
23
+ - Add support for test repos using Github Actions
24
+
25
+ ### Fixed
26
+ - If the list of repos is empty default to the core repo
27
+
28
+ ## [1.1.3] - 2021-08-27
29
+ ### Changed
30
+ - Add retry to ensure_clone (#74)
31
+
32
+ ## [1.1.2] - 2021-05-13
33
+ ### Changed
34
+ - Fix newer activesupport pulling in newer tzinfo and causing automate engine specs to fail
35
+
36
+ ## [1.1.1] - 2021-02-22
37
+ ### Changed
38
+ - [#71] Pass BUNDLE_PATH env var to test script
39
+
40
+ ## [1.1.0] - 2021-02-05
41
+ ### Changed
42
+ - Fix a warning from Kernel#open
43
+ - Add a --script-cmd and SCRIPT_CMD option
44
+ - Parse .travis.yml and run before_*/install/script sections
45
+
46
+ ## [1.0.4] - 2020-04-14
47
+ ### Changed
48
+ - Run tools/ci/before_install.sh for all plugins
49
+
50
+ ## [1.0.3] - 2020-03-05
51
+ ### Changed
52
+ - Prefer testing using the merge commit if it exists rather than the PR head
53
+
54
+ ## [1.0.2] - 2020-02-04
55
+ ### Changed
56
+ - Fix an issue extracting tgz files smaller than 10Kb
57
+ - Fix an issue overriding gems whose repo name doesn't match
58
+
59
+ [Unreleased]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v2.1.0...HEAD
60
+ [2.1.0]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v2.1.0..v2.0.0
61
+ [2.0.0]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v2.0.0...v1.2.1
62
+ [1.2.1]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v1.2.0...v1.2.1
63
+ [1.2.0]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v1.1.3...v1.2.0
64
+ [1.1.3]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v1.1.2...v1.1.3
65
+ [1.1.2]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v1.1.1...v1.1.2
66
+ [1.1.1]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v1.1.0...v1.1.1
67
+ [1.1.0]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v1.0.4...v1.1.0
68
+ [1.0.4]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v1.0.3...v1.0.4
69
+ [1.0.3]: https://github.com/ManageIQ/manageiq-cross_repo/compare/v1.0.2...v1.0.3
70
+ [1.0.2]: https://github.com/ManageIQ/manageiq-cross_repo/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
 
@@ -0,0 +1,99 @@
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, :config
8
+
9
+ def initialize(script_cmd = nil)
10
+ @script_cmd = script_cmd.presence
11
+ @config = load_config!
12
+ end
13
+
14
+ def build_test_script
15
+ load_config!
16
+ build_script
17
+ end
18
+
19
+ private
20
+
21
+ def environment_setup_commands
22
+ commands = []
23
+
24
+ if config["node_js"]
25
+ commands << "source ~/.nvm/nvm.sh"
26
+ commands += Array(config["node_js"]).map do |node_version|
27
+ "nvm install #{node_version}"
28
+ end
29
+ end
30
+
31
+ commands.any? ? build_section("environment", *commands) : commands
32
+ end
33
+
34
+ def section_commands
35
+ sections = %w[before_install install before_script script]
36
+ sections.flat_map do |section|
37
+ commands = build_section_commands(section)
38
+ build_section(section, *commands) if commands.present?
39
+ end.compact
40
+ end
41
+
42
+ def build_commands
43
+ environment_setup_commands + section_commands
44
+ end
45
+
46
+ def build_section_commands(section)
47
+ # Travis sections can have a single command or an array of commands
48
+ Array(config[section]).map { |cmd| "#{cmd} || exit $?" }
49
+ end
50
+
51
+ def build_section(section, *commands)
52
+ [
53
+ "echo '::group::#{section}'",
54
+ *commands,
55
+ "echo '::endgroup::'"
56
+ ]
57
+ end
58
+
59
+ def build_script
60
+ <<~BASH_SCRIPT
61
+ #!/bin/bash
62
+
63
+ #{build_commands.join("\n")}
64
+ BASH_SCRIPT
65
+ end
66
+
67
+ def load_config!
68
+ ci_config.tap do |config|
69
+ # Set missing sections to the proper defaults
70
+ config["install"] ||= defaults[config["language"]]["install"]
71
+
72
+ config["script"] = script_cmd if script_cmd.present?
73
+ config["script"] ||= defaults[config["language"]]["script"]
74
+ end
75
+ end
76
+
77
+ def ci_config
78
+ raise NotImplementedError, "must be implemented in a subclass"
79
+ end
80
+
81
+ def defaults
82
+ @defaults ||= {
83
+ "node_js" => {
84
+ "language" => "node_js",
85
+ "node_js" => ["16"],
86
+ "install" => "npm install",
87
+ "script" => "npm test"
88
+ },
89
+ "ruby" => {
90
+ "language" => "ruby",
91
+ "rvm" => ["2.7"],
92
+ "install" => "bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}",
93
+ "script" => "bundle exec rake"
94
+ }
95
+ }.freeze
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,34 @@
1
+ require_relative "./base"
2
+ require "yaml"
3
+ require "active_support/core_ext/enumerable"
4
+
5
+ module ManageIQ::CrossRepo
6
+ class Runner
7
+ class Github < Base
8
+ CONFIG_FILE = ".github/workflows/ci.yaml".freeze
9
+
10
+ def self.available?
11
+ File.exist?(CONFIG_FILE)
12
+ end
13
+
14
+ private
15
+
16
+ def ci_config
17
+ github_config = YAML.load_file(CONFIG_FILE)
18
+
19
+ steps = github_config["jobs"]["ci"]["steps"]
20
+ steps_by_name = steps.index_by { |step| step["name"] }
21
+
22
+ language = steps.any? { |s| s["uses"] == "ruby/setup-ruby@v1" } ? "ruby" : "node_js"
23
+
24
+ result = {"language" => language}
25
+
26
+ result["before_install"] = steps_by_name["Set up system"]["run"] if steps_by_name["Set up system"]
27
+ result["before_script"] = steps_by_name["Prepare tests"]["run"] if steps_by_name["Prepare tests"]
28
+ result["script"] = steps_by_name["Run tests"]["run"] if steps_by_name["Run tests"]
29
+
30
+ result
31
+ end
32
+ end
33
+ end
34
+ 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 ci_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
 
@@ -26,6 +26,7 @@ module ManageIQ::CrossRepo
26
26
  end
27
27
 
28
28
  def run
29
+ announce_run
29
30
  test_repo.ensure_clone
30
31
  core_repo.ensure_clone unless test_repo.core?
31
32
  prepare_gem_repos
@@ -34,6 +35,15 @@ module ManageIQ::CrossRepo
34
35
 
35
36
  private
36
37
 
38
+ def announce_run
39
+ puts "\e[36m Starting cross repo for:\e[0m"
40
+ puts " \e[36mtest repo: #{test_repo.identifier}\e[0m"
41
+ puts " \e[36mcore repo: #{core_repo.identifier}\e[0m"
42
+ gem_repos.each do |gr|
43
+ puts " \e[36mgem repo: #{gr.identifier}\e[0m"
44
+ end
45
+ end
46
+
37
47
  def bundle_path
38
48
  app_path = Pathname.new(ENV["TRAVIS_BUILD_DIR"].presence || Pathname.pwd)
39
49
  app_path.join("vendor", "bundle")
@@ -41,12 +51,13 @@ module ManageIQ::CrossRepo
41
51
 
42
52
  def run_tests
43
53
  with_test_env do
44
- run_test_script(build_test_script)
54
+ test_script = script_source.new(script_cmd).build_test_script
55
+ run_test_script(test_script)
45
56
  end
46
57
  end
47
58
 
48
59
  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}
60
+ {"MANAGEIQ_REPO" => core_repo.path.to_s, "BUNDLE_PATH" => bundle_path.to_s, "TEST_SUITE" => test_suite}
50
61
  end
51
62
 
52
63
  def with_test_env
@@ -67,6 +78,10 @@ module ManageIQ::CrossRepo
67
78
  exit($?.exitstatus) unless $?.success?
68
79
  end
69
80
 
81
+ def script_source
82
+ Base.descendants.detect(&:available?)
83
+ end
84
+
70
85
  def generate_bundler_d
71
86
  bundler_d_path = core_repo.path.join("bundler.d")
72
87
  override_path = bundler_d_path.join("overrides.rb")
@@ -100,74 +115,5 @@ module ManageIQ::CrossRepo
100
115
 
101
116
  system!(env_vars, "/bin/bash -s", :in => r, :out => $stdout, :err => $stderr)
102
117
  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
118
  end
173
119
  end
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module CrossRepo
3
- VERSION = "1.1.3"
3
+ VERSION = "2.1.0"
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
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.3
4
+ version: 2.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: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: manageiq-style
@@ -123,19 +123,22 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: ManageIQ CrossRepo testing library
126
- email:
126
+ email:
127
127
  executables:
128
128
  - manageiq-cross_repo
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".codeclimate.yml"
133
+ - ".github/workflows/ci.yaml"
134
+ - ".github/workflows/manageiq_cross_repo.yaml"
133
135
  - ".gitignore"
134
136
  - ".rspec"
135
137
  - ".rubocop.yml"
136
138
  - ".rubocop_cc.yml"
137
139
  - ".rubocop_local.yml"
138
- - ".travis.yml"
140
+ - ".whitesource"
141
+ - CHANGELOG.md
139
142
  - Gemfile
140
143
  - LICENSE.txt
141
144
  - README.md
@@ -147,15 +150,19 @@ files:
147
150
  - lib/manageiq/cross_repo.rb
148
151
  - lib/manageiq/cross_repo/repository.rb
149
152
  - lib/manageiq/cross_repo/runner.rb
153
+ - lib/manageiq/cross_repo/runner/base.rb
154
+ - lib/manageiq/cross_repo/runner/github.rb
155
+ - lib/manageiq/cross_repo/runner/travis.rb
150
156
  - lib/manageiq/cross_repo/version.rb
151
157
  - manageiq-cross_repo.gemspec
158
+ - repos/.gitkeep
152
159
  homepage: https://github.com/ManageIQ/manageiq-cross_repo
153
160
  licenses:
154
161
  - MIT
155
162
  metadata:
156
163
  homepage_uri: https://github.com/ManageIQ/manageiq-cross_repo
157
164
  source_code_uri: https://github.com/ManageIQ/manageiq-cross_repo
158
- post_install_message:
165
+ post_install_message:
159
166
  rdoc_options: []
160
167
  require_paths:
161
168
  - lib
@@ -170,8 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
177
  - !ruby/object:Gem::Version
171
178
  version: '0'
172
179
  requirements: []
173
- rubygems_version: 3.2.5
174
- signing_key:
180
+ rubygems_version: 3.3.5
181
+ signing_key:
175
182
  specification_version: 4
176
183
  summary: ManageIQ CrossRepo testing library
177
184
  test_files: []
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5.5
4
- cache: bundler
5
- addons:
6
- postgresql: '10'
7
- apt:
8
- packages:
9
- - libarchive-dev
10
- matrix:
11
- fast_finish: true