32
32
import requests
33
33
34
34
from adabot import github_requests as github
35
- from adabot import travis_requests as travis
36
35
from adabot import pypi_requests as pypi
37
36
from adabot .lib import circuitpython_library_validators as cirpy_lib_vals
38
37
from adabot .lib import common_funcs
68
67
default = 5 ,
69
68
metavar = "n"
70
69
)
71
- cmd_line_parser .add_argument (
72
- "-t" , "--travis-github-token" ,
73
- help = "Prompt for the GitHub user's password in order to make a GitHub token to use on Travis." ,
74
- dest = "gh_token" ,
75
- action = "store_true"
76
- )
77
70
cmd_line_parser .add_argument (
78
71
"-v" , "--validator" ,
79
72
help = "Run validators with 'all', or only the validator(s) supplied in a string." ,
103
96
if vals [0 ].startswith ("validate" )
104
97
]
105
98
106
- pr_sort_re = re .compile ("(?<=\(Open\s)(.+)(?=\sdays)" )
99
+ pr_sort_re = re .compile (r"(?<=\(Open\s)(.+)(?=\sdays)" )
100
+ close_pr_sort_re = re .compile (r"(?<=\(Days\sopen:\s)(.+)(?=\))" )
107
101
108
102
def run_library_checks (validators , bundle_submodules , latest_pylint , kw_args ):
109
103
"""runs the various library checking functions"""
@@ -112,7 +106,8 @@ def run_library_checks(validators, bundle_submodules, latest_pylint, kw_args):
112
106
latest_pylint = pylint_info .json ()["info" ]["version" ]
113
107
output_handler ("Latest pylint is: {}" .format (latest_pylint ))
114
108
115
- repos = common_funcs .list_repos (include_repos = ('Adafruit_Blinka' ,))
109
+ repos = common_funcs .list_repos (include_repos = ('Adafruit_Blinka' ,
110
+ 'CircuitPython_Community_Bundle' ))
116
111
output_handler ("Found {} repos to check." .format (len (repos )))
117
112
bundle_submodules = common_funcs .get_bundle_submodules ()
118
113
output_handler ("Found {} submodules in the bundle." .format (len (bundle_submodules )))
@@ -165,7 +160,8 @@ def run_library_checks(validators, bundle_submodules, latest_pylint, kw_args):
165
160
insights = blinka_insights
166
161
elif repo ["name" ] == "circuitpython" :
167
162
insights = core_insights
168
- errors = validator .gather_insights (repo , insights , since )
163
+ closed_metric = bool (insights == lib_insights )
164
+ errors = validator .gather_insights (repo , insights , since , show_closed_metric = closed_metric )
169
165
if errors :
170
166
print ("insights error" )
171
167
for error in errors :
@@ -182,11 +178,11 @@ def run_library_checks(validators, bundle_submodules, latest_pylint, kw_args):
182
178
updated_libs [repo ["name" ]] = repo ["html_url" ]
183
179
184
180
output_handler ()
185
- output_handler ("State of CircuitPython + Libraries" )
181
+ output_handler ("State of CircuitPython + Libraries + Blinka " )
186
182
187
183
output_handler ("Overall" )
188
- print_pr_overview (lib_insights , core_insights )
189
- print_issue_overview (lib_insights , core_insights )
184
+ print_pr_overview (lib_insights , core_insights , blinka_insights )
185
+ print_issue_overview (lib_insights , core_insights , blinka_insights )
190
186
191
187
output_handler ()
192
188
output_handler ("Core" )
@@ -208,20 +204,38 @@ def run_library_checks(validators, bundle_submodules, latest_pylint, kw_args):
208
204
core_insights ["milestones" ][milestone ]))
209
205
output_handler (" * {} issues not assigned a milestone" .format (len (core_insights ["open_issues" ]) - ms_count ))
210
206
output_handler ()
211
- print_circuitpython_download_stats ()
207
+
208
+ ## temporarily disabling core download stats:
209
+ # - GitHub API has been broken, due to the number of release artifacts
210
+ # - Release asset delivery is being moved to AWS CloudFront/S3
211
+ #print_circuitpython_download_stats()
212
+ output_handler (
213
+ "* Core download stats available at https://circuitpython.org/stats"
214
+ )
212
215
213
216
output_handler ()
214
217
output_handler ("Libraries" )
215
218
print_pr_overview (lib_insights )
216
- output_handler ("* {} open pull requests" . format ( len ( lib_insights [ "open_prs" ])) )
217
- sorted_prs = sorted (lib_insights ["open_prs " ],
218
- key = lambda days : int (pr_sort_re .search (days ).group (1 )),
219
+ output_handler (" * Merged pull requests:" )
220
+ sorted_prs = sorted (lib_insights ["merged_prs " ],
221
+ key = lambda days : int (close_pr_sort_re .search (days ).group (1 )),
219
222
reverse = True )
220
223
for pr in sorted_prs :
221
- output_handler (" * {}" .format (pr ))
224
+ output_handler (" * {}" .format (pr ))
222
225
print_issue_overview (lib_insights )
223
- output_handler ("* {} open issues" .format (len (lib_insights ["open_issues" ])))
224
- output_handler (" * https://circuitpython.org/contributing" )
226
+ output_handler ("* https://circuitpython.org/contributing" )
227
+ output_handler (" * {} open issues" .format (len (lib_insights ["open_issues" ])))
228
+ open_pr_days = [
229
+ int (pr_sort_re .search (pr ).group (1 )) for pr in lib_insights ["open_prs" ]
230
+ if pr_sort_re .search (pr ) is not None
231
+ ]
232
+ output_handler (
233
+ " * {0} open pull requests (Oldest: {1}, Newest: {2})" .format (
234
+ len (lib_insights ["open_prs" ]),
235
+ max (open_pr_days ),
236
+ max ((min (open_pr_days ), 1 )) # ensure the minumum is '1'
237
+ )
238
+ )
225
239
output_handler ("Library updates in the last seven days:" )
226
240
if len (new_libs ) != 0 :
227
241
output_handler ("**New Libraries**" )
@@ -280,9 +294,25 @@ def output_handler(message="", quiet=False):
280
294
281
295
def print_circuitpython_download_stats ():
282
296
"""Gather and report analytics on the main CircuitPython repository."""
283
- response = github .get ("/repos/adafruit/circuitpython/releases" )
297
+
298
+ # TODO: with the move of release assets to AWS CloudFront/S3, update
299
+ # this to use AWS CloudWatch metrics to gather download stats.
300
+ # AWS' Python SDK `boto3` has CloudWatch interfaces which should
301
+ # enable this. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudwatch.html
302
+
303
+ try :
304
+ response = github .get ("/repos/adafruit/circuitpython/releases" )
305
+ except (ValueError , RuntimeError ):
306
+ output_handler (
307
+ "Core CircuitPython GitHub download statistics request failed."
308
+ )
309
+ return
310
+
284
311
if not response .ok :
285
- output_handler ("Core CircuitPython GitHub analytics request failed." )
312
+ output_handler (
313
+ "Core CircuitPython GitHub download statistics request failed."
314
+ )
315
+ return
286
316
releases = response .json ()
287
317
288
318
found_unstable = False
@@ -416,7 +446,7 @@ def print_circuitpython_download_stats():
416
446
output_handler ()
417
447
418
448
def print_pr_overview (* insights ):
419
- merged_prs = sum ([x ["merged_prs" ] for x in insights ])
449
+ merged_prs = sum ([len ( x ["merged_prs" ]) for x in insights ])
420
450
authors = set ().union (* [x ["pr_merged_authors" ] for x in insights ])
421
451
reviewers = set ().union (* [x ["pr_reviewers" ] for x in insights ])
422
452
@@ -467,10 +497,6 @@ def print_issue_overview(*insights):
467
497
error_depth = cmd_line_args .error_depth
468
498
startup_message .append (" - Depth for listing libraries with errors: {}" .format (error_depth ))
469
499
470
- github_token = cmd_line_args .gh_token
471
- validator_kwarg_list ["github_token" ] = github_token
472
- startup_message .append (" - Prompts for the GitHub Token are {}." .format (("enabled" if github_token else "disabled" )))
473
-
474
500
if cmd_line_args .validator != "all" :
475
501
validators = []
476
502
for func in cmd_line_args .validator .split ("," ):
0 commit comments