avm-tools 0.45.0 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) 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 +16 -2
  4. data/lib/avm/git/issue/complete/_validations.rb +9 -14
  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/_tests.rb +14 -0
  8. data/lib/avm/rails.rb +9 -0
  9. data/lib/avm/rails/runners.rb +11 -0
  10. data/lib/avm/rails/runners/bundle.rb +35 -0
  11. data/lib/avm/rails/runners/runner.rb +48 -0
  12. data/lib/avm/ruby.rb +0 -20
  13. data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +2 -2
  14. data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +3 -3
  15. data/lib/avm/tools/runner/eac_rails_base0/bundle.rb +14 -0
  16. data/lib/avm/tools/runner/eac_rails_base0/runner.rb +14 -0
  17. data/lib/avm/tools/runner/eac_redmine_base0/bundle.rb +2 -24
  18. data/lib/avm/tools/runner/eac_redmine_base0/runner.rb +14 -0
  19. data/lib/avm/tools/runner/files/format.rb +1 -1
  20. data/lib/avm/tools/runner/git.rb +1 -1
  21. data/lib/avm/tools/runner/launcher.rb +12 -0
  22. data/lib/avm/tools/version.rb +1 -1
  23. data/lib/eac_launcher.rb +17 -0
  24. data/lib/eac_launcher/context.rb +81 -0
  25. data/lib/eac_launcher/context/instance_discovery.rb +54 -0
  26. data/lib/eac_launcher/context/instance_manager.rb +94 -0
  27. data/lib/eac_launcher/context/settings.rb +51 -0
  28. data/lib/eac_launcher/git.rb +7 -0
  29. data/lib/eac_launcher/git/base.rb +100 -0
  30. data/lib/eac_launcher/git/base/class_methods.rb +26 -0
  31. data/lib/eac_launcher/git/base/dirty_files.rb +30 -0
  32. data/lib/eac_launcher/git/base/remotes.rb +38 -0
  33. data/lib/eac_launcher/git/base/subrepo.rb +42 -0
  34. data/lib/eac_launcher/git/base/underlying.rb +59 -0
  35. data/lib/eac_launcher/git/error.rb +11 -0
  36. data/lib/eac_launcher/git/mirror_update.rb +36 -0
  37. data/lib/eac_launcher/git/publish_base.rb +118 -0
  38. data/lib/eac_launcher/git/remote.rb +53 -0
  39. data/lib/eac_launcher/git/sub_warp_base.rb +30 -0
  40. data/lib/eac_launcher/git/warp_base.rb +54 -0
  41. data/lib/eac_launcher/instances.rb +6 -0
  42. data/lib/eac_launcher/instances/base.rb +91 -0
  43. data/lib/eac_launcher/instances/base/cache.rb +41 -0
  44. data/lib/eac_launcher/instances/error.rb +8 -0
  45. data/lib/eac_launcher/instances/runner_helper.rb +42 -0
  46. data/lib/eac_launcher/instances/settings.rb +23 -0
  47. data/lib/eac_launcher/paths.rb +4 -0
  48. data/lib/eac_launcher/paths/logical.rb +80 -0
  49. data/lib/eac_launcher/paths/real.rb +42 -0
  50. data/lib/eac_launcher/project.rb +16 -0
  51. data/lib/eac_launcher/publish.rb +4 -0
  52. data/lib/eac_launcher/publish/base.rb +45 -0
  53. data/lib/eac_launcher/publish/check_result.rb +65 -0
  54. data/lib/eac_launcher/ruby.rb +3 -0
  55. data/lib/eac_launcher/ruby/gem.rb +4 -0
  56. data/lib/eac_launcher/ruby/gem/build.rb +123 -0
  57. data/lib/eac_launcher/ruby/gem/specification.rb +61 -0
  58. data/lib/eac_launcher/runner.rb +21 -0
  59. data/lib/eac_launcher/runner/instances.rb +41 -0
  60. data/lib/eac_launcher/runner/projects.rb +46 -0
  61. data/lib/eac_launcher/runner/publish.rb +59 -0
  62. data/lib/eac_launcher/stereotype.rb +52 -0
  63. data/lib/eac_launcher/stereotypes.rb +14 -0
  64. data/lib/eac_launcher/stereotypes/git.rb +21 -0
  65. data/lib/eac_launcher/stereotypes/git/publish.rb +13 -0
  66. data/lib/eac_launcher/stereotypes/git/warp.rb +25 -0
  67. data/lib/eac_launcher/stereotypes/git_subrepo.rb +30 -0
  68. data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +12 -0
  69. data/lib/eac_launcher/stereotypes/git_subrepo/warp.rb +85 -0
  70. data/lib/eac_launcher/stereotypes/git_subtree.rb +47 -0
  71. data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +10 -0
  72. data/lib/eac_launcher/stereotypes/git_subtree/warp.rb +27 -0
  73. data/lib/eac_launcher/stereotypes/rails.rb +21 -0
  74. data/lib/eac_launcher/stereotypes/redmine_plugin.rb +21 -0
  75. data/lib/eac_launcher/stereotypes/ruby_gem.rb +27 -0
  76. data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +127 -0
  77. data/lib/eac_launcher/vendor.rb +3 -0
  78. data/lib/eac_launcher/vendor/github.rb +18 -0
  79. data/lib/eac_launcher/version.rb +5 -0
  80. metadata +122 -9
  81. 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: 7e0e6277dfb4d7fb9d026f49aa93d0bc395c1c4b526911a5229f062e95a33a60
