jira-auto-tool 1.2.4 → 1.3.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/.ruby-version +1 -0
- data/features/configure_environment.feature +1 -1
- data/features/control_http_request_rate_limit.feature +8 -2
- data/lib/jira/auto/tool/project/ticket_fields.rb +6 -6
- data/lib/jira/auto/tool/rate_limited_jira_client.rb +3 -3
- data/lib/jira/auto/tool/ticket.rb +18 -3
- data/lib/jira/auto/tool/version.rb +1 -1
- data/lib/jira/auto/tool.rb +1 -2
- data/spec/jira/auto/tool/ticket_fields_spec.rb +63 -0
- data/spec/jira/auto/tool_spec.rb +1 -3
- data/spec/spec_helper.rb +2 -2
- metadata +19 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01e73565bdbb82263685fcd3f903a96f53606fd2a742dcd7baf290767535e231
|
|
4
|
+
data.tar.gz: 6caf206fb9f7754362edf4ec3fd1c2c85ba82f13a95711f8716e968b63deb85e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f195ea5c9cbeb1a525cc3b9684d71f0a791b05935510f221bfc347b173165abc70598ceacf01918cee660172f385a9ed1ac824aaeecaa78d4cc6894683a6cf5
|
|
7
|
+
data.tar.gz: 807721d720cde7b2142a8c5cae279ea20fe857d79a107e90efa62742f8fa5cb298a5cde6333463085cd00ac6e702101237d4ec0b421d923f2e0e90e65c934952
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.4.8
|
|
@@ -205,7 +205,7 @@ Feature: Environment Configuration Management
|
|
|
205
205
|
When I run `jira-auto-tool --env-list`
|
|
206
206
|
Then it should fail with:
|
|
207
207
|
"""
|
|
208
|
-
ERROR Jira::Auto::Tool::EnvironmentLoader : ./jira-auto-tool.env.yaml.erb:6: failed to load with the following error:
|
|
208
|
+
ERROR Jira::Auto::Tool::EnvironmentLoader : ./jira-auto-tool.env.yaml.erb:6: failed to load with the following error: (RuntimeError)
|
|
209
209
|
This is meant to fail while loading!
|
|
210
210
|
"""
|
|
211
211
|
|
|
@@ -4,7 +4,13 @@ Feature: Control the HTTP request rate limit
|
|
|
4
4
|
I need the ability to control the HTTP request limit
|
|
5
5
|
|
|
6
6
|
Scenario Outline: Limiting the request rate
|
|
7
|
-
Given
|
|
7
|
+
Given a Jira Scrum board
|
|
8
|
+
And the board only has the following sprints:
|
|
9
|
+
| name | length | start_date | state |
|
|
10
|
+
| ART-16_CRM_24.4.1 | 2-week | 2024-12-01 11:00:00 UTC | closed |
|
|
11
|
+
| ART-16_E2E-Test_24.4.2 | 4-day | 2024-12-05 11:00:00 UTC | future |
|
|
12
|
+
| ART-32_Platform_24.4.7 | 3-week | 2024-10-07 11:00:00 UTC | future |
|
|
13
|
+
And the following environment variables are set:
|
|
8
14
|
| name | value |
|
|
9
15
|
| JAT_RATE_INTERVAL_IN_SECONDS | <rate_interval_in_seconds> |
|
|
10
16
|
| JAT_RATE_LIMIT_IMPLEMENTATION | <jat_rate_limit_implementation> |
|
|
@@ -14,7 +20,7 @@ Feature: Control the HTTP request rate limit
|
|
|
14
20
|
Examples:
|
|
15
21
|
| jat_rate_limit_implementation | rate_limit_per_interval | rate_interval_in_seconds | minimal_time | maximal_time |
|
|
16
22
|
| | 0 | 0 | 0 | 5 |
|
|
17
|
-
| in_process | 1 |
|
|
23
|
+
| in_process | 1 | 1 | 1 | 20 |
|
|
18
24
|
| redis | 1 | 2 | 1 | 20 |
|
|
19
25
|
| redis | 1 | 10 | 18 | 120 |
|
|
20
26
|
|
|
@@ -39,12 +39,12 @@ module Jira
|
|
|
39
39
|
def each_issue_type_field
|
|
40
40
|
tool.jira_client.Createmeta.all({ projectKeys: project.key, "expand" => "projects.issuetypes.fields" })
|
|
41
41
|
.each do |createmeta|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
createmeta.attrs["issuetypes"].each do |issue_type|
|
|
43
|
+
issue_type_name = issue_type["name"]
|
|
44
|
+
issue_type["fields"].each_value do |field|
|
|
45
|
+
yield(issue_type_name, field)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -33,11 +33,11 @@ module Jira
|
|
|
33
33
|
|
|
34
34
|
alias original_request request
|
|
35
35
|
|
|
36
|
-
def request(*
|
|
36
|
+
def request(*)
|
|
37
37
|
if rate_limit_per_interval == NO_RATE_LIMIT_PER_INTERVAL
|
|
38
|
-
original_request(*
|
|
38
|
+
original_request(*)
|
|
39
39
|
else
|
|
40
|
-
rate_limit { original_request(*
|
|
40
|
+
rate_limit { original_request(*) }
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -42,8 +42,23 @@ module Jira
|
|
|
42
42
|
%i[key summary sprint implementation_team expected_start_date]
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
# Compatibility helper to access Issue fields across Jira API versions
|
|
46
|
+
# - jira-ruby v2: JIRA::Resource::Issue responds to #fields
|
|
47
|
+
# - jira-ruby v3: fields are nested under #attrs['fields']
|
|
48
|
+
def ticket_fields
|
|
49
|
+
if jira_ticket.respond_to?(:fields)
|
|
50
|
+
jira_ticket.fields
|
|
51
|
+
else
|
|
52
|
+
raise "attrs not found in #{jira_ticket}!" unless jira_ticket.respond_to?(:attrs)
|
|
53
|
+
|
|
54
|
+
attrs = jira_ticket.attrs
|
|
55
|
+
attrs["fields"] || attrs[:fields] ||
|
|
56
|
+
raise("fields not found in #{attrs} from #{jira_ticket}!")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
45
60
|
def sprint
|
|
46
|
-
|
|
61
|
+
ticket_fields.fetch(tool.jira_sprint_field.id)
|
|
47
62
|
end
|
|
48
63
|
|
|
49
64
|
def jira_client
|
|
@@ -96,8 +111,8 @@ module Jira
|
|
|
96
111
|
def jira_field_value(field_id = caller_locations(1, 1).first.base_label)
|
|
97
112
|
log.debug { "jira_field_value(#{field_id})" }
|
|
98
113
|
|
|
99
|
-
field =
|
|
100
|
-
raise "#{id}: value not found in #{
|
|
114
|
+
field = ticket_fields.fetch(field_id) do |id|
|
|
115
|
+
raise "#{id}: value not found in #{ticket_fields}"
|
|
101
116
|
end
|
|
102
117
|
|
|
103
118
|
log.debug { "jira_field_value(#{field_id}), field: #{field}" }
|
data/lib/jira/auto/tool.rb
CHANGED
|
@@ -160,7 +160,6 @@ module Jira
|
|
|
160
160
|
].collect { |value_name| [value_name, !HOLDS_A_SECRET] }).freeze
|
|
161
161
|
|
|
162
162
|
ENVIRONMENT_BASED_VALUE_SYMBOLS.each do |method_name, holds_a_secret|
|
|
163
|
-
holds_a_secret ||= false
|
|
164
163
|
define_overridable_environment_based_value(method_name, holds_a_secret)
|
|
165
164
|
end
|
|
166
165
|
|
|
@@ -209,7 +208,7 @@ module Jira
|
|
|
209
208
|
end
|
|
210
209
|
|
|
211
210
|
def tickets(jql = "project = #{project.key}")
|
|
212
|
-
jira_client.Issue.jql(jql).collect { |jira_ticket| Ticket.new(self, jira_ticket) }
|
|
211
|
+
jira_client.Issue.jql(jql, fields: ["*all"]).collect { |jira_ticket| Ticket.new(self, jira_ticket) }
|
|
213
212
|
rescue StandardError => e
|
|
214
213
|
raise <<~EOEM
|
|
215
214
|
Error fetching project tickets: Something went wrong:
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# //wsl.localhost/Ubuntu/home/cbroult/work/ruby/jira-auto-tool/features/ticket_fields_spec.rb
|
|
4
|
+
|
|
5
|
+
require "spec_helper"
|
|
6
|
+
require "jira/auto/tool/ticket"
|
|
7
|
+
|
|
8
|
+
module Jira
|
|
9
|
+
module Auto
|
|
10
|
+
class Tool
|
|
11
|
+
RSpec.describe Jira::Auto::Tool::Ticket do
|
|
12
|
+
let(:tool) { instance_double(Tool) }
|
|
13
|
+
|
|
14
|
+
describe "#ticket_fields" do
|
|
15
|
+
context "when JIRA API V2, jira_ticket responds to #fields" do
|
|
16
|
+
let(:jira_ticket_with_fields) do
|
|
17
|
+
jira_resource_double(JIRA::Resource::Issue, fields: { "example_field" => "value" })
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "returns the fields hash" do
|
|
21
|
+
ticket = described_class.new(tool, jira_ticket_with_fields)
|
|
22
|
+
expect(ticket.ticket_fields).to eq({ "example_field" => "value" })
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context "when JIRA API V3, jira_ticket does not respond to #fields but responds to #attrs" do
|
|
27
|
+
let(:jira_ticket_with_attrs) do
|
|
28
|
+
jira_resource_double(JIRA::Resource::Issue, attrs: { "fields" => { "example_field" => "value" } })
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
let(:jira_ticket_with_invalid_attrs) do
|
|
32
|
+
jira_resource_double(JIRA::Resource::Issue, attrs: { "invalid" => "data" })
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "returns the fields hash from attrs" do
|
|
36
|
+
ticket = described_class.new(tool, jira_ticket_with_attrs)
|
|
37
|
+
expect(ticket.ticket_fields).to eq({ "example_field" => "value" })
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "raises an error if fields are not found in attrs" do
|
|
41
|
+
ticket = described_class.new(tool, jira_ticket_with_invalid_attrs)
|
|
42
|
+
expect do
|
|
43
|
+
ticket.ticket_fields
|
|
44
|
+
end
|
|
45
|
+
.to raise_error("fields not found in {\"invalid\" => \"data\"} from #{jira_ticket_with_invalid_attrs}!")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context "when jira_ticket does not respond to #fields or #attrs" do
|
|
50
|
+
let(:jira_ticket_without_fields_or_attrs) { jira_resource_double(JIRA::Resource::Issue) }
|
|
51
|
+
|
|
52
|
+
it "raises an error indicating attrs are not found" do
|
|
53
|
+
ticket = described_class.new(tool, jira_ticket_without_fields_or_attrs)
|
|
54
|
+
expect do
|
|
55
|
+
ticket.ticket_fields
|
|
56
|
+
end.to raise_error("attrs not found in #{jira_ticket_without_fields_or_attrs}!")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/spec/jira/auto/tool_spec.rb
CHANGED
|
@@ -230,8 +230,6 @@ module Jira
|
|
|
230
230
|
end
|
|
231
231
|
|
|
232
232
|
described_class::ENVIRONMENT_BASED_VALUE_SYMBOLS.each do |method_name, holds_a_secret|
|
|
233
|
-
holds_a_secret ||= false
|
|
234
|
-
|
|
235
233
|
describe "environment based values - #{method_name} - holds_a_secret = #{holds_a_secret}}" do
|
|
236
234
|
let(:object_with_overridable_value) { tool }
|
|
237
235
|
|
|
@@ -435,7 +433,7 @@ module Jira
|
|
|
435
433
|
allow(tool)
|
|
436
434
|
.to receive_messages(project: jira_resource_double(JIRA::Resource::Project, key: "project_key"))
|
|
437
435
|
|
|
438
|
-
allow(query).to receive(:jql).with(expected_jql).and_return([instance_double(JIRA::Resource::Issue)])
|
|
436
|
+
allow(query).to receive(:jql).with(expected_jql, fields: ["*all"]).and_return([instance_double(JIRA::Resource::Issue)])
|
|
439
437
|
end
|
|
440
438
|
|
|
441
439
|
context "without arguments" do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -33,9 +33,9 @@ RSpec.configure do |config|
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
config.include(Module.new do
|
|
36
|
-
def jira_resource_double(*
|
|
36
|
+
def jira_resource_double(*)
|
|
37
37
|
# rubocop:disable RSpec/VerifiedDoubles
|
|
38
|
-
double(*
|
|
38
|
+
double(*)
|
|
39
39
|
# rubocop:enable RSpec/VerifiedDoubles
|
|
40
40
|
end
|
|
41
41
|
end)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jira-auto-tool
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christophe Broult
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: cgi
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
26
40
|
- !ruby/object:Gem::Dependency
|
|
27
41
|
name: http_logger
|
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -214,6 +228,7 @@ extra_rdoc_files: []
|
|
|
214
228
|
files:
|
|
215
229
|
- ".rspec"
|
|
216
230
|
- ".rubocop.yml"
|
|
231
|
+
- ".ruby-version"
|
|
217
232
|
- CHANGELOG.md
|
|
218
233
|
- CODE_OF_CONDUCT.md
|
|
219
234
|
- Guardfile
|
|
@@ -357,6 +372,7 @@ files:
|
|
|
357
372
|
- spec/jira/auto/tool/team_spec.rb
|
|
358
373
|
- spec/jira/auto/tool/team_sprint_prefix_mapper_spec.rb
|
|
359
374
|
- spec/jira/auto/tool/team_sprint_ticket_dispatcher_spec.rb
|
|
375
|
+
- spec/jira/auto/tool/ticket_fields_spec.rb
|
|
360
376
|
- spec/jira/auto/tool/ticket_spec.rb
|
|
361
377
|
- spec/jira/auto/tool/until_date_spec.rb
|
|
362
378
|
- spec/jira/auto/tool_spec.rb
|
|
@@ -377,14 +393,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
377
393
|
requirements:
|
|
378
394
|
- - ">="
|
|
379
395
|
- !ruby/object:Gem::Version
|
|
380
|
-
version: 3.
|
|
396
|
+
version: 3.4.8
|
|
381
397
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
382
398
|
requirements:
|
|
383
399
|
- - ">="
|
|
384
400
|
- !ruby/object:Gem::Version
|
|
385
401
|
version: '0'
|
|
386
402
|
requirements: []
|
|
387
|
-
rubygems_version:
|
|
403
|
+
rubygems_version: 4.0.3
|
|
388
404
|
specification_version: 4
|
|
389
405
|
summary: Automate making adjustments to Jira sprints for multiple teams following
|
|
390
406
|
some naming conventions.
|