gitlab-triage 0.0.3 → 0.1.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/.gitlab-ci.yml +8 -13
- data/README.md +279 -7
- data/bin/gitlab-triage +10 -0
- data/lib/gitlab/triage/network.rb +6 -1
- data/lib/gitlab/triage/version.rb +1 -1
- data/support/.gitlab-ci.example.yml +22 -0
- data/support/.triage-policies.example.yml +19 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b9611f0a3f4f58779cf16cfa76d2dc93889646dc7566b8dc75116838f362940
|
4
|
+
data.tar.gz: 6d8c4675ead2c209ab18df6f8bb6068cf9c2a80f262d7d6759921f90679f1e47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 521a204ed0b650f6f31d8cb78583525ea58f2fb9378db976bf1a1e42af3a58b475480c8128cc59f43fdf065214e23557356502c4ee2340d444806fe56a3cfe33
|
7
|
+
data.tar.gz: a9d972bdd97dc71c4759849ec6b17a6a0f1f0bfc634c3aaf9c895b1f5e7e53a119642ebad19b39ffb156a583efaf06c0ce6a5b5cfb6f27cb384fc963252e215b
|
data/.gitlab-ci.yml
CHANGED
@@ -54,15 +54,6 @@ specs:
|
|
54
54
|
script:
|
55
55
|
- bundle exec rake spec
|
56
56
|
|
57
|
-
build:
|
58
|
-
<<: *pull-cache
|
59
|
-
stage: test
|
60
|
-
script:
|
61
|
-
- bundle exec rake build
|
62
|
-
- bundle exec rake clobber
|
63
|
-
except:
|
64
|
-
- schedules
|
65
|
-
|
66
57
|
codequality:
|
67
58
|
<<: *pull-cache
|
68
59
|
image: docker:latest
|
@@ -94,7 +85,9 @@ dry-run:bin:gitlab-org/triage:
|
|
94
85
|
<<: *pull-cache
|
95
86
|
stage: triage
|
96
87
|
script:
|
97
|
-
- bundle exec
|
88
|
+
- bundle exec rake install:local
|
89
|
+
- gitlab-triage --help
|
90
|
+
- gitlab-triage --dry-run --token $API_TOKEN --project-id $CI_PROJECT_PATH
|
98
91
|
except:
|
99
92
|
- schedules
|
100
93
|
|
@@ -102,7 +95,9 @@ dry-run:bin:gitlab-org/gitlab-ce:
|
|
102
95
|
<<: *pull-cache
|
103
96
|
stage: triage
|
104
97
|
script:
|
105
|
-
- bundle exec
|
98
|
+
- bundle exec rake install:local
|
99
|
+
- gitlab-triage --help
|
100
|
+
- gitlab-triage --dry-run --token $API_TOKEN --project-id gitlab-org/gitlab-ce
|
106
101
|
when: manual
|
107
102
|
except:
|
108
103
|
- schedules
|
@@ -113,7 +108,7 @@ dry-run:gem:gitlab-org/triage:
|
|
113
108
|
script:
|
114
109
|
- gem install gitlab-triage
|
115
110
|
- gitlab-triage --help
|
116
|
-
- gitlab-triage --dry-run --token $API_TOKEN --project-id
|
111
|
+
- gitlab-triage --dry-run --token $API_TOKEN --project-id $CI_PROJECT_PATH
|
117
112
|
when: manual
|
118
113
|
except:
|
119
114
|
- schedules
|
@@ -133,6 +128,6 @@ run:triage:triage:
|
|
133
128
|
stage: triage
|
134
129
|
script:
|
135
130
|
- gem install gitlab-triage
|
136
|
-
- gitlab-triage --token $API_TOKEN --project-id
|
131
|
+
- gitlab-triage --token $API_TOKEN --project-id $CI_PROJECT_PATH
|
137
132
|
only:
|
138
133
|
- schedules
|
data/README.md
CHANGED
@@ -1,13 +1,285 @@
|
|
1
1
|
[](https://gitlab.com/gitlab-org/triage/commits/master)
|
2
2
|
|
3
|
-
|
3
|
+
# GitLab Triage Project
|
4
4
|
|
5
|
-
This project contains
|
6
|
-
The scripts found here may be useful for triaging issues in other projects too.
|
5
|
+
This project contains the library and pipeline definition to enable automated triaging of issues in the [GitLab-CE Project](https://gitlab.com/gitlab-org/gitlab-ce).
|
7
6
|
|
8
|
-
-
|
9
|
-
- We use scheduled pipelines to run the scripts to enforce our policies on a daily basis.
|
7
|
+
## gitlab-triage gem
|
10
8
|
|
11
|
-
|
9
|
+
### Summary
|
12
10
|
|
13
|
-
|
11
|
+
The `gitlab-triage` gem aims to enable project managers and maintainers to automatically triage Issues and Merge Requests in GitLab projects based on defined policies.
|
12
|
+
|
13
|
+
### What is a triage policy?
|
14
|
+
|
15
|
+
Triage policies are defined on a resource level basis, resources being:
|
16
|
+
- Issues
|
17
|
+
- Merge Requests
|
18
|
+
|
19
|
+
Each policy can declare a number of conditions that must all be satisfied before a number of actions are carried out.
|
20
|
+
|
21
|
+
### Defining a policy
|
22
|
+
|
23
|
+
Policies are defined in a policy file (by default [.triage-policies.yml](.triage-policies.yml)). The format of the file is [YAML](https://en.wikipedia.org/wiki/YAML).
|
24
|
+
|
25
|
+
> Note: You can use the [`--init`](#usage) option to add an example [`.triage-policies.yml` file](support/.triage-policies.example.yml) to your project
|
26
|
+
|
27
|
+
Select which resource to add the policy to:
|
28
|
+
- `issues`
|
29
|
+
- `merge_requests`
|
30
|
+
|
31
|
+
And create an array of `rules` to define your policies:
|
32
|
+
|
33
|
+
For example:
|
34
|
+
|
35
|
+
```yml
|
36
|
+
resource_rules:
|
37
|
+
issues:
|
38
|
+
rules:
|
39
|
+
- name: My policy
|
40
|
+
conditions:
|
41
|
+
date:
|
42
|
+
attribute: updated_at
|
43
|
+
condition: older_than
|
44
|
+
interval_type: days
|
45
|
+
interval: 5
|
46
|
+
state: opened
|
47
|
+
label:
|
48
|
+
- No label
|
49
|
+
actions:
|
50
|
+
labels:
|
51
|
+
- needs attention
|
52
|
+
mention:
|
53
|
+
- markglenfletcher
|
54
|
+
comment: |
|
55
|
+
This issue is unlabelled after 5 days. It needs attention.
|
56
|
+
merge_requests:
|
57
|
+
rules:
|
58
|
+
[]
|
59
|
+
```
|
60
|
+
|
61
|
+
### Fields
|
62
|
+
|
63
|
+
A policy consists of the following fields:
|
64
|
+
- [Name field](#name-field)
|
65
|
+
- [Conditions field](#conditions-field)
|
66
|
+
- [Actions field](#actions-field)
|
67
|
+
|
68
|
+
#### Name field
|
69
|
+
|
70
|
+
The name field is used to describe the purpose of the individual policy.
|
71
|
+
|
72
|
+
Example:
|
73
|
+
|
74
|
+
```yml
|
75
|
+
name: Policy name
|
76
|
+
```
|
77
|
+
|
78
|
+
#### Conditions field
|
79
|
+
|
80
|
+
Used to declare a condition that must be satisfied by a resource before actions will be taken.
|
81
|
+
|
82
|
+
Available condition types:
|
83
|
+
- [`date` condition](#date-condition)
|
84
|
+
- [`milestone` condition](#milestone-condition)
|
85
|
+
- [`state` condition](#state-condition)
|
86
|
+
- [`upvotes` condition](#upvotes-condition)
|
87
|
+
- [`labels` condition](#labels-condition)
|
88
|
+
|
89
|
+
##### Date condition
|
90
|
+
|
91
|
+
Accepts a hash of fields.
|
92
|
+
|
93
|
+
| Field | Type | Values | Required |
|
94
|
+
| --------- | ---- | ---- | -------- |
|
95
|
+
| `attribute` | string | `created_at`, `updated_at` | yes |
|
96
|
+
| `condition` | string | `older_than`, `newer_than` | yes |
|
97
|
+
| `interval_type` | string | `days`, `weeks`, `months`, `years` | yes |
|
98
|
+
| `interval` | integer | integer | yes |
|
99
|
+
|
100
|
+
Example:
|
101
|
+
|
102
|
+
```yml
|
103
|
+
conditions:
|
104
|
+
date:
|
105
|
+
attribute: updated_at
|
106
|
+
condition: older_than
|
107
|
+
interval_type: months
|
108
|
+
interval: 12
|
109
|
+
```
|
110
|
+
|
111
|
+
##### Milestone condition
|
112
|
+
|
113
|
+
Accepts an array of strings. Each element is the name of a milestone to filter upon.
|
114
|
+
|
115
|
+
> Note: **All** specified milestones must be present on the resource for the condition to be satisfied
|
116
|
+
|
117
|
+
Example:
|
118
|
+
|
119
|
+
```yml
|
120
|
+
conditions:
|
121
|
+
milestone:
|
122
|
+
- v1
|
123
|
+
- v2
|
124
|
+
```
|
125
|
+
|
126
|
+
##### State condition
|
127
|
+
|
128
|
+
Accepts a string.
|
129
|
+
|
130
|
+
| State | Type | Value |
|
131
|
+
| --------- | ---- | ------ |
|
132
|
+
| Closed issues | string | `closed` |
|
133
|
+
| Open issues | string | `opened` |
|
134
|
+
|
135
|
+
Example:
|
136
|
+
|
137
|
+
```yml
|
138
|
+
conditions:
|
139
|
+
state: opened
|
140
|
+
```
|
141
|
+
|
142
|
+
##### Upvotes condition
|
143
|
+
|
144
|
+
Accepts a hash of fields.
|
145
|
+
|
146
|
+
| Field | Type | Values | Required |
|
147
|
+
| --------- | ---- | ---- | -------- |
|
148
|
+
| `attribute` | string | `upvotes`, `downvotes` | yes |
|
149
|
+
| `condition` | string | `less_than`, `greater_than` | yes |
|
150
|
+
| `threshold` | integer | integer | yes |
|
151
|
+
|
152
|
+
Example:
|
153
|
+
|
154
|
+
```yml
|
155
|
+
conditions:
|
156
|
+
upvotes:
|
157
|
+
attribute: upvotes
|
158
|
+
condition: less_than
|
159
|
+
threshold: 10
|
160
|
+
```
|
161
|
+
|
162
|
+
##### Labels condition
|
163
|
+
|
164
|
+
Accepts an array of strings. Each element in the array represents the name of a label to filter on.
|
165
|
+
|
166
|
+
> Note: **All** specified labels must be present on the resource for the condition to be satisfied
|
167
|
+
|
168
|
+
Example:
|
169
|
+
|
170
|
+
```yml
|
171
|
+
conditions:
|
172
|
+
labels:
|
173
|
+
- feature proposal
|
174
|
+
```
|
175
|
+
|
176
|
+
#### Actions field
|
177
|
+
|
178
|
+
Used to declare an action to be carried out on a resource if **all** conditions are satisfied.
|
179
|
+
|
180
|
+
Available action types:
|
181
|
+
- [`label` action](#label-action)
|
182
|
+
- [`status` action](#status-action)
|
183
|
+
- [`mention` action](#mention-action)
|
184
|
+
- [`comment` action](#comment-action)
|
185
|
+
|
186
|
+
##### Label action
|
187
|
+
|
188
|
+
Adds a number of labels to the resource.
|
189
|
+
|
190
|
+
Accepts an array of strings. Each element is the name of a label to add.
|
191
|
+
|
192
|
+
Example:
|
193
|
+
|
194
|
+
```yml
|
195
|
+
actions:
|
196
|
+
label:
|
197
|
+
- feature proposal
|
198
|
+
- awaiting feedback
|
199
|
+
```
|
200
|
+
|
201
|
+
##### Status action
|
202
|
+
|
203
|
+
Changes the status of the resource.
|
204
|
+
|
205
|
+
Accepts a string.
|
206
|
+
|
207
|
+
| State transition | Type | Value |
|
208
|
+
| --------- | ---- | ------ |
|
209
|
+
| Close the resource | string | `close` |
|
210
|
+
| Reopen the resource | string | `reopen` |
|
211
|
+
|
212
|
+
Example:
|
213
|
+
|
214
|
+
```yml
|
215
|
+
actions:
|
216
|
+
status: close
|
217
|
+
```
|
218
|
+
|
219
|
+
##### Mention action
|
220
|
+
|
221
|
+
Mentions a number of users.
|
222
|
+
|
223
|
+
Accepts an array of strings. Each element is the username of a user to mention.
|
224
|
+
|
225
|
+
Example:
|
226
|
+
|
227
|
+
```yml
|
228
|
+
actions:
|
229
|
+
mention:
|
230
|
+
- rymai
|
231
|
+
- markglenfletcher
|
232
|
+
```
|
233
|
+
|
234
|
+
##### Comment action
|
235
|
+
|
236
|
+
Adds a comment to the resource.
|
237
|
+
|
238
|
+
Accepts a string.
|
239
|
+
|
240
|
+
Example:
|
241
|
+
|
242
|
+
```yml
|
243
|
+
actions:
|
244
|
+
comment: |
|
245
|
+
Closing this issue automatically
|
246
|
+
```
|
247
|
+
|
248
|
+
### Usage
|
249
|
+
|
250
|
+
```
|
251
|
+
Usage: gitlab-triage [options]
|
252
|
+
|
253
|
+
-n, --dry-run Don't actually update anything, just print
|
254
|
+
-f, --policies-file [string] A valid policies YML file
|
255
|
+
-p, --project-id [string] A project ID or path
|
256
|
+
-t, --token [string] A valid API token
|
257
|
+
-d, --debug Print debug information
|
258
|
+
-h, --help Print help message
|
259
|
+
--init Initialize the project with a policy file
|
260
|
+
--init-ci Initialize the project with a .gitlab-ci.yml file
|
261
|
+
```
|
262
|
+
|
263
|
+
#### Local
|
264
|
+
|
265
|
+
```
|
266
|
+
gem install gitlab-triage
|
267
|
+
gitlab-triage --help
|
268
|
+
gitlab-triage --dry-run --token $API_TOKEN --project-id gitlab-org/triage
|
269
|
+
```
|
270
|
+
|
271
|
+
#### GitLab CI pipeline
|
272
|
+
|
273
|
+
You can enforce policies using a scheduled pipeline:
|
274
|
+
|
275
|
+
```yml
|
276
|
+
run:triage:triage:
|
277
|
+
stage: triage
|
278
|
+
script:
|
279
|
+
- gem install gitlab-triage
|
280
|
+
- gitlab-triage --token $API_TOKEN --project-id $CI_PROJECT_PATH
|
281
|
+
only:
|
282
|
+
- schedules
|
283
|
+
```
|
284
|
+
|
285
|
+
> Note: You can use the [`--init-ci`](#usage) option to add an example [`.gitlab-ci.yml` file](support/.gitlab-ci.example.yml) to your project
|
data/bin/gitlab-triage
CHANGED
@@ -44,6 +44,16 @@ class TriageOptionParser
|
|
44
44
|
$stdout.puts opts
|
45
45
|
exit
|
46
46
|
end
|
47
|
+
|
48
|
+
opts.on('--init', 'Initialize the project with a policy file') do
|
49
|
+
FileUtils.cp('./support/.triage-policies.example.yml', './.triage-policies.yml')
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('--init-ci', 'Initialize the project with a .gitlab-ci.yml file') do
|
54
|
+
FileUtils.cp('./support/.gitlab-ci.example.yml', './.gitlab-ci.yml')
|
55
|
+
exit
|
56
|
+
end
|
47
57
|
end
|
48
58
|
|
49
59
|
parser.parse!(argv)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
image: ruby:2.4
|
2
|
+
|
3
|
+
stages:
|
4
|
+
- triage
|
5
|
+
|
6
|
+
dry-run:triage:
|
7
|
+
stage: triage
|
8
|
+
script:
|
9
|
+
- gem install gitlab-triage
|
10
|
+
- gitlab-triage --help
|
11
|
+
- gitlab-triage --dry-run --token $API_TOKEN --project-id $CI_PROJECT_PATH
|
12
|
+
when: manual
|
13
|
+
except:
|
14
|
+
- schedules
|
15
|
+
|
16
|
+
run:triage:
|
17
|
+
stage: triage
|
18
|
+
script:
|
19
|
+
- gem install gitlab-triage
|
20
|
+
- gitlab-triage --token $API_TOKEN --project-id $CI_PROJECT_PATH
|
21
|
+
only:
|
22
|
+
- schedules
|
@@ -0,0 +1,19 @@
|
|
1
|
+
resource_rules:
|
2
|
+
issues:
|
3
|
+
rules:
|
4
|
+
- name: Comment 1 week old, unlabelled issues
|
5
|
+
conditions:
|
6
|
+
date:
|
7
|
+
attribute: created_at
|
8
|
+
condition: older_than
|
9
|
+
interval_type: week
|
10
|
+
interval: 1
|
11
|
+
labels:
|
12
|
+
- No label
|
13
|
+
state: opened
|
14
|
+
actions:
|
15
|
+
comment: |
|
16
|
+
This issue has been open for one week and is unlabelled
|
17
|
+
merge_requests:
|
18
|
+
rules:
|
19
|
+
[]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-triage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -135,6 +135,8 @@ files:
|
|
135
135
|
- lib/gitlab/triage/ui.rb
|
136
136
|
- lib/gitlab/triage/url_builders/url_builder.rb
|
137
137
|
- lib/gitlab/triage/version.rb
|
138
|
+
- support/.gitlab-ci.example.yml
|
139
|
+
- support/.triage-policies.example.yml
|
138
140
|
homepage: https://gitlab.com/gitlab-org/triage
|
139
141
|
licenses:
|
140
142
|
- MIT
|