avm-tools 0.44.2 → 0.49.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/git/issue/complete.rb +1 -1
  3. data/lib/avm/git/issue/complete/_test.rb +43 -0
  4. data/lib/avm/git/issue/complete/_validations.rb +11 -15
  5. data/lib/avm/git/issue/complete/validation.rb +31 -0
  6. data/lib/avm/git/revision_test.rb +2 -2
  7. data/lib/avm/instances/configuration.rb +12 -0
  8. data/lib/avm/instances/configuration/_rubocop.rb +24 -0
  9. data/lib/avm/instances/configuration/_tests.rb +27 -0
  10. data/lib/avm/rails.rb +9 -0
  11. data/lib/avm/rails/runners.rb +11 -0
  12. data/lib/avm/rails/runners/bundle.rb +35 -0
  13. data/lib/avm/ruby.rb +0 -20
  14. data/lib/avm/ruby/rubocop/_configured.rb +4 -16
  15. data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +2 -2
  16. data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +3 -3
  17. data/lib/avm/tools/runner/eac_rails_base0/bundle.rb +14 -0
  18. data/lib/avm/tools/runner/eac_redmine_base0/bundle.rb +2 -24
  19. data/lib/avm/tools/runner/eac_redmine_base0/runner.rb +43 -0
  20. data/lib/avm/tools/runner/files/format.rb +1 -1
  21. data/lib/avm/tools/runner/git.rb +1 -1
  22. data/lib/avm/tools/runner/launcher.rb +12 -0
  23. data/lib/avm/tools/version.rb +1 -1
  24. data/lib/eac_launcher.rb +17 -0
  25. data/lib/eac_launcher/context.rb +81 -0
  26. data/lib/eac_launcher/context/instance_discovery.rb +54 -0
  27. data/lib/eac_launcher/context/instance_manager.rb +94 -0
  28. data/lib/eac_launcher/context/settings.rb +51 -0
  29. data/lib/eac_launcher/git.rb +7 -0
  30. data/lib/eac_launcher/git/base.rb +100 -0
  31. data/lib/eac_launcher/git/base/class_methods.rb +26 -0
  32. data/lib/eac_launcher/git/base/dirty_files.rb +30 -0
  33. data/lib/eac_launcher/git/base/remotes.rb +38 -0
  34. data/lib/eac_launcher/git/base/subrepo.rb +42 -0
  35. data/lib/eac_launcher/git/base/underlying.rb +59 -0
  36. data/lib/eac_launcher/git/error.rb +11 -0
  37. data/lib/eac_launcher/git/mirror_update.rb +36 -0
  38. data/lib/eac_launcher/git/publish_base.rb +118 -0
  39. data/lib/eac_launcher/git/remote.rb +53 -0
  40. data/lib/eac_launcher/git/sub_warp_base.rb +30 -0
  41. data/lib/eac_launcher/git/warp_base.rb +54 -0
  42. data/lib/eac_launcher/instances.rb +6 -0
  43. data/lib/eac_launcher/instances/base.rb +91 -0
  44. data/lib/eac_launcher/instances/base/cache.rb +41 -0
  45. data/lib/eac_launcher/instances/error.rb +8 -0
  46. data/lib/eac_launcher/instances/runner_helper.rb +42 -0
  47. data/lib/eac_launcher/instances/settings.rb +23 -0
  48. data/lib/eac_launcher/paths.rb +4 -0
  49. data/lib/eac_launcher/paths/logical.rb +80 -0
  50. data/lib/eac_launcher/paths/real.rb +42 -0
  51. data/lib/eac_launcher/project.rb +16 -0
  52. data/lib/eac_launcher/publish.rb +4 -0
  53. data/lib/eac_launcher/publish/base.rb +45 -0
  54. data/lib/eac_launcher/publish/check_result.rb +65 -0
  55. data/lib/eac_launcher/ruby.rb +3 -0
  56. data/lib/eac_launcher/ruby/gem.rb +4 -0
  57. data/lib/eac_launcher/ruby/gem/build.rb +123 -0
  58. data/lib/eac_launcher/ruby/gem/specification.rb +61 -0
  59. data/lib/eac_launcher/runner.rb +21 -0
  60. data/lib/eac_launcher/runner/instances.rb +41 -0
  61. data/lib/eac_launcher/runner/projects.rb +46 -0
  62. data/lib/eac_launcher/runner/publish.rb +59 -0
  63. data/lib/eac_launcher/stereotype.rb +52 -0
  64. data/lib/eac_launcher/stereotypes.rb +14 -0
  65. data/lib/eac_launcher/stereotypes/git.rb +21 -0
  66. data/lib/eac_launcher/stereotypes/git/publish.rb +13 -0
  67. data/lib/eac_launcher/stereotypes/git/warp.rb +25 -0
  68. data/lib/eac_launcher/stereotypes/git_subrepo.rb +30 -0
  69. data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +12 -0
  70. data/lib/eac_launcher/stereotypes/git_subrepo/warp.rb +85 -0
  71. data/lib/eac_launcher/stereotypes/git_subtree.rb +47 -0
  72. data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +10 -0
  73. data/lib/eac_launcher/stereotypes/git_subtree/warp.rb +27 -0
  74. data/lib/eac_launcher/stereotypes/rails.rb +21 -0
  75. data/lib/eac_launcher/stereotypes/redmine_plugin.rb +21 -0
  76. data/lib/eac_launcher/stereotypes/ruby_gem.rb +27 -0
  77. data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +127 -0
  78. data/lib/eac_launcher/vendor.rb +3 -0
  79. data/lib/eac_launcher/vendor/github.rb +18 -0
  80. data/lib/eac_launcher/version.rb +5 -0
  81. metadata +126 -46
  82. data/lib/avm/patches/eac_launcher_git_base.rb +0 -77
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c9d91dc20429e3c9c932f57e47152b19fb1e468f3e564c44f4f395f7d04b5d7
4
- data.tar.gz: 18bfbdc67f8f8a9c93bccff6798f4b444fc6c20e3a9a4318e1acae168c6cccd1
3
+ metadata.gz: c4de0474ea4576b01ebad7cc61770d10f4be52e95820681eed2918d0d9faaab9
4
+ data.tar.gz: 7f849db68edcbe9d6070a814698c69011a73e33940b086c96476509cbd85bff8
5
5
  SHA512:
