gitlab-triage 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +19 -0
  3. data/.gitignore +15 -0
  4. data/.gitlab-ci.yml +101 -0
  5. data/.gitlab/issue_templates/Policy.md +32 -0
  6. data/.rubocop.yml +6 -0
  7. data/Gemfile +4 -0
  8. data/Guardfile +70 -0
  9. data/README.md +13 -0
  10. data/Rakefile +6 -0
  11. data/bin/gitlab-triage +63 -0
  12. data/gitlab-triage.gemspec +29 -0
  13. data/lib/gitlab/triage.rb +6 -0
  14. data/lib/gitlab/triage/command_builders/base_command_builder.rb +32 -0
  15. data/lib/gitlab/triage/command_builders/cc_command_builder.rb +19 -0
  16. data/lib/gitlab/triage/command_builders/comment_command_builder.rb +23 -0
  17. data/lib/gitlab/triage/command_builders/label_command_builder.rb +19 -0
  18. data/lib/gitlab/triage/command_builders/status_command_builder.rb +23 -0
  19. data/lib/gitlab/triage/engine.rb +146 -0
  20. data/lib/gitlab/triage/filter_builders/base_filter_builder.rb +18 -0
  21. data/lib/gitlab/triage/filter_builders/multi_filter_builder.rb +20 -0
  22. data/lib/gitlab/triage/filter_builders/single_filter_builder.rb +13 -0
  23. data/lib/gitlab/triage/limiters/base_conditions_limiter.rb +65 -0
  24. data/lib/gitlab/triage/limiters/date_conditions_limiter.rb +63 -0
  25. data/lib/gitlab/triage/limiters/name_conditions_limiter.rb +30 -0
  26. data/lib/gitlab/triage/limiters/votes_conditions_limiter.rb +54 -0
  27. data/lib/gitlab/triage/network.rb +37 -0
  28. data/lib/gitlab/triage/network_adapters/httparty_adapter.rb +36 -0
  29. data/lib/gitlab/triage/network_adapters/test_adapter.rb +31 -0
  30. data/lib/gitlab/triage/retryable.rb +31 -0
  31. data/lib/gitlab/triage/ui.rb +15 -0
  32. data/lib/gitlab/triage/version.rb +5 -0
  33. data/policies.yml +232 -0
  34. metadata +160 -0
