avm-tools 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/fs_cache.rb +11 -0
- data/lib/avm/git/revision_test.rb +103 -0
- data/lib/avm/patches/eac_launcher_git_base.rb +4 -0
- data/lib/avm/ruby.rb +25 -0
- data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +2 -19
- data/lib/avm/tools/runner/git/revisions_test.rb +77 -0
- data/lib/avm/tools/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ddfc7d16b8fdfe9667b1946cce15ec58148f16bd8f0df9eeb20017e37b6410
|
4
|
+
data.tar.gz: b04f18cc844998d78c2f0f9e337c2f276e092d10bc8f7d43bb88dfe5dc024425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a1fdec71e84673c36e350c9802e60e16159da27bd8761c196e3adafaa6b4528d2a51de0b2a0ad19a3a9eabeddaf590242e860eae3421cd839a9cc69d02043c5
|
7
|
+
data.tar.gz: 6e0e9d04f05d2d9c62342930bf572bab4304725fa012a710fe1f69569ef8d6673271a68c4e0562bfa4e3de8a8a4af2996714788383421693ca0604167ebe2705
|
data/lib/avm/fs_cache.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/fs_cache'
|
4
|
+
require 'avm/ruby'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Git
|
9
|
+
class RevisionTest
|
10
|
+
enable_simple_cache
|
11
|
+
enable_console_speaker
|
12
|
+
common_constructor :git, :sha1, :options
|
13
|
+
|
14
|
+
def banner
|
15
|
+
infov 'Revision to test', sha1
|
16
|
+
on_speaker_node do |node|
|
17
|
+
node.stderr_line_prefix = ' '
|
18
|
+
infov '* Subject', commit.subject
|
19
|
+
infov '* Success?', successful_label
|
20
|
+
infov '* STDOUT', stdout_cache.content_path
|
21
|
+
infov '* STDERR', stderr_cache.content_path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def successful_label
|
26
|
+
successful?.to_s.send((successful? ? :green : :red))
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
sha1
|
31
|
+
end
|
32
|
+
|
33
|
+
def successful?
|
34
|
+
successful
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def checkout_revision
|
40
|
+
infom 'Checking out revision...'
|
41
|
+
git.execute!('checkout', sha1)
|
42
|
+
end
|
43
|
+
|
44
|
+
def commit_uncached
|
45
|
+
::Avm::Git::Commit.new(git, sha1)
|
46
|
+
end
|
47
|
+
|
48
|
+
def git_absolute_path
|
49
|
+
::File.expand_path(git.to_s)
|
50
|
+
end
|
51
|
+
|
52
|
+
def root_cache
|
53
|
+
::Avm.fs_cache.child('git', 'revision_test', git_absolute_path.parameterize, sha1,
|
54
|
+
options.fetch(:test_command).to_s.parameterize)
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_test
|
58
|
+
infom "Running test command \"#{::Shellwords.join(test_command_args)}\"" \
|
59
|
+
" on \"#{git_absolute_path}\"..."
|
60
|
+
result = ::Avm::Ruby.on_clean_environment { test_command.execute }
|
61
|
+
infom 'Test done'
|
62
|
+
write_result_cache(result)
|
63
|
+
end
|
64
|
+
|
65
|
+
def stdout_cache
|
66
|
+
root_cache.child('stdout')
|
67
|
+
end
|
68
|
+
|
69
|
+
def stderr_cache
|
70
|
+
root_cache.child('stderr')
|
71
|
+
end
|
72
|
+
|
73
|
+
def successful_cache
|
74
|
+
root_cache.child('successful')
|
75
|
+
end
|
76
|
+
|
77
|
+
def successful_uncached
|
78
|
+
if options.fetch(:no_cache) || !successful_cache.cached?
|
79
|
+
checkout_revision
|
80
|
+
run_test
|
81
|
+
end
|
82
|
+
successful_cache.read == 'true'
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_command
|
86
|
+
::EacRubyUtils::Envs.local.command(*test_command_args).chdir(git.to_s)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_command_args
|
90
|
+
r = ::Shellwords.split(options.fetch(:test_command).to_s)
|
91
|
+
return r if r.any?
|
92
|
+
|
93
|
+
raise 'No command found'
|
94
|
+
end
|
95
|
+
|
96
|
+
def write_result_cache(result)
|
97
|
+
stdout_cache.write(result[:stdout])
|
98
|
+
stderr_cache.write(result[:stderr])
|
99
|
+
successful_cache.write(result[:exit_code].zero? ? 'true' : 'false')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/avm/ruby.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module Ruby
|
5
|
+
class << self
|
6
|
+
def on_clean_environment
|
7
|
+
on_clean_envvars('BUNDLE', 'RUBY') { yield }
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def on_clean_envvars(*start_with_vars)
|
13
|
+
old_values = envvars_starting_with(start_with_vars)
|
14
|
+
old_values.keys.each { |k| ENV.delete(k) }
|
15
|
+
yield
|
16
|
+
ensure
|
17
|
+
old_values&.each { |k, v| ENV[k] = v }
|
18
|
+
end
|
19
|
+
|
20
|
+
def envvars_starting_with(start_with_vars)
|
21
|
+
ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/ruby'
|
3
4
|
require 'avm/stereotypes/eac_webapp_base0/deploy'
|
4
5
|
|
5
6
|
module Avm
|
@@ -10,7 +11,7 @@ module Avm
|
|
10
11
|
|
11
12
|
def run_installer
|
12
13
|
infom 'Running installer'
|
13
|
-
|
14
|
+
::Avm::Ruby.on_clean_environment do
|
14
15
|
installer_command.system!
|
15
16
|
end
|
16
17
|
end
|
@@ -31,24 +32,6 @@ module Avm
|
|
31
32
|
'redmine_as_apache_base'
|
32
33
|
end
|
33
34
|
end
|
34
|
-
|
35
|
-
def on_clean_ruby
|
36
|
-
on_clear_envvars('BUNDLE', 'RUBY') { yield }
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def on_clear_envvars(*start_with_vars)
|
42
|
-
old_values = envvars_starting_with(start_with_vars)
|
43
|
-
old_values.keys.each { |k| ENV.delete(k) }
|
44
|
-
yield
|
45
|
-
ensure
|
46
|
-
old_values&.each { |k, v| ENV[k] = v }
|
47
|
-
end
|
48
|
-
|
49
|
-
def envvars_starting_with(start_with_vars)
|
50
|
-
ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
|
51
|
-
end
|
52
35
|
end
|
53
36
|
end
|
54
37
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
5
|
+
require 'avm/git/revision_test'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Tools
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class Git < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class RevisionsTest < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
enable_simple_cache
|
13
|
+
enable_console_speaker
|
14
|
+
|
15
|
+
DOC = <<~DOCOPT
|
16
|
+
Test multiple revisions until a error is found.
|
17
|
+
|
18
|
+
Usage:
|
19
|
+
__PROGRAM__ [options]
|
20
|
+
__PROGRAM__ -h | --help
|
21
|
+
|
22
|
+
Options:
|
23
|
+
-h --help Mostra esta ajuda.
|
24
|
+
-c --command=<test-command> Command to test instance.
|
25
|
+
-n --no-cache Does not use cache.
|
26
|
+
DOCOPT
|
27
|
+
|
28
|
+
def run
|
29
|
+
fatal_error('Repository is dirty') if context(:git).dirty?
|
30
|
+
|
31
|
+
return_to_branch_on_end do
|
32
|
+
infov 'Revisions found', revisions.count
|
33
|
+
if revision_with_error
|
34
|
+
warn("First revision with error: #{revision_with_error}")
|
35
|
+
else
|
36
|
+
success('No error found in revisions')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def return_to_branch_on_end
|
44
|
+
current_branch = context(:git).current_branch
|
45
|
+
yield
|
46
|
+
ensure
|
47
|
+
infom "Returning to original branch \"#{current_branch}\""
|
48
|
+
context(:git).execute!('checkout', current_branch)
|
49
|
+
end
|
50
|
+
|
51
|
+
def revision_with_error_uncached
|
52
|
+
revision_with_error = nil
|
53
|
+
revisions.each do |revision|
|
54
|
+
revision.banner
|
55
|
+
unless revision.successful?
|
56
|
+
revision_with_error = revision
|
57
|
+
break
|
58
|
+
end
|
59
|
+
end
|
60
|
+
revision_with_error
|
61
|
+
end
|
62
|
+
|
63
|
+
def revisions_uncached
|
64
|
+
context(:git).execute!('log', '--pretty=format:%H', 'origin/master..HEAD')
|
65
|
+
.each_line.map(&:strip).reverse.map do |sha1|
|
66
|
+
::Avm::Git::RevisionTest.new(context(:git), sha1, test_revision_options)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_revision_options
|
71
|
+
{ test_command: options.fetch('--command'), no_cache: options.fetch('--no-cache') }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/avm/tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- lib/avm/executables.rb
|
195
195
|
- lib/avm/files.rb
|
196
196
|
- lib/avm/files/rotate.rb
|
197
|
+
- lib/avm/fs_cache.rb
|
197
198
|
- lib/avm/git.rb
|
198
199
|
- lib/avm/git/commit.rb
|
199
200
|
- lib/avm/git/commit/deploy.rb
|
@@ -209,6 +210,7 @@ files:
|
|
209
210
|
- lib/avm/git/issue/complete/_remote.rb
|
210
211
|
- lib/avm/git/issue/complete/_tracker.rb
|
211
212
|
- lib/avm/git/issue/complete/_validations.rb
|
213
|
+
- lib/avm/git/revision_test.rb
|
212
214
|
- lib/avm/git/spec_helper.rb
|
213
215
|
- lib/avm/instances.rb
|
214
216
|
- lib/avm/instances/application.rb
|
@@ -232,6 +234,7 @@ files:
|
|
232
234
|
- lib/avm/patches/object/template.rb
|
233
235
|
- lib/avm/path_string.rb
|
234
236
|
- lib/avm/result.rb
|
237
|
+
- lib/avm/ruby.rb
|
235
238
|
- lib/avm/self.rb
|
236
239
|
- lib/avm/self/docker_image.rb
|
237
240
|
- lib/avm/self/instance.rb
|
@@ -293,6 +296,7 @@ files:
|
|
293
296
|
- lib/avm/tools/runner/git/dirty_files.rb
|
294
297
|
- lib/avm/tools/runner/git/issue.rb
|
295
298
|
- lib/avm/tools/runner/git/issue/complete.rb
|
299
|
+
- lib/avm/tools/runner/git/revisions_test.rb
|
296
300
|
- lib/avm/tools/runner/self.rb
|
297
301
|
- lib/avm/tools/runner/self/docker.rb
|
298
302
|
- lib/avm/tools/version.rb
|