4
- data.tar.gz: 7c3628d294e04080fa3b9adef605bba3c4c75260bcaf398b1a46a8b1cca8a33d
3
+ metadata.gz: 1137821182b34e4446f1f175eac9e65759aa94850eaa2be6452e438794c3d7e2
4
+ data.tar.gz: 646ea6c80d87e421e6959d316c746ef24e778650346dfbc7cd141c556fec77ad
5
5
  SHA512:
6
- metadata.gz: 690afb20bf63115d36da0090cb070ff112fd187ba6dc428cb25fd6d31b0ab9588f90abcf09faf43d1a33f1aacc0bb5fb549ef63ba14ab7a4f2ff31a6bb32cbff
7
- data.tar.gz: 28ae352ef538db3bb01a0dc8fbdc593ca61fd34ef24fdfe97e00db3ce3c27af6d953e3c9459fbb51b7dce2106c5d801b717c9d5e2adf0ee3a6ab4fb984a519e8
6
+ metadata.gz: 01a3a8f6965075d701380b9e97338b3d50497cf2ccc3e0e5bfe3f219c709db6b0c0bb3a6af6c51ea19557046c2170134fd70ea830b0faaddc03dac1f958a9c99
7
+ data.tar.gz: ea67bf1ddfdae82da134cb4883958ed9c1efc17d6b25e65d2acc40d5c16fadeacc67b1f93817c113b4165360caf16a21fee1ef38e788e2e76b8e593625a7d7ed
@@ -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'
@@ -2,16 +2,20 @@
2
2
 
3
3
  require 'avm/instances/configuration'
4
4
  require 'avm/result'
5
+ require 'eac_ruby_utils/fs/temp'
5
6
 
6
7
  module Avm
7
8
  module Git
8
9
  module Issue
9
10
  class Complete
10
11
  def test_result
11
- test_command = configuration.if_present(&:test_command)
12
+ test_command = configuration.if_present(&:any_test_command)
12
13
  return ::Avm::Result.success('unconfigured') unless test_command.present?
13
14
 
14
- if test_command.execute[:exit_code].zero?
15
+ infom "Running test command \"#{test_command}\"..."
16
+ result = test_command.execute
17
+ test_result_log(result)
18
+ if result.fetch(:exit_code).zero?
15
19
  ::Avm::Result.success('yes')
16
20
  else
17
21
  ::Avm::Result.error('no')
@@ -20,6 +24,16 @@ module Avm
20
24
 
21
25
  private
22
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
+
23
37
  def configuration_uncached
24
38
  ::Avm::Instances::Configuration.find_by_path(@git)
25
39
  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
 
@@ -28,20 +29,6 @@ module Avm
28
29
  end
29
30
  end
30
31
 
31
- def validations
32
- VALIDATIONS.map do |key, label|
33
- ::OpenStruct.new(key: key, label: label, result: validation_result(key))
34
- end
35
- end
36
-
37
- def validation_result(key)
38
- if skip_validations.include?(key)
39
- ::Avm::Result.neutral('skipped')
40
- else
41
- send("#{key}_result")
42
- end
43
- end
44
-
45
32
  def validate_skip_validations
46
33
  skip_validations.each do |validation|
47
34
  next if VALIDATIONS.keys.include?(validation)
@@ -49,6 +36,14 @@ module Avm
49
36
  raise "\"#{validation}\" is not a registered validation"
50
37
  end
51
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
52
47
  end
53
48
  end
54
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,13 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_gems_utils/gem'
4
+
3
5
  module Avm
4
6
  module Instances
5
7
  class Configuration < ::EacRubyUtils::Configs
8
+ BUNDLE_TEST_COMMAND_KEY = 'test.bundle_command'
6
9
  TEST_COMMAND_KEY = 'test.command'
7
10
 
11
+ def any_test_command
12
+ bundle_test_command || test_command
13
+ end
14
+
8
15
  def test_command
9
16
  read_command(TEST_COMMAND_KEY)
10
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
11
25
  end
12
26
  end
13
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
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Rails
8
+ module Runners
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ enable_console_speaker
11
+ enable_simple_cache
12
+
13
+ DOC = <<~DOC
14
+ Runs a Ruby code with "rails runner".
15
+
16
+ Usage:
17
+ __PROGRAM__ [options] <code>
18
+ __PROGRAM__ --version
19
+ __PROGRAM__ -h | --help
20
+
21
+ Options:
22
+ -h --help Show this screen.
23
+ -e --environment Specifies the environment for the runner to
24
+ operate (test/development/production). Default: "development".
25
+ DOC
26
+
27
+ def run
28
+ infov 'Runner arguments', runner_args
29
+ infov 'Environment', context(:instance).host_env
30
+ runner_command.system!
31
+ end
32
+
33
+ def runner_command_uncached
34
+ context(:instance).bundle(*bundle_args)
35
+ end
36
+
37
+ def bundle_args
38
+ %w[exec rails runner] + runner_args
39
+ end
40
+
41
+ def runner_args
42
+ options.fetch('--environment').if_present([]) { |v| ['--environment', v] } +
43
+ [options.fetch('<code>')]
44
+ end
45
+ end
46
+ end
47
+ end
48
+ 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
@@ -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
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/rails/runners/runner'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class EacRailsBase0 < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner < ::Avm::Rails::Runners::Runner
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
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/rails/runners/runner'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner < ::Avm::Rails::Runners::Runner
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/files/formatter'
4
- require 'avm/patches/eac_launcher_git_base'
4
+ require 'eac_launcher/git/base'
5
5
  require 'eac_ruby_utils/console/docopt_runner'
6
6
  require 'eac_ruby_utils/core_ext'
7
7