@@ -0,0 +1,37 @@
1
+ require 'active_support/all'
2
+ require 'net/protocol'
3
+
4
+ require_relative 'retryable'
5
+
6
+ module Gitlab
7
+ module Triage
8
+ class Network
9
+ include Retryable
10
+
11
+ def initialize(adapter)
12
+ @adapter = adapter
13
+ end
14
+
15
+ def query_api(token, url)
16
+ response = {}
17
+ resources = []
18
+
19
+ begin
20
+ print '.'
21
+ response = execute_with_retry(Net::ReadTimeout) do
22
+ @adapter.get(token, response.fetch(:next_page_url) { url })
23
+ end
24
+ resources += response.delete(:results)
25
+ end while response.delete(:more_pages)
26
+
27
+ resources.map!(&:with_indifferent_access)
28
+ rescue Net::ReadTimeout
29
+ []
30
+ end
31
+
32
+ def post_api(token, url, body)
33
+ @adapter.post(token, url, body)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ require 'httparty'
2
+
3
+ module Gitlab
4
+ module Triage
5
+ module NetworkAdapters
6
+ class HttpartyAdapter
7
+ def get(token, url)
8
+ response = HTTParty.get(
9
+ url,
10
+ headers: {
11
+ 'Content-type' => 'application/json',
12
+ 'PRIVATE-TOKEN' => token
13
+ }
14
+ )
15
+
16
+ {
17
+ more_pages: (response.headers["x-next-page"] != ""),
18
+ next_page_url: url + "&page=#{response.headers['x-next-page']}",
19
+ results: response.parsed_response
20
+ }
21
+ end
22
+
23
+ def post(token, url, body)
24
+ HTTParty.post(
25
+ url,
26
+ body: { body: body }.to_json,
27
+ headers: {
28
+ 'Content-type' => 'application/json',
29
+ 'PRIVATE-TOKEN' => token
30
+ }
31
+ )
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,31 @@
1
+ require 'httparty'
2
+
3
+ module Gitlab
4
+ module Triage
5
+ module NetworkAdapters
6
+ class TestAdapter
7
+ def get(_token, url)
8
+ results =
9
+ case url
10
+ when %r{\Ahttps://gitlab.com/v4/issues?per_page=100}
11
+ [
12
+ { id: 1, title: 'First issue' }
13
+ ]
14
+ else
15
+ []
16
+ end
17
+
18
+ {
19
+ more_pages: false,
20
+ next_page_url: nil,
21
+ results: results
22
+ }
23
+ end
24
+
25
+ def post(token, url, body)
26
+ # no-op in tests
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ module Gitlab
2
+ module Triage
3
+ module Retryable
4
+ MAX_RETRIES = 3
5
+
6
+ attr_accessor :tries
7
+
8
+ def execute_with_retry(exception_type = StandardError)
9
+ @tries = 0
10
+
11
+ until maximum_retries_reached?
12
+ begin
13
+ @tries += 1
14
+ result = yield
15
+ break
16
+ rescue exception_type
17
+ raise if maximum_retries_reached?
18
+ end
19
+ end
20
+
21
+ result
22
+ end
23
+
24
+ private
25
+
26
+ def maximum_retries_reached?
27
+ tries == MAX_RETRIES
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ module Gitlab
2
+ module Triage
3
+ class UI
4
+ def self.header(text, char: '=')
5
+ header = char * text.size
6
+
7
+ [header, text, header, nil].join("\n")
8
+ end
9
+
10
+ def self.debug(text)
11
+ "[DEBUG] #{text}"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Gitlab
2
+ module Triage
3
+ VERSION = '0.0.1'.freeze
4
+ end
5
+ end
@@ -0,0 +1,232 @@
1
+ host_url: https://gitlab.com
2
+ api_version: v4
3
+ project_id: 13083
4
+ per_page: 100
5
+ resource_rules:
6
+ issues:
7
+ rules:
8
+ - name: Mark stale issues with no milestone for closure
9
+ conditions:
10
+ date:
11
+ attribute: updated_at
12
+ condition: older_than
13
+ interval_type: months
14
+ interval: 12
15
+ milestone:
16
+ - No Milestone
17
+ state: opened
18
+ actions:
19
+ labels:
20
+ - awaiting feedback
21
+ - auto updated
22
+ mention:
23
+ - markglenfletcher
24
+ comment: |
25
+ Hi,
26
+
27
+ First of all, thank you for raising an issue to help improve the GitLab product. We're sorry about this, but this particular issue has gone unnoticed for quite some time. To establish order in the GitLab-CE Issue Tracker, we must ensure that every issue is correctly labelled and triaged, to get the proper attention.
28
+
29
+ This issue will be closed, as it meets the following criteria:
30
+ * No activity in the past 12 months
31
+ * No milestone (unscheduled)
32
+
33
+ We'd like to ask you to help us out and determine whether this issue should be reopened.
34
+
35
+ If this issue is reporting a bug, please can you attempt to reproduce on the latest version of GitLab or GitLab.com, to help us to understand whether the bug still needs our attention.
36
+
37
+ If this issue is proposing a new feature, please can you verify whether the feature proposal is still relevant.
38
+
39
+ Thanks for your help
40
+ - name: Mark stale issues for closure
41
+ conditions:
42
+ date:
43
+ attribute: updated_at
44
+ condition: older_than
45
+ interval_type: months
46
+ interval: 3
47
+ labels:
48
+ - No Label
49
+ state: opened
50
+ actions:
51
+ labels:
52
+ - awaiting feedback
53
+ - auto updated
54
+ mention:
55
+ - markglenfletcher
56
+ comment: |
57
+ Hi,
58
+
59
+ First of all, thank you for raising an issue to help improve the GitLab product. We're sorry about this, but this particular issue has gone unnoticed for quite some time. To establish order in the GitLab-CE Issue Tracker, we must ensure that every issue is correctly labelled and triaged, to get the proper attention.
60
+
61
+ This issue will be closed, as it meets the following criteria:
62
+ * No activity in the past 3 months
63
+ * Unlabelled
64
+
65
+ We'd like to ask you to help us out and determine whether this issue should be reopened.
66
+
67
+ If this issue is reporting a bug, please can you attempt to reproduce on the latest version of GitLab or GitLab.com, to help us to understand whether the bug still needs our attention.
68
+
69
+ If this issue is proposing a new feature, please can you verify whether the feature proposal is still relevant.
70
+
71
+ Thanks for your help
72
+ - name: Close non-updated issues
73
+ conditions:
74
+ date:
75
+ attribute: updated_at
76
+ condition: older_than
77
+ interval_type: weeks
78
+ interval: 2
79
+ labels:
80
+ - awaiting feedback
81
+ - auto updated
82
+ state: opened
83
+ actions:
84
+ labels:
85
+ - auto closed
86
+ mention:
87
+ - markglenfletcher
88
+ status: close
89
+ comment: |
90
+ Closing this issue down in accordance with our [Issue Triage Policies](https://gitlab.com/gitlab-org/triage). Please reopen the issue if you feel that the issue is still relevant. Thanks!
91
+ - name: Mark potentially interesting feature proposals
92
+ conditions:
93
+ labels:
94
+ - feature proposal
95
+ state: opened
96
+ upvotes:
97
+ attribute: upvotes
98
+ condition: greater_than
99
+ threshold: 10
100
+ milestone:
101
+ - No Milestone
102
+ actions:
103
+ labels:
104
+ - auto updated
105
+ - potential proposal
106
+ mention:
107
+ - markglenfletcher
108
+ comment: |
109
+ In order to get this request some attention, this issue has been marked as a potentially interesting proposal as it meets the following criteria:
110
+
111
+ * Labelled as a feature proposal
112
+ * More than 10 upvotes
113
+ * Unscheduled (not associated with a milestone)
114
+
115
+ Thanks for your proposal!
116
+ - name: Mark unpopular, old feature proposals for closure
117
+ conditions:
118
+ date:
119
+ attribute: updated_at
120
+ condition: older_than
121
+ interval_type: years
122
+ interval: 1
123
+ labels:
124
+ - feature proposal
125
+ state: opened
126
+ upvotes:
127
+ attribute: upvotes
128
+ condition: less_than
129
+ threshold: 10
130
+ milestone:
131
+ - No Milestone
132
+ actions:
133
+ labels:
134
+ - auto updated
135
+ - awaiting feedback
136
+ mention:
137
+ - markglenfletcher
138
+ comment: |
139
+ Hi,
140
+
141
+ First of all, thank you for raising an issue to help improve the GitLab product. This issue was labelled as a ~"feature proposal" in the past. In order to maintain order in the issue tracker, we are starting to close off old, unpopular feature proposals that have not gained many votes since opening.
142
+
143
+ This issue will be closed, as it meets the following criteria:
144
+ * No activity in the past 12 months
145
+ * Labelled as a ~"feature proposal"
146
+ * Unscheduled (not associated with a milestone)
147
+ * Less than 10 upvotes
148
+
149
+ Thanks for your help and please raise any new feature proposals as a new issue.
150
+ - name: Mark very popular, unscheduled feature proposals
151
+ conditions:
152
+ labels:
153
+ - feature proposal
154
+ state: opened
155
+ milestone:
156
+ - No Milestone
157
+ upvotes:
158
+ attribute: upvotes
159
+ condition: greater_than
160
+ threshold: 50
161
+ actions:
162
+ labels:
163
+ - auto updated
164
+ - popular proposal
165
+ - name: Mark stale bugs for closure
166
+ conditions:
167
+ date:
168
+ attribute: updated_at
169
+ condition: older_than
170
+ interval_type: months
171
+ interval: 6
172
+ labels:
173
+ - bug
174
+ milestone:
175
+ - No Milestone
176
+ state: opened
177
+ actions:
178
+ labels:
179
+ - awaiting feedback
180
+ - auto updated
181
+ mention:
182
+ - markglenfletcher
183
+ comment: |
184
+ Hi,
185
+
186
+ First of all, thank you for raising an issue to help improve the GitLab product. We're sorry about this, but this particular issue has gone unnoticed for quite some time. To establish order in the GitLab-CE Issue Tracker, we must ensure that every issue is correctly labelled and triaged, to get the proper attention.
187
+
188
+ This issue will be marked for closure, as it meets the following criteria:
189
+ * Issue is open
190
+ * No activity in the past 6 months
191
+ * Labelled as a bug
192
+ * Unscheduled (no milestone)
193
+
194
+ We'd like to ask you to help us out and determine whether this issue should be reopened.
195
+
196
+ Because this issue is reporting a bug, please can you attempt to reproduce on the latest version of GitLab or on GitLab.com, to help us to understand whether the bug still needs our attention.
197
+
198
+ Thanks for your help
199
+ merge_requests:
200
+ rules:
201
+ - name: Encourage old Community Merge Requests to completion
202
+ conditions:
203
+ date:
204
+ attribute: updated_at
205
+ condition: older_than
206
+ interval_type: months
207
+ interval: 6
208
+ labels:
209
+ - Community Contribution
210
+ state: opened
211
+ actions:
212
+ labels:
213
+ - awaiting feedback
214
+ - auto updated
215
+ mention:
216
+ - rymai
217
+ comment: |
218
+ Hi,
219
+
220
+ First of all, thank you for creating a Merge Request to help improve the GitLab product. We are running through old Merge Requests and asking authors to update their Merge Requests
221
+
222
+ This Merge Request was chosen, as it meets the following criteria:
223
+ * Open
224
+ * Labelled ~"Community Contribution"
225
+ * No activity in the past 6 months
226
+
227
+ We'd like to ask you to help us out and let us know whether:
228
+ * You would like to continue the work here
229
+ * You would like us to take on the Merge Request for you
230
+ * You would like us to close down the Merge Request
231
+
232
+ Thanks for your help
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitlab-triage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - GitLab
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.15'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gitlab-styles
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description:
98
+ email:
99
+ - remy@rymai.me
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".codeclimate.yml"
105
+ - ".gitignore"
106
+ - ".gitlab-ci.yml"
107
+ - ".gitlab/issue_templates/Policy.md"
108
+ - ".rubocop.yml"
109
+ - Gemfile
110
+ - Guardfile
111
+ - README.md
112
+ - Rakefile
113
+ - bin/gitlab-triage
114
+ - gitlab-triage.gemspec
115
+ - lib/gitlab/triage.rb
116
+ - lib/gitlab/triage/command_builders/base_command_builder.rb
117
+ - lib/gitlab/triage/command_builders/cc_command_builder.rb
118
+ - lib/gitlab/triage/command_builders/comment_command_builder.rb
119
+ - lib/gitlab/triage/command_builders/label_command_builder.rb
120
+ - lib/gitlab/triage/command_builders/status_command_builder.rb
121
+ - lib/gitlab/triage/engine.rb
122
+ - lib/gitlab/triage/filter_builders/base_filter_builder.rb
123
+ - lib/gitlab/triage/filter_builders/multi_filter_builder.rb
124
+ - lib/gitlab/triage/filter_builders/single_filter_builder.rb
125
+ - lib/gitlab/triage/limiters/base_conditions_limiter.rb
126
+ - lib/gitlab/triage/limiters/date_conditions_limiter.rb
127
+ - lib/gitlab/triage/limiters/name_conditions_limiter.rb
128
+ - lib/gitlab/triage/limiters/votes_conditions_limiter.rb
129
+ - lib/gitlab/triage/network.rb
130
+ - lib/gitlab/triage/network_adapters/httparty_adapter.rb
131
+ - lib/gitlab/triage/network_adapters/test_adapter.rb
132
+ - lib/gitlab/triage/retryable.rb
133
+ - lib/gitlab/triage/ui.rb
134
+ - lib/gitlab/triage/version.rb
135
+ - policies.yml
136
+ homepage: https://gitlab.com/gitlab-org/triage
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.7.0
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: GitLab triage automation project.
160
+ test_files: []