lazylead 0.5.2 → 0.6.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 +4 -4
- data/lazylead.gemspec +3 -2
- data/lib/lazylead/opts.rb +1 -0
- data/lib/lazylead/postman.rb +4 -3
- data/lib/lazylead/system/jira.rb +21 -4
- data/lib/lazylead/task/accuracy/accuracy.rb +1 -1
- data/lib/lazylead/task/accuracy/logs.rb +5 -3
- data/lib/lazylead/task/accuracy/servers.rb +1 -1
- data/lib/lazylead/task/accuracy/stacktrace.rb +50 -10
- data/lib/lazylead/task/accuracy/testcase.rb +12 -6
- data/lib/lazylead/task/assignment.rb +96 -0
- data/lib/lazylead/task/fix_version.rb +4 -0
- data/lib/lazylead/task/svn/diff.rb +76 -0
- data/lib/lazylead/task/svn/grep.rb +111 -0
- data/lib/lazylead/task/svn/touch.rb +101 -0
- data/lib/lazylead/version.rb +1 -1
- data/lib/messages/illegal_assignee_change.erb +123 -0
- data/lib/messages/illegal_fixversion_change.erb +2 -0
- data/lib/messages/svn_diff.erb +110 -0
- data/lib/messages/{svn_log.erb → svn_diff_attachment.erb} +0 -0
- data/lib/messages/svn_grep.erb +114 -0
- data/test/lazylead/system/jira_test.rb +6 -7
- data/test/lazylead/task/accuracy/logs_test.rb +62 -2
- data/test/lazylead/task/accuracy/stacktrace_test.rb +227 -0
- data/test/lazylead/task/accuracy/testcase_test.rb +10 -0
- data/test/lazylead/task/assignment_test.rb +53 -0
- data/test/lazylead/task/svn/diff_test.rb +97 -0
- data/test/lazylead/task/svn/grep_test.rb +61 -0
- data/test/lazylead/task/{touch_test.rb → svn/touch_test.rb} +7 -34
- metadata +33 -7
- data/lib/lazylead/task/touch.rb +0 -119
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50916d6916b46d8ea4c92fc6c4a02b75d6f9e35bbaad260057dd61bb0e25b650
|
4
|
+
data.tar.gz: d536e0d99c760a853d3a24f47d2b1a8fbece654790af65ec02fe7c3bf69af085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da6131b9e02115b3b61c70c3a38665f563f4ff7d37f20b0939073f11c05549c061403e9fa1711897b26917b88f324e89dd42c64128a27b72b6ebbf0b134e1d20
|
7
|
+
data.tar.gz: bcc6287781baced0f0c0e0d4506fc1fa18439c98ff66a9254704620b537e9eb448daabdef646aa145ddf2d744c2f07f805ef717612bba0e4b86901be8ef33a85
|
data/lazylead.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.rubygems_version = "2.2"
|
33
33
|
s.required_ruby_version = ">=2.6.5"
|
34
34
|
s.name = "lazylead"
|
35
|
-
s.version = "0.
|
35
|
+
s.version = "0.6.0"
|
36
36
|
s.license = "MIT"
|
37
37
|
s.summary = "Eliminate the annoying work within bug-trackers."
|
38
38
|
s.description = "Ticketing systems (Github, Jira, etc.) are strongly
|
@@ -45,7 +45,7 @@ tasks instead of solving technical problems."
|
|
45
45
|
s.authors = ["Yurii Dubinka"]
|
46
46
|
s.email = "yurii.dubinka@gmail.com"
|
47
47
|
s.homepage = "http://github.com/dgroup/lazylead"
|
48
|
-
s.post_install_message = "Thanks for installing Lazylead v0.
|
48
|
+
s.post_install_message = "Thanks for installing Lazylead v0.6.0!
|
49
49
|
Read our blog posts: https://lazylead.org
|
50
50
|
Stay in touch with the community in Telegram: https://t.me/lazylead
|
51
51
|
Follow us on Twitter: https://twitter.com/lazylead
|
@@ -71,6 +71,7 @@ tasks instead of solving technical problems."
|
|
71
71
|
s.add_runtime_dependency "slop", "4.4"
|
72
72
|
s.add_runtime_dependency "sqlite3", "1.4.2"
|
73
73
|
s.add_runtime_dependency "tilt", "2.0.10"
|
74
|
+
s.add_runtime_dependency "tmpdir", "0.1.0"
|
74
75
|
s.add_runtime_dependency "tzinfo", "1.1"
|
75
76
|
s.add_runtime_dependency "tzinfo-data", "1.2019.3"
|
76
77
|
s.add_runtime_dependency "vcs4sql", "0.1.0"
|
data/lib/lazylead/opts.rb
CHANGED
data/lib/lazylead/postman.rb
CHANGED
@@ -75,9 +75,10 @@ module Lazylead
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def add_attachments(mail, opts)
|
78
|
-
return unless opts.key?
|
79
|
-
opts["attachments"]
|
80
|
-
|
78
|
+
return unless opts.key?("attachments") || opts.key?(:attachments)
|
79
|
+
attach = opts["attachments"] || opts[:attachments]
|
80
|
+
return if attach.nil?
|
81
|
+
attach.select { |a| File.file? a }.each { |a| mail.add_file a }
|
81
82
|
end
|
82
83
|
end
|
83
84
|
end
|
data/lib/lazylead/system/jira.rb
CHANGED
@@ -25,6 +25,7 @@
|
|
25
25
|
require "jira-ruby"
|
26
26
|
require "forwardable"
|
27
27
|
require_relative "../salt"
|
28
|
+
require_relative "../opts"
|
28
29
|
|
29
30
|
module Lazylead
|
30
31
|
# Jira system for manipulation with issues.
|
@@ -45,16 +46,32 @@ module Lazylead
|
|
45
46
|
" and salt #{@salt.id} (found=#{@salt.specified?})"
|
46
47
|
end
|
47
48
|
|
48
|
-
|
49
|
+
# Find the jira issues by 'JQL'
|
50
|
+
# @param 'jql' - Jira search query
|
51
|
+
# @param 'opts' - Parameters for Jira search query.
|
52
|
+
# :max_results => maximum number of tickets per one iteration.
|
53
|
+
# :fields => ticket fields to be fetched like assignee, summary, etc.
|
54
|
+
def issues(jql, opts = { max_results: 50, fields: nil, expand: nil })
|
49
55
|
raw do |jira|
|
50
|
-
|
56
|
+
start = 0
|
57
|
+
tickets = []
|
58
|
+
total = jira.Issue.jql(jql, max_results: 0)
|
59
|
+
@log.debug "Found #{total} ticket(s) in '#{jql}'"
|
60
|
+
loop do
|
61
|
+
tickets.concat(jira.Issue.jql(jql, opts.merge(start_at: start))
|
62
|
+
.map { |i| Lazylead::Issue.new(i, jira) })
|
63
|
+
@log.debug "Fetched #{tickets.size}"
|
64
|
+
start += opts.fetch(:max_results, 50).to_i
|
65
|
+
break if start > total
|
66
|
+
end
|
67
|
+
tickets
|
51
68
|
end
|
52
69
|
end
|
53
70
|
|
54
71
|
# Execute request to the ticketing system using raw client.
|
55
72
|
# For Jira the raw client is 'jira-ruby' gem.
|
56
73
|
def raw
|
57
|
-
raise "ll-
|
74
|
+
raise "ll-009: No block given to method" unless block_given?
|
58
75
|
yield client
|
59
76
|
end
|
60
77
|
|
@@ -325,7 +342,7 @@ module Lazylead
|
|
325
342
|
|
326
343
|
# Execute request to the ticketing system using raw client.
|
327
344
|
def raw
|
328
|
-
raise "ll-
|
345
|
+
raise "ll-008: No block given to method" unless block_given?
|
329
346
|
yield(OpenStruct.new(Issue: self))
|
330
347
|
end
|
331
348
|
|
@@ -31,10 +31,12 @@ module Lazylead
|
|
31
31
|
super("Log files", 2, "Attachments")
|
32
32
|
end
|
33
33
|
|
34
|
-
# Ensure that ticket has a '*.log' file more '
|
34
|
+
# Ensure that ticket has a '*.log' file more '5KB'
|
35
35
|
def matching(attachment)
|
36
|
-
attachment.attrs["
|
37
|
-
|
36
|
+
name = attachment.attrs["filename"].downcase
|
37
|
+
return false unless attachment.attrs["size"].to_i > 5120
|
38
|
+
return true if File.extname(name).start_with?(".log", ".txt")
|
39
|
+
%w[.log.zip .log.gz .log.tar.gz].any? { |l| name.end_with? l }
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -43,7 +43,7 @@ module Lazylead
|
|
43
43
|
.reject(&:blank?)
|
44
44
|
.map(&:strip)
|
45
45
|
.flat_map { |l| l.split(" ").map(&:strip) }
|
46
|
-
.select { |w| w.
|
46
|
+
.select { |w| w.include?("http://") || w.include?("https://") }
|
47
47
|
.any? { |u| @envs.any? { |e| u.match? e } }
|
48
48
|
end
|
49
49
|
end
|
@@ -34,24 +34,64 @@ module Lazylead
|
|
34
34
|
|
35
35
|
def passed(issue)
|
36
36
|
return false if issue.description.nil?
|
37
|
-
|
37
|
+
frames(issue.description).any? { |f| oracle?(f) || java?(f) }
|
38
38
|
end
|
39
39
|
|
40
|
-
# Detect all {noformat} frames in description
|
40
|
+
# Detect all {noformat}, {code} frames in ticket description
|
41
41
|
def frames(description)
|
42
|
-
description.
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
noformat(description).concat(code(description))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Detect all noformat blocks and give all text snippets in array
|
46
|
+
# @param desc The jira ticket description
|
47
|
+
def noformat(desc)
|
48
|
+
return [] unless desc.match?(/{(n|N)(o|O)(f|F)(o|O)(r|R)(m|M)(a|A)(t|T)}/)
|
49
|
+
desc.enum_for(:scan, /(?=\{(n|N)(o|O)(f|F)(o|O)(r|R)(m|M)(a|A)(t|T)})/)
|
50
|
+
.map { Regexp.last_match.offset(0).first }
|
51
|
+
.each_slice(2).map do |f|
|
52
|
+
desc[f.first, f.last - f.first + "{noformat}".size]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Detect all {code:*} blocks and give all text snippets in array
|
57
|
+
# @param desc The jira ticket description
|
58
|
+
def code(desc)
|
59
|
+
return [] unless desc.match?(/{(c|C)(o|O)(d|D)(e|E)(:\S+)?}/)
|
60
|
+
words = desc.gsub(/{(c|C)(o|O)(d|D)(e|E)/, " {code")
|
61
|
+
.gsub("}", "} ")
|
62
|
+
.gsub("Caused by:", "Caused_by:")
|
63
|
+
.split(" ")
|
64
|
+
.map(&:strip)
|
65
|
+
.reject(&:blank?)
|
66
|
+
pairs(words, "{code").map { |s| words[s.first..s.last].join("\n") }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Detect indexes of pairs which are starting from particular text
|
70
|
+
# @param words is array of words
|
71
|
+
# @param text is a label for pairs
|
72
|
+
#
|
73
|
+
# paris([aa,tag,bb,cc,tag,dd], "tag") => [[1, 4]]
|
74
|
+
# paris([aa,tag,bb,cc,tag,dd,tag,ee], "tag") => [[1, 4]] # non closed
|
75
|
+
#
|
76
|
+
def pairs(words, text)
|
77
|
+
snippets = [[]]
|
78
|
+
words.each_with_index do |e, i|
|
79
|
+
next unless e.start_with? text
|
80
|
+
pair = snippets.last
|
81
|
+
pair << i if pair.size.zero? || pair.size == 1
|
82
|
+
snippets[-1] = pair
|
83
|
+
snippets << [] if pair.size == 2
|
46
84
|
end
|
85
|
+
snippets.select { |s| s.size == 2 }
|
47
86
|
end
|
48
87
|
|
49
88
|
# @return true if frame has few lines with java stack frames
|
50
89
|
def java?(frame)
|
51
|
-
allowed = ["at
|
52
|
-
frame.
|
53
|
-
|
54
|
-
|
90
|
+
allowed = ["at", "Caused by:", "Caused_by:"]
|
91
|
+
frame.match?(/\s\S+\.\S+Exception:\s/) ||
|
92
|
+
frame.split("\n")
|
93
|
+
.map(&:strip)
|
94
|
+
.count { |l| allowed.any? { |a| l.start_with? a } } > 3
|
55
95
|
end
|
56
96
|
|
57
97
|
# @return true if frame has Oracle error
|
@@ -38,7 +38,7 @@ module Lazylead
|
|
38
38
|
return false if issue.description.nil?
|
39
39
|
@tc = @ar = @er = -1
|
40
40
|
issue.description.split("\n").reject(&:blank?).each_with_index do |l, i|
|
41
|
-
line = escape(l.
|
41
|
+
line = escape(l.downcase.gsub(/\s+/, ""))
|
42
42
|
detect_tc(line, i)
|
43
43
|
detect_ar(line, i)
|
44
44
|
detect_er(line, i)
|
@@ -65,21 +65,27 @@ module Lazylead
|
|
65
65
|
# Detect index of line with test case
|
66
66
|
def detect_tc(line, index)
|
67
67
|
return unless @tc.negative?
|
68
|
-
@tc = index if %w[testcase: tc: teststeps: teststeps steps:]
|
69
|
-
e.eql? line
|
70
|
-
end
|
68
|
+
@tc = index if eql?(line, %w[testcase: tc: teststeps: teststeps steps:])
|
71
69
|
end
|
72
70
|
|
73
71
|
# Detect index of line with actual result
|
74
72
|
def detect_ar(line, index)
|
75
73
|
return unless @ar.negative? && index > @tc
|
76
|
-
@ar = index if %w[ar: actualresult: ar=
|
74
|
+
@ar = index if starts?(line, %w[ar: actualresult: ar= *ar*= *ar*:])
|
77
75
|
end
|
78
76
|
|
79
77
|
# Detect index of line with expected result
|
80
78
|
def detect_er(line, index)
|
81
79
|
return unless @er.negative? && index > @tc
|
82
|
-
@er = index if %w[er: expectedresult: er=
|
80
|
+
@er = index if starts?(line, %w[er: expectedresult: er= *er*= *er*:])
|
81
|
+
end
|
82
|
+
|
83
|
+
def starts?(line, text)
|
84
|
+
text.any? { |t| line.start_with? t }
|
85
|
+
end
|
86
|
+
|
87
|
+
def eql?(line, text)
|
88
|
+
text.any? { |t| t.eql? line }
|
83
89
|
end
|
84
90
|
end
|
85
91
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2020 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require "date"
|
26
|
+
require_relative "../log"
|
27
|
+
require_relative "../opts"
|
28
|
+
require_relative "../system/jira"
|
29
|
+
|
30
|
+
module Lazylead
|
31
|
+
module Task
|
32
|
+
#
|
33
|
+
# Email alerts about illegal issue assignment(s).
|
34
|
+
#
|
35
|
+
# Author:: Yurii Dubinka (yurii.dubinka@gmail.com)
|
36
|
+
# Copyright:: Copyright (c) 2019-2020 Yurii Dubinka
|
37
|
+
# License:: MIT
|
38
|
+
class Assignment
|
39
|
+
def initialize(log = Log.new)
|
40
|
+
@log = log
|
41
|
+
end
|
42
|
+
|
43
|
+
def run(sys, postman, opts)
|
44
|
+
allowed = opts.slice "allowed", ","
|
45
|
+
silent = opts.key? "silent"
|
46
|
+
issues = sys.issues opts["jql"],
|
47
|
+
opts.jira_defaults.merge(expand: "changelog")
|
48
|
+
return if issues.empty?
|
49
|
+
postman.send opts.merge(
|
50
|
+
assignees: issues.map { |i| Assignee.new(i, allowed, silent) }
|
51
|
+
.select(&:illegal?)
|
52
|
+
.each(&:add_label)
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Instance of "Assignee" history item for the particular ticket.
|
58
|
+
class Assignee
|
59
|
+
attr_reader :issue
|
60
|
+
|
61
|
+
def initialize(issue, allowed, silent)
|
62
|
+
@issue = issue
|
63
|
+
@allowed = allowed
|
64
|
+
@silent = silent
|
65
|
+
end
|
66
|
+
|
67
|
+
# Gives true when last change of "Assignee" field was done
|
68
|
+
# by not authorized person.
|
69
|
+
def illegal?
|
70
|
+
@allowed.none? do |a|
|
71
|
+
return false if last.nil?
|
72
|
+
a == last["author"]["name"]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Detect details about last change of "Assignee" to non-null value
|
77
|
+
def last
|
78
|
+
@last ||= issue.history.reverse.find do |h|
|
79
|
+
h["items"].any? do |i|
|
80
|
+
i["field"] == "assignee"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Mark ticket with particular label
|
86
|
+
def add_label(name = "LL.IllegalChangeOfAssignee")
|
87
|
+
@issue.add_label(name) unless @silent
|
88
|
+
end
|
89
|
+
|
90
|
+
# The name of current assignee for ticket
|
91
|
+
def to
|
92
|
+
@issue.fields["assignee"]["name"]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2020 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require "tmpdir"
|
26
|
+
require "nokogiri"
|
27
|
+
require "active_support/core_ext/hash/conversions"
|
28
|
+
require_relative "../../salt"
|
29
|
+
require_relative "../../opts"
|
30
|
+
|
31
|
+
module Lazylead
|
32
|
+
module Task
|
33
|
+
module Svn
|
34
|
+
#
|
35
|
+
# Send notification about modification of svn files since particular
|
36
|
+
# revision.
|
37
|
+
#
|
38
|
+
class Diff
|
39
|
+
def initialize(log = Log.new)
|
40
|
+
@log = log
|
41
|
+
end
|
42
|
+
|
43
|
+
def run(_, postman, opts)
|
44
|
+
cmd = [
|
45
|
+
"svn log --diff --no-auth-cache",
|
46
|
+
"--username #{opts.decrypt('svn_user', 'svn_salt')}",
|
47
|
+
"--password #{opts.decrypt('svn_password', 'svn_salt')}",
|
48
|
+
"-r#{opts['since_rev']}:HEAD #{opts['svn_url']}"
|
49
|
+
]
|
50
|
+
stdout = `#{cmd.join(" ")}`
|
51
|
+
send_email stdout, postman, opts unless stdout.blank?
|
52
|
+
end
|
53
|
+
|
54
|
+
# Send email with svn log as an attachment.
|
55
|
+
# The attachment won't be stored locally and we'll be removed once
|
56
|
+
# mail sent.
|
57
|
+
def send_email(stdout, postman, opts)
|
58
|
+
Dir.mktmpdir do |dir|
|
59
|
+
name = "svn-log-#{Date.today.strftime('%d-%b-%Y')}.html"
|
60
|
+
f = File.open(File.join(dir, name), "w")
|
61
|
+
f.write(
|
62
|
+
Email.new(
|
63
|
+
opts["template-attachment"],
|
64
|
+
opts.merge(stdout: stdout, version: Lazylead::VERSION)
|
65
|
+
).render
|
66
|
+
)
|
67
|
+
postman.send opts.merge(stdout: stdout, attachments: [f.path])
|
68
|
+
rescue StandardError => e
|
69
|
+
@log.error "ll-010: Can't send an email for #{opts} based on "\
|
70
|
+
"'#{stdout}'", e
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|