forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
open-bot.yaml
692 lines (639 loc) · 19.8 KB
/
open-bot.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
bot: "webpack-bot"
rules:
# Add ci-ok, ci-not-ok labels depending on travis status
# comment to point the user to the results
# comment in case of success
- filters:
open: true
pull_request:
mergeable: true
status_1:
context: "continuous-integration/travis-ci/pr"
status_2:
context: "continuous-integration/appveyor/pr"
ensure_1:
value: "{{status_1.state}}"
equals: "success"
ensure_2:
value: "{{status_2.state}}"
equals: "success"
actions:
label:
add: "PR: CI-ok"
remove: "PR: CI-not-ok"
comment:
identifier: "ci-result"
message: |-
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.
- filters:
open: true
pull_request:
mergeable: true
status_1:
context: "continuous-integration/travis-ci/pr"
status_2:
context: "continuous-integration/appveyor/pr"
any:
ensure_1:
value: "{{status_1.state}}"
equals: "failure"
ensure_2:
value: "{{status_2.state}}"
equals: "failure"
not:
any:
ensure_3:
value: "{{status_1.state}}"
equals: "pending"
ensure_4:
value: "{{status_2.state}}"
equals: "pending"
actions:
label:
add: "PR: CI-not-ok"
remove: "PR: CI-ok"
set:
id: report_ci
value: yep
# Report specific error message if jest for basic tests fails
- filters:
ensure:
value: "{{report_ci}}"
equals: yep
commit: true
status:
context: "continuous-integration/travis-ci/pr"
travis_job:
state: "failed"
allow_failure: false
config:
env: JOB_PART=basic
fetch: travis_job.log
string_cleanup:
id: logResult
value: "{{{fetch}}}"
remove:
- ".\\[2K.\\[1G|.\\[999D.\\[K"
- "^[\\s\\S]+?\\$ yarn travis:\\$JOB_PART.*\n"
- "\\$ node --max-old-space-size=4096.*\n"
- ".+rimraf coverage"
- "yarn run.+\n"
- "\\(node:\\d+\\) (\\[DEP0005\\]|DeprecationWarning).+\n"
- "\\$ yarn (cover|test):.+\n"
- "Ran all test suites.\n[\\s\\S]*"
- "error Command failed with exit code \\d+.\n"
- "info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n"
- "Force exiting Jest\n\nHave you considered.+"
- "=============================== Coverage summary ===============================[\\s\\S]+?================================================================================"
- " *PASS *test/.*\n"
- "^\\s+\n|\\s+$"
string_cleanup_1:
id: firstError
value: "{{{logResult}}}"
remove:
- "\n\n( ●| FAIL)[\\s\\S]*"
- "Test Suites:[\\s\\S]*"
- "\\s+$"
string_cleanup_2:
id: remainingErrors
value: "{{{logResult}}}"
remove:
- "^[\\s\\S]+?(?=\n\n( ●| FAIL)|$)"
- "^\n+"
- "Test Suites:[\\s\\S]*"
- "\\s+$"
string_cleanup_3:
id: summary
value: "{{{logResult}}}"
remove:
- "^[\\s\\S]+?(?=Test Suites:)"
- "\\s+$"
actions:
comment:
identifier: "ci-result"
message: |-
The basic integration tests failed.
@{{commit.author.login}} Please review the following output log for errors:
```text
{{{firstError}}}
```
{{#if remainingErrors}}
<details>
<summary>Show remaining errors</summary>
```text
{{{remainingErrors}}}
```
</details>
{{/if}}
```text
{{{summary}}}
```
See [complete report here]({{status.target_url}}).
set:
id: report_ci
value: nope
# Report specific error message if jest for integration tests fails
- filters:
ensure:
value: "{{report_ci}}"
equals: yep
commit: true
status:
context: "continuous-integration/travis-ci/pr"
travis_job:
state: "failed"
allow_failure: false
config:
env: JOB_PART=integration
fetch: travis_job.log
string_cleanup:
id: logResult
value: "{{{fetch}}}"
remove:
- ".\\[2K.\\[1G|.\\[999D.\\[K"
- "^[\\s\\S]+?\\$ yarn travis:\\$JOB_PART.*\n"
- "\\$ node --max-old-space-size=4096.*\n"
- ".+rimraf coverage"
- "yarn run.+\n"
- "\\(node:\\d+\\) (\\[DEP0005\\]|DeprecationWarning).+\n"
- "\\$ yarn (cover|test):.+\n"
- "The command \"yarn travis:\\$JOB_PART\" exited[\\s\\S]*"
- "Ran all test suites.+\n"
- "error Command failed with exit code \\d+.\n"
- "info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n"
- "Force exiting Jest\n\nHave you considered.+"
- "=============================== Coverage summary ===============================[\\s\\S]+?================================================================================"
- " *PASS *test/.*\n"
- "^\\s+\n|\\s+$"
string_cleanup_1:
id: firstError
value: "{{{logResult}}}"
remove:
- "\n\n( ●| FAIL)[\\s\\S]*"
- "Test Suites:[\\s\\S]*"
- "\\s+$"
string_cleanup_2:
id: remainingErrors
value: "{{{logResult}}}"
remove:
- "^[\\s\\S]+?(?=\n\n( ●| FAIL)|$)"
- "^\n+"
- "Test Suites:[\\s\\S]*"
- "\\s+$"
string_cleanup_3:
id: summary
value: "{{{logResult}}}"
remove:
- "^[\\s\\S]+?(?=Test Suites:)"
- "\\s+$"
actions:
comment:
identifier: "ci-result"
message: |-
The basic integration tests succeeded, but the full suite failed.
@{{commit.author.login}} Please review the following output log for errors:
```text
{{{firstError}}}
```
{{#if remainingErrors}}
<details>
<summary>Show remaining errors</summary>
```text
{{{remainingErrors}}}
```
</details>
{{/if}}
```text
{{{summary}}}
```
See [complete report here]({{status.target_url}}).
set:
id: report_ci
value: nope
# Report specific error message if jest for unit tests or liniting fails
- filters:
ensure:
value: "{{report_ci}}"
equals: yep
commit: true
status:
context: "continuous-integration/travis-ci/pr"
travis_job:
state: "failed"
allow_failure: false
config:
env: JOB_PART=lint-unit
fetch: travis_job.log
string_cleanup:
id: logResult
value: "{{{fetch}}}"
remove:
- ".\\[2K.\\[1G|.\\[999D.\\[K"
- "^[\\s\\S]+?\\$ yarn travis:\\$JOB_PART.*\n"
- "\\$ node --max-old-space-size=4096.*\n"
- ".+rimraf coverage"
- "yarn run.+\n"
- "\\(node:\\d+\\) (\\[DEP0005\\]|DeprecationWarning).+\n"
- "\\$ yarn (unit|lint).+\n"
- "The command \"yarn travis:\\$JOB_PART\" exited[\\s\\S]*"
- "Ran all test suites.+\n"
- "error Command failed with exit code \\d+.\n"
- "info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n"
- "Force exiting Jest\n\nHave you considered.+"
- "=============================== Coverage summary ===============================[\\s\\S]+?================================================================================"
- " *PASS *test/.*\n"
- "^\\s+\n|\\s+$"
actions:
comment:
identifier: "ci-result"
message: |-
The integration tests look fine, but there are code style issues or unit test failures in the Pull Request.
@{{commit.author.login}} Please review the following output log for errors:
``` text
{{{logResult}}}
```
If the unit tests are outdated, you can choose to delete them and add integration tests instead. That would be great.
See [complete report here]({{status.target_url}}).
set:
id: report_ci
value: nope
# Report a general error message
- filters:
ensure:
value: "{{report_ci}}"
equals: yep
commit: true
status_1:
context: "continuous-integration/travis-ci/pr"
status_2:
context: "continuous-integration/appveyor/pr"
actions:
comment:
identifier: "ci-result"
message: |-
@{{commit.author.login}} The most important CI builds failed. This way your PR can't be merged.
Please take a look at the CI results from [travis]({{status_1.target_url}}) ({{status_1.state}}) and [appveyor]({{status_2.target_url}}) ({{status_2.state}}) and fix these issues.
# Add tests-needed label depending on codecov status
# comment to point the user writing test cases
# comment in case of success
- filters:
open: true
pull_request:
mergeable: true
status:
context: "codecov/patch/integration"
ensure:
value: "{{status.state}}"
equals: "success"
label: "PR: tests-needed"
actions:
label:
remove: "PR: tests-needed"
comment:
identifier: "tests-result"
message: |-
The minimum test ratio has been reached. Thanks!
- filters:
open: true
pull_request:
mergeable: true
status:
context: "codecov/patch/integration"
ensure:
value: "{{status.state}}"
equals: "failure"
actions:
label:
add: "PR: tests-needed"
- filters:
open: true
pull_request:
mergeable: true
status:
context: "codecov/patch/integration"
ensure:
value: "{{status.state}}"
equals: "failure"
age:
value: "{{status.created_at}}"
minimum: 1h
permission: "read|none"
actions:
comment:
identifier: "tests-result"
message: |-
It looks like this Pull Request doesn't include [enough test cases]({{status.target_url}}) (based on Code Coverage analysis of the PR diff).
A PR need to be covered by tests if you add a new feature (we want to make sure that your feature is working) or if you fix a bug (we want to make sure that we don't run into a regression in future).
@{{issue.user.login}} Please check if this is appliable to your PR and if you can add more test cases.
Read the [test readme](https://github.com/webpack/webpack/blob/master/test/README.md) for details how to write test cases.
# add conflict label to pull requests with conflict
# on conflict all result labels are removed
- filters:
open: true
pull_request:
mergeable: false
actions:
label:
add: "PR: conflict"
remove:
- "PR: tests-needed"
- "PR: CI-ok"
- "PR: CI-not-ok"
- filters:
open: true
pull_request:
mergeable: true
actions:
label:
remove: "PR: conflict"
# add unreviewed, reviewed, review-outdated labels
# comment to ping reviewer
# comment on new PR
- filters:
open: true
in_order:
commit: true
review:
state: APPROVED|CHANGES_REQUESTED
ensure:
value: "{{review.state}}"
equals: APPROVED
permission:
user: "{{review.user.login}}"
actions:
label:
add: "PR: reviewed-approved"
remove:
- "PR: review-outdated"
- "PR: unreviewed"
- "PR: reviewed"
- filters:
open: true
in_order:
commit: true
review:
state: APPROVED|CHANGES_REQUESTED
permission:
user: "{{review.user.login}}"
ensure:
value: "{{review.state}}"
equals: CHANGES_REQUESTED
actions:
label:
add: "PR: reviewed-changes-requested"
remove:
- "PR: review-outdated"
- "PR: unreviewed"
- "PR: reviewed"
- filters:
open: true
in_order:
review:
state: APPROVED|CHANGES_REQUESTED
commit: true
permission:
user: "{{review.user.login}}"
not:
label: "review-outdated"
ensure:
value: "{{commit.author.login}}"
notEquals: "{{review.user.login}}"
actions:
label:
add: "PR: review-outdated"
remove:
- "PR: reviewed-approved"
- "PR: reviewed-changes-requested"
- "PR: unreviewed"
- "PR: reviewed"
comment:
identifier: "review-outdated"
message: |-
@{{commit.author.login}} Thanks for your update.
I labeled the Pull Request so reviewers will review it again.
@{{review.user.login}} Please review the new changes.
- filters:
open: true
commit: true
not:
review:
state: APPROVED|CHANGES_REQUESTED
actions:
label: "PR: unreviewed"
# add non-master, webpack-4 and next label to pull request to other branch
- filters:
pull_request:
base_ref: "^master$"
actions:
label:
remove:
- "PR: next"
- "PR: webpack-4"
- "PR: non-master"
- filters:
pull_request:
base_ref: "^next$"
actions:
label:
add: "PR: next"
remove:
- "PR: webpack-4"
- "PR: non-master"
- filters:
pull_request:
base_ref: "^webpack-4$"
actions:
label:
add: "PR: webpack-4"
remove:
- "PR: next"
- "PR: non-master"
- filters:
pull_request:
base_ref: "^(?!master$)(?!webpack-4$)(?!next$)"
actions:
label:
add: "PR: non-master"
remove:
- "PR: next"
- "PR: webpack-4"
# add non-master label to pull request to other branch
- filters:
open: true
age:
minimum: 1d
maximum: 1w
pull_request:
head_ref: "^master$"
permission: "read|none"
actions:
comment:
identifier: "head-master"
edit: true
message: |-
Hi @{{pull_request.user.login}}.
Just a little hint from a friendly bot about the best practice when submitting pull requests:
> Don't submit pull request from your own `master` branch. It's recommended to create a feature branch for the PR.
*You don't have to change it for this PR, just make sure to follow this hint the next time you submit a PR.*
# skip CLA for dependabot
- filters:
open: true
pull_request:
author: "^dependabot(-preview)?\\[bot\\]$"
status:
context: "licence/cla"
state: "pending"
actions:
status:
context: "licence/cla"
description: "Contributor License Agreement is not needed for this user."
state: "success"
# merge dependabot PRs automatically
- filters:
open: true
pull_request:
author: "^dependabot(-preview)?\\[bot\\]$"
mergeable_state: clean
merged: false
label: "PR: CI-ok"
actions:
merge: true
# add "Send a PR" label when somebody with write permission say it
- filters:
open: true
comment: "[Ss]end a [Pp][Rr]"
permission:
user: "{{comment.actor.login}}"
actions:
label: "Send a PR"
# Move issue task
- filters:
open: true
comment: "\\s*@webpack-bot\\s+move\\s+(?:to\\s+)?([a-z0-9_\\-\\.]+/[a-z0-9_\\-\\.]+)\\s*([\\s\\S]*)$"
not:
comment_1:
matching: "moved\\-by\\-bot"
author: "."
permission:
user: "{{comment.actor.login}}"
actions:
new_issue:
target: "{{{comment_match.[1]}}}"
body: |-
{{{issue.body}}}
---
This issue was moved from {{owner}}/{{repo}}#{{issue.number}} by @{{comment.actor.login}}. Original issue was by @{{issue.user.login}}.
{{{comment_match.[2]}}}
comment:
identifier: moved-by-bot
message: |-
I've moved it to {{comment_match.[1]}}.
close: true
# mark inactive issues with inactive label
# close them when no activity after warning
- filters:
issue: true
open: true
not:
label: inactive
ensure:
value: "{{issue.reactions.[+1]}}"
range: "< 10"
last_action_age: 13w # three months
actions:
comment:
identifier: inactive-warning
message: |-
**This issue had no activity for at least three months.**
It's subject to automatic issue closing if there is no activity in the next 15 days.
label: inactive
- filters:
open: true
label: inactive
last_action_age:
maximum: 13w # three months
actions:
label:
remove:
- inactive
- filters:
open: true
label: inactive
last_action_age:
minimum: 15d
includeBotActions: true
actions:
close: true
comment:
identifier: inactive-close
message: |-
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.
# Add action actions box to each pull request
- filters:
pull_request: true
open: true
not:
comment:
matching: admin-actions
author: webpack-bot
actions:
comment:
identifier: admin-actions
message: |-
*For maintainers only:*
* [ ] <!-- document --> This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
* [ ] <!-- webpack-4-backport --> This needs to be backported to webpack 4 (issue will be created when merged)
# When a pull request need to be documented, create an issue in webpack/webpack.js.org when merged
- filters:
pull_request:
merged: true
comment:
author: webpack-bot
matching: "\\* \\[x\\] <!-- document -->"
not:
comment_1:
author: webpack-bot
matching: admin-action-document-executed
actions:
new_issue:
target: webpack/webpack.js.org
title: "Document webpack change: {{{pull_request.title}}}"
body: |-
<!-- documentation request from webpack/webpack -->
*A pull request by @{{pull_request.user.login}} was merged and maintainers requested a documentation change.*
See pull request: {{{pull_request.html_url}}}
---
{{{pull_request.body}}}
comment:
identifier: admin-action-document-executed
message: |-
I've created an issue to document this in webpack/webpack.js.org.
# When a pull request need to be backported, create an issue in webpack/webpack when merged
- filters:
pull_request:
merged: true
comment:
author: webpack-bot
matching: "\\* \\[x\\] <!-- webpack-4-backport -->"
not:
comment_1:
author: webpack-bot
matching: admin-action-webpack-4-backport-executed
actions:
new_issue:
target: webpack/webpack
title: "Backport to webpack 4: {{{pull_request.title}}}"
body: |-
{{{pull_request.html_url}}} needs to be backported to webpack 4.
Send a PR.
cc @{{pull_request.user.login}}
comment:
identifier: admin-action-webpack-4-backport-executed
message: |-
I've created an issue to backport this.
# Check open issues and pull requests every day
- filters:
open: true
actions:
schedule: 1d