6
- metadata.gz: ab35a0b3b98a2885cc1de50a117b5fa579429160aa1cae64d9edf4edc94fa819afad0bb470bcbd7b7f293ca3ff90bda4d56c37460455093dab45ac4879174532
7
- data.tar.gz: 6f7ec8185a22da62ec5b5ada88065ba74ca6a0971235322732aff502c94d5853be532dc188fae5bef70830de18cd20412af536ff82f3c3dd991d08a69f7a4559
6
+ metadata.gz: b35a21622b980f23e8a578277fac9204465543e431b3cd530f6d18d4d224bf811709ecbf61777a96fb0c84820491d0a72d7d020af7f07792ed579ceb5e84320e
7
+ data.tar.gz: 5360f604e835e82cb18cd8e97224c33d563df588b78a46a9f82ede674828caae31898d41459051f015dae44fdd43bda06b929adca4405f055053ff983774f13b
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/patches/eac_launcher_git_base'
3
+ require 'eac_launcher/git/base'
4
4
  require 'eac_ruby_utils/console/speaker'
5
5
  require 'eac_ruby_utils/options_consumer'
6
6
  require 'eac_ruby_utils/require_sub'
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/configuration'
4
+ require 'avm/result'
5
+ require 'eac_ruby_utils/fs/temp'
6
+
7
+ module Avm
8
+ module Git
9
+ module Issue
10
+ class Complete
11
+ def test_result
12
+ test_command = configuration.if_present(&:any_test_command)
13
+ return ::Avm::Result.success('unconfigured') unless test_command.present?
14
+
15
+ infom "Running test command \"#{test_command}\"..."
16
+ result = test_command.execute
17
+ test_result_log(result)
18
+ if result.fetch(:exit_code).zero?
19
+ ::Avm::Result.success('yes')
20
+ else
21
+ ::Avm::Result.error('no')
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def test_result_log(result)
28
+ stdout_file = ::EacRubyUtils::Fs::Temp.file
29
+ stderr_file = ::EacRubyUtils::Fs::Temp.file
30
+ stdout_file.write(result.fetch(:stdout))
31
+ stderr_file.write(result.fetch(:stderr))
32
+ infov ' * Exit code', result.fetch(:exit_code)
33
+ infov ' * STDOUT', stdout_file.to_path
34
+ infov ' * STDERR', stderr_file.to_path
35
+ end
36
+
37
+ def configuration_uncached
38
+ ::Avm::Instances::Configuration.find_by_path(@git)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/git/issue/complete/validation'
3
4
  require 'avm/result'
