apadmi_grout 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e1366656468880b0537f216f0e6e6d02ac91a8da0a90098f16923bf8b0959a7
4
- data.tar.gz: 12a4ea1f4d6a19d229aec128b2e6dce25fdc65333dc88974a9f3caca248a9a6d
3
+ metadata.gz: f779ff10f50f15d2ce74311339c8407ae32eec3bcc8fb49f0ab3a85d8a0cbdc7
4
+ data.tar.gz: e0f9034584fdcafb95355ade65f64ccdd7e82acc2e07d62a5bd61129e3fc5464
5
5
  SHA512:
6
- metadata.gz: e64db1a7ace678871f6f32a9e2747d62ae854024755b52bbb4caadd474f989fa10cd5151021dde2c9eafb8cf48b7e58633dbcafa2f2e81fddfc088eca0e965dc
7
- data.tar.gz: 7bd1bd81f7bc1a24050ed0fe95bc73af8be5765745e5ff3d926728196cbf1b3d96600437f3c08cfa13256cb344b6f746fb0c457b30f0a7a0d22604050337cad4
6
+ metadata.gz: 10b206d1d56814b6288bf0db35259c02c81baf0c3554de6286627498c0d65ee6f8808fafcd5908038be9a196ae264952180fc4988ca15b4023dd03a1380c98be
7
+ data.tar.gz: ecbf93eb1f3bd3141a54949568edc1196ad6b7aaf7348f89f93e9fb46bf76aa424504cf2a5bc5d9effd78f811543322980c65a7e83231cdb283ca492aec53fc8
data/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Core Changelog
2
2
 
3
- ## [Unreleased]
3
+ ## [1.1.0] - 2022-05-12
4
+ * Support allowing tickets that aren't assigned to a sprint to be moved.
5
+ * Created utilities for getting the git root and number of commits
4
6
 
5
7
  ## [1.0.0] - 2022-05-09 - Initial release
6
8
 
@@ -16,21 +16,25 @@ module Apadmi
16
16
  # @param component [String] Only include tickets tagged with this component
17
17
  # @param status [String] The status of tickets to be moved (Usually "Awaiting QA Release")
18
18
  # @param excluded_ticket_keys [Array<String>] ticket keys to be excluded from consideration
19
- # @param custom_flag_messages [FlagMessages]
19
+ # @param custom_flag_messages [Apadmi::Grout::FlagMessages]
20
+ # @param options [Apadmi::Grout::FindTicketsOptions]
20
21
  # @return [Array<JIRA::Resource::Issue>] the issues ready to move
21
22
  def run(
22
23
  component,
23
24
  status,
24
25
  excluded_ticket_keys,
25
- custom_flag_messages = FlagMessages.new(
26
- "REASON FOR FLAG: Check this ticket - it was put in #{status} but has no PRs connected to it. CI still moved it",
27
- "REASON FOR FLAG: Check this ticket - it was put in #{status} but has no MERGED PRs and at least one OPEN PR",
28
- "REASON FOR FLAG: Check this ticket - it was put in #{status} but has only DECLINED PRs",
29
- "REASON FOR FLAG: Check this ticket - it was put in #{status} but has no MERGED PRs"
30
- )
26
+ custom_flag_messages = nil,
27
+ options = nil
31
28
  )
32
- issues = @jira_wrapper.search_unblocked_issues(component, status).reject do |issue|
33
- puts issue.key
29
+ custom_flag_messages ||= Apadmi::Grout::FlagMessages.default(status)
30
+ options ||= Apadmi::Grout::FindTicketsOptions.new(include_no_sprint_tickets: false)
31
+
32
+ issues = @jira_wrapper.search_unblocked_issues(
33
+ component,
34
+ status,
35
+ [],
36
+ allow_no_sprint: options.include_no_sprint_tickets
37
+ ).reject do |issue|
34
38
  excluded_ticket_keys.include? issue.key
35
39
  end