4
5
  require 'ostruct'
5
6
 
@@ -14,7 +15,8 @@ module Avm
14
15
  follow_master: 'Follow master?',
15
16
  commits: 'Commits?',
16
17
  bifurcations: 'Bifurcations?',
17
- dry_push: 'Dry push?'
18
+ dry_push: 'Dry push?',
19
+ test: 'Test ok?'
18
20
  }.with_indifferent_access.freeze
19
21
 
20
22
  def valid?
@@ -27,20 +29,6 @@ module Avm
27
29
  end
28
30
  end
29
31
 
30
- def validations
31
- VALIDATIONS.map do |key, label|
32
- ::OpenStruct.new(key: key, label: label, result: validation_result(key))
33
- end
34
- end
35
-
36
- def validation_result(key)
37
- if skip_validations.include?(key)
38
- ::Avm::Result.neutral('skipped')
39
- else
40
- send("#{key}_result")
41
- end
42
- end
43
-
44
32
  def validate_skip_validations
45
33
  skip_validations.each do |validation|
46
34
  next if VALIDATIONS.keys.include?(validation)
@@ -48,6 +36,14 @@ module Avm
48
36
  raise "\"#{validation}\" is not a registered validation"
49
37
  end
50
38
  end
39
+
40
+ private
41
+
42
+ def validations_uncached
43
+ VALIDATIONS.map do |key, label|
44
+ ::Avm::Git::Issue::Complete::Validation.new(self, key, label)
45
+ end
46
+ end
51
47
  end
52
48
  end
53
49
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/result'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ module Issue
9
+ class Complete
10
+ class Validation
11
+ enable_simple_cache
12
+ common_constructor :parent, :key, :label
13
+
14
+ def skip?
15
+ parent.skip_validations.include?(key)
16
+ end
17
+
18
+ private
19
+
20
+ def result_uncached
21
+ if skip?
22
+ ::Avm::Result.neutral('skipped')
23
+ else
24
+ parent.send("#{key}_result")
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/fs_cache'
4
- require 'avm/ruby'
5
4
  require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/ruby'
6
6
 
7
7
  module Avm
8
8
  module Git
@@ -57,7 +57,7 @@ module Avm
57
57
  def run_test
58
58
  infom "Running test command \"#{::Shellwords.join(test_command_args)}\"" \
59
59
  " on \"#{git_absolute_path}\"..."
60
- result = ::Avm::Ruby.on_clean_environment { test_command.execute }
60
+ result = ::EacRubyUtils::Ruby.on_clean_environment { test_command.execute }
61
61
  infom 'Test done'
62
62
  write_result_cache(result)
63
63
  end
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/configs'
4
+ require 'eac_ruby_utils/core_ext'
4
5
  require 'yaml'
5
6
 
6
7
  module Avm
7
8
  module Instances
8
9
  class Configuration < ::EacRubyUtils::Configs
10
+ require_sub __FILE__
11
+
9
12
  FILENAMES = %w[.avm.yml .avm.yaml].freeze
10
13
 
11
14
  class << self
@@ -30,6 +33,15 @@ module Avm
30
33
  def initialize(path)
31
34
  super(nil, storage_path: path)
32
35
  end
36
+
37
+ # Utility to read a configuration as a [EacRubyUtils::Envs::Command].
38
+ # @return [EacRubyUtils::Envs::Command]
39
+ def read_command(key)
40
+ read_entry(key).if_present do |v|
41
+ args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
42
+ ::EacRubyUtils::Envs.local.command(args).chdir(::File.dirname(storage_path))
43
+ end
44
+ end
33
45
  end
34
46
  end
35
47
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Instances
5
+ class Configuration < ::EacRubyUtils::Configs
6
+ RUBOCOP_COMMAND_KEY = 'ruby.rubocop.command'
7
+ RUBOCOP_GEMFILE_KEY = 'ruby.rubocop.gemfile'
8
+
9
+ def rubocop_command
10
+ read_command(RUBOCOP_COMMAND_KEY)
11
+ end
12
+
13
+ def rubocop_gemfile
14
+ gemfile_path = read_entry(RUBOCOP_GEMFILE_KEY)
15
+ return nil unless gemfile_path.present?
16
+
17
+ gemfile_path = gemfile_path.to_pathname.expand_path(storage_path.parent)
18
+ return gemfile_path if gemfile_path.file?
19
+
20
+ raise "Gemfile path \"#{gemfile_path}\" does not exist or is not a file"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/gem'
4
+
5
+ module Avm
6
+ module Instances
7
+ class Configuration < ::EacRubyUtils::Configs
8
+ BUNDLE_TEST_COMMAND_KEY = 'test.bundle_command'
9
+ TEST_COMMAND_KEY = 'test.command'
10
+
11
+ def any_test_command
12
+ bundle_test_command || test_command
13
+ end
14
+
15
+ def test_command
16
+ read_command(TEST_COMMAND_KEY)
17
+ end
18
+
19
+ def bundle_test_command
20
+ read_entry(BUNDLE_TEST_COMMAND_KEY).if_present do |v|
21
+ args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
22
+ ::EacRubyGemsUtils::Gem.new(::File.dirname(storage_path)).bundle(*args).chdir_root
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Rails
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Rails
7
+ module Runners
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'shellwords'
6
+
7
+ module Avm
8
+ module Rails
9
+ module Runners
10
+ class Bundle < ::EacRubyUtils::Console::DocoptRunner
11
+ enable_console_speaker
12
+
13
+ DOC = <<~DOCOPT
14
+ Runs "bundle ...".
15
+
16
+ Usage:
17
+ __PROGRAM__ [<bundle-args>...]
18
+ __PROGRAM__ -h | --help
19
+
20
+ Options:
21
+ -h --help Show this screen.
22
+ DOCOPT
23
+
24
+ def run
25
+ infov 'Bundle arguments', ::Shellwords.join(bundle_args)
26
+ context(:instance).bundle(*bundle_args).system!
27
+ end
28
+
29
+ def bundle_args
30
+ options.fetch('<bundle-args>').reject { |arg| arg == '--' }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -5,25 +5,5 @@ require 'eac_ruby_utils/core_ext'
5
5
  module Avm
6
6
  module Ruby
7
7
  require_sub __FILE__
8
-
9
- class << self
10
- def on_clean_environment
11
- on_clean_envvars('BUNDLE', 'RUBY') { yield }
12
- end
13
-
14
- private
15
-
16
- def on_clean_envvars(*start_with_vars)
17
- old_values = envvars_starting_with(start_with_vars)
18
- old_values.keys.each { |k| ENV.delete(k) } # rubocop:disable Style/HashEachMethods
19
- yield
20
- ensure
21
- old_values&.each { |k, v| ENV[k] = v }
22
- end
23
-
24
- def envvars_starting_with(start_with_vars)
25
- ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
26
- end
27
- end
28
8
  end
29
9
  end
@@ -10,25 +10,13 @@ module Avm
10
10
  end
11
11
 
12
12
  def configured_rubocop_command_by_command
13
- rubocop_command = configuration.if_present { |v| v.read_entry('ruby.rubocop.command') }
14
- return nil unless rubocop_command.present?
15
-
16
- args = if rubocop_command.is_a?(::Enumerable)
17
- rubocop_command.map(&:to_s)
18
- else
19
- ::Shellwords.split(rubocop_command)
20
- end
21
- cmd(args).chdir(::File.dirname(configuration.storage_path))
13
+ configuration.if_present(&:rubocop_command)
22
14
  end
23
15
 
24
16
  def configured_rubocop_command_by_gemfile
25
- gemfile_path = configuration.if_present { |v| v.read_entry('ruby.rubocop.gemfile') }
26
- return nil unless gemfile_path.present?
27
-
28
- gemfile_path = ::Pathname.new(gemfile_path).expand_path(configuration.storage_path.parent)
29
- raise "Gemfile path \"#{gemfile_path}\" does not exist" unless gemfile_path.exist?
30
-
31
- rubocop_command_by_gemfile_path(gemfile_path.parent)
17
+ configuration.if_present(&:rubocop_gemfile).if_present do |v|
18
+ rubocop_command_by_gemfile_path(v.parent)
19
+ end
32
20
  end
33
21
 
34
22
  private
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/ruby'
4
3
  require 'avm/stereotypes/eac_webapp_base0/deploy'
4
+ require 'eac_ruby_utils/ruby'
5
5
 
6
6
  module Avm
7
7
  module Stereotypes
@@ -11,7 +11,7 @@ module Avm
11
11
 
12
12
  def run_installer
13
13
  infom 'Running installer'
14
- ::Avm::Ruby.on_clean_environment do
14
+ ::EacRubyUtils::Ruby.on_clean_environment do
15
15
  installer_command.system!
16
16
  end
17
17
  end
@@ -42,9 +42,9 @@ module Avm
42
42
  private
43
43
 
44
44
  def files_units
45
- self.class.const_get('FILES_UNITS').map do |data_key, fs_path_subpath|
46
- [data_key, ::Avm::Data::Instance::FilesUnit.new(self, fs_path_subpath)]
47
- end.to_h
45
+ self.class.const_get('FILES_UNITS').transform_values do |fs_path_subpath|
46
+ ::Avm::Data::Instance::FilesUnit.new(self, fs_path_subpath)
47
+ end
48
48
  end
49
49
  end
50
50
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/rails/runners/bundle'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class EacRailsBase0 < ::EacRubyUtils::Console::DocoptRunner
9
+ class Bundle < ::Avm::Rails::Runners::Bundle
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,34 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/stereotypes/eac_redmine_base0/deploy'
4
- require 'avm/stereotypes/eac_webapp_base0/runner/deploy'
3
+ require 'avm/rails/runners/bundle'
5
4
 
6
5
  module Avm
7
6
  module Tools
8
7
  class Runner < ::EacRubyUtils::Console::DocoptRunner
9
8
  class EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
10
- class Bundle < ::EacRubyUtils::Console::DocoptRunner
11
- enable_console_speaker
12
-
13
- DOC = <<~DOCOPT
14
- Runs "bundle ...".
15
-
16
- Usage:
17
- __PROGRAM__ [<bundle-args>...]
18
- __PROGRAM__ -h | --help
19
-
20
- Options:
21
- -h --help Show this screen.
22
- DOCOPT
23
-
24
- def run
25
- infov 'Bundle arguments', ::Shellwords.join(bundle_args)
26
- context(:instance).bundle(*bundle_args).system!
27
- end
28
-
29
- def bundle_args
30
- options.fetch('<bundle-args>').reject { |arg| arg == '--' }
31
- end
9
+ class Bundle < ::Avm::Rails::Runners::Bundle
32
10
  end
33
11
  end
34
12
  end