36
40
 
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apadmi
4
+ module Grout
5
+ FindTicketsOptions = Struct.new(
6
+ :include_no_sprint_tickets,
7
+ keyword_init: true
8
+ )
9
+ end
10
+ end
@@ -1,8 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- FlagMessages = Struct.new(
4
- :no_prs_flag_msg,
5
- :open_prs_flag_msg,
6
- :declined_prs_flag_msg,
7
- :no_merged_prs_flag_msg
8
- )
3
+ module Apadmi
4
+ module Grout
5
+ FlagMessages = Struct.new(
6
+ :no_prs_flag_msg,
7
+ :open_prs_flag_msg,
8
+ :declined_prs_flag_msg,
9
+ :no_merged_prs_flag_msg
10
+ ) do
11
+ # Get default flag messages
12
+ # @param status [String] status ticket will be moving to
13
+ # @return [Apadmi::Grout::FlagMessages]
14
+ def self.default(status)
15
+ FlagMessages.new(
16
+ "REASON FOR FLAG: Check this ticket - it was put in #{status} but has no PRs connected to it. CI still moved it",
17
+ "REASON FOR FLAG: Check this ticket - it was put in #{status} but has no MERGED PRs and at least one OPEN PR",
18
+ "REASON FOR FLAG: Check this ticket - it was put in #{status} but has only DECLINED PRs",
19
+ "REASON FOR FLAG: Check this ticket - it was put in #{status} but has no MERGED PRs"
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
@@ -46,16 +46,19 @@ module Apadmi
46
46
  # @param [String] component
47
47
  # @param [String] status
48
48
  # @param [String[]] ticket_types
49
+ # @param [Boolean] allow_no_sprint
49
50
  # @return [Array<JIRA::Resource::Issue>]
50
- def search_unblocked_issues(component, status, ticket_types = [])
51
+ def search_unblocked_issues(component, status, ticket_types = [], allow_no_sprint: false)
51
52
  component_filter = (" AND component = '#{component}' " unless component.empty?) || ""
52
53
  status_filter = (" AND status = '#{status}' " unless status.empty?) || ""
53
54
  type_filter = ("AND (#{ticket_types.map { |type| "type = #{type}" }.join("OR ")})" unless ticket_types.empty?) || ""
55
+ empty_sprint_condition = ("OR sprint is EMPTY" if allow_no_sprint) || ""
54
56
 
55
57
  jql_search = %{
56
58
  project = '#{@project}'
57
59
  #{status_filter} #{component_filter} #{type_filter}
58
- AND sprint in openSprints() AND (labels not in(Blocked) or labels is EMPTY) AND Flagged is EMPTY
60
+ AND (sprint in openSprints() #{empty_sprint_condition}) AND (labels not in(Blocked) or labels is EMPTY)
61
+ AND Flagged is EMPTY
59
62
  }
60
63
 
61
64
  @jira_client.Issue.jql(jql_search, { max_results: 1000 }).uniq
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apadmi
4
+ module Grout
5
+ # Generic Filename Utils
6
+ class FilenameUtils
7
+ # Constructs a standard Apadmi filename for a build output binary
8
+ # @param [Hash] options the options to create a filename with
9
+ # @option options [String] :client_name The client name
10
+ # @option options [String] :product_name The product name
11
+ # @option options [String] :platform The product's platform
12
+ # @option options [String] :version Version number
13
+ # @option options [String] :build_number Build number
14
+ # @option options [String] :data (Today) The date for the file
15
+ # @option options [String] :suffix Suffix to identify what this output is (e.g. SOURCE, UAT, QA, DEV)
16
+ # @return [String] A filename formatted such as "Apadmi-Grout-Ruby-v1.0.0(2921)-2021-06-22-DEV"
17
+ def self.binary_output_filename(options = {})
18
+ client_name = options[:client_name]
19
+ raise ":client_name shouldn't be empty" if client_name.blank?
20
+
21
+ product_name = options[:product_name]
22
+ raise ":product_name shouldn't be empty" if product_name.blank?
23
+
24
+ platform = options[:platform]
25
+ raise ":platform shouldn't be empty" if platform.blank?
26
+
27
+ version = options[:version]
28
+ raise ":version shouldn't be empty" if version.blank?
29
+
30
+ build_number = options[:build_number]
31
+ raise ":build_number shouldn't be empty" if build_number.blank?
32
+
33
+ date = options[:date] || Time.now.strftime("%Y-%m-%d")
34
+ suffix = ("-#{options[:suffix]}" unless options[:suffix].blank?) || ""
35
+
36
+ "#{client_name}-#{product_name}-#{platform}-v#{version}(#{build_number})-#{date}#{suffix}"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+
5
+ module Apadmi
6
+ module Grout
7
+ # Generic Git related utils
8
+ class GitUtils
9
+ # Gets the root of the Git repo we're in
10
+ # @return [String] The full path for the root of this Git repo
11
+ def self.git_root
12
+ stdout, stderr, = Open3.capture3("git rev-parse --show-toplevel")
13
+ raise "Failed to get git root: #{stderr}" unless stderr.strip.empty?
14
+
15
+ stdout.strip
16
+ end
17
+
18
+ # Gets the number of commits accessible from HEAD treating the history as a graph.
19
+ # See more details here: https://git-scm.com/docs/git-rev-list
20
+ # @return [String] The number of commits
21
+ def self.number_of_commits
22
+ stdout, stderr, = Open3.capture3("git rev-list HEAD --count")
23
+ raise "Failed to get commit number: #{stderr}" unless stderr.strip.empty?
24
+
25
+ stdout.strip
26
+ end
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Apadmi
4
4
  module Grout
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
data/lib/apadmi_grout.rb CHANGED
@@ -16,5 +16,8 @@ require_relative "apadmi/grout/jira/wrapper/jira_wrapper"
16
16
  require_relative "apadmi/grout/jira/models/pull_request"
17
17
  require_relative "apadmi/grout/jira/models/version"
18
18
  require_relative "apadmi/grout/jira/models/flag_messages"
19
+ require_relative "apadmi/grout/jira/models/find_tickets_options"
19
20
 
20
21
  require_relative "apadmi/grout/utils/logger"
22
+ require_relative "apadmi/grout/utils/git_utils"
23
+ require_relative "apadmi/grout/utils/filename_utils"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apadmi_grout
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-09 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -66,6 +66,7 @@ files:
66
66
  - lib/apadmi/grout/di.rb
67
67
  - lib/apadmi/grout/jira/actions/find_tickets_to_move_action.rb
68
68
  - lib/apadmi/grout/jira/actions/move_jira_tickets_action.rb
69
+ - lib/apadmi/grout/jira/models/find_tickets_options.rb
69
70
  - lib/apadmi/grout/jira/models/flag_messages.rb
70
71
  - lib/apadmi/grout/jira/models/pull_request.rb
71
72
  - lib/apadmi/grout/jira/models/version.rb
@@ -74,6 +75,8 @@ files:
74
75
  - lib/apadmi/grout/release_notes/actions/issues_from_changelog_action.rb
75
76
  - lib/apadmi/grout/release_notes/models/release_notes_config.rb
76
77
  - lib/apadmi/grout/release_notes/models/release_notes_templates.rb
78
+ - lib/apadmi/grout/utils/filename_utils.rb
79
+ - lib/apadmi/grout/utils/git_utils.rb
77
80
  - lib/apadmi/grout/utils/logger.rb
78
81
  - lib/apadmi/grout/version.rb
79
82
  - lib/apadmi_grout.rb