@@ -80,6 +80,16 @@ def is_arduino_library(repo):
80
80
else :
81
81
return False
82
82
83
+ def print_list_output (title , coll ):
84
+ ""
85
+ output_handler ()
86
+ output_handler (title .format (len (coll )))
87
+ long_col = [(max ([len (str (row [i ])) for row in coll ]) + 3 )
88
+ for i in range (len (coll [0 ]))]
89
+ row_format = "" .join (["{:<" + str (this_col ) + "}" for this_col in long_col ])
90
+ for lib in coll :
91
+ output_handler (row_format .format (* lib ))
92
+
83
93
def output_handler (message = "" , quiet = False ):
84
94
"""Handles message output to prompt/file for print_*() functions."""
85
95
if output_filename is not None :
@@ -98,7 +108,7 @@ def validate_library_properties(repo):
98
108
has_lib_prop = github .get ("/repos/adafruit/" + repo ["name" ] + "/contents" )
99
109
if has_lib_prop .ok :
100
110
if "library.properties" not in has_lib_prop .text :
101
- return
111
+ return False
102
112
for file in has_lib_prop .json ():
103
113
if file ["name" ] == "library.properties" :
104
114
lib_prop_file = requests .get (file ["download_url" ], timeout = 30 )
@@ -162,6 +172,22 @@ def validate_release_state(repo):
162
172
163
173
return
164
174
175
+ def validate_travis (repo ):
176
+ """Validate if a repo has .travis.yml.
177
+ """
178
+ repo_has_travis = github .get ("/repos/" + repo ["full_name" ] + "/contents/.travis.yml" )
179
+ if repo_has_travis .ok :
180
+ return True
181
+
182
+ def validate_example (repo ):
183
+ """Validate if a repo has any files in examples directory
184
+ """
185
+ repo_has_ino = github .get ("/repos/adafruit/" + repo ["name" ] + "/contents/examples" )
186
+ if repo_has_ino .ok and len (repo_has_ino .json ()):
187
+ return True
188
+ else :
189
+ return False
190
+
165
191
def run_arduino_lib_checks ():
166
192
output_handler ("Running Arduino Library Checks" )
167
193
output_handler ("Getting list of libraries to check..." )
@@ -170,32 +196,41 @@ def run_arduino_lib_checks():
170
196
output_handler ("Found {} Arduino libraries to check\n " .format (len (repo_list )))
171
197
failed_lib_prop = [[" Repo" , "Release Tag" , "library.properties Version" ], [" ----" , "-----------" , "--------------------------" ]]
172
198
needs_release_list = [[" Repo" , "Latest Release" , "Commits Behind" ], [" ----" , "--------------" , "--------------" ]]
199
+ missing_travis_list = [[" Repo" ], [" ----" ]]
200
+ missing_library_properties_list = [[" Repo" ], [" ----" ]]
201
+
173
202
for repo in repo_list :
174
203
lib_check = validate_library_properties (repo )
175
204
if lib_check :
176
205
if lib_check [0 ] != lib_check [1 ]:
177
206
failed_lib_prop .append ([" " + str (repo ["name" ]), lib_check [0 ], lib_check [1 ]])
178
207
179
208
needs_release = validate_release_state (repo )
209
+ missing_travis = not validate_travis (repo )
210
+ have_ino = validate_example (repo )
211
+ missing_library_properties = lib_check == False
212
+
180
213
if needs_release :
181
214
needs_release_list .append ([" " + str (repo ["name" ]), needs_release [0 ], needs_release [1 ]])
182
215
216
+ if missing_travis and have_ino :
217
+ missing_travis_list .append ([" " + str (repo ["name" ])])
218
+
219
+ if missing_library_properties and have_ino :
220
+ missing_library_properties_list .append ([" " + str (repo ["name" ])])
221
+
183
222
if len (failed_lib_prop ) > 2 :
184
- output_handler ("Libraries Have Mismatched Release Tag and library.properties Version: ({})" .format (len (failed_lib_prop )))
185
- long_col = [(max ([len (str (row [i ])) for row in failed_lib_prop ]) + 3 )
186
- for i in range (len (failed_lib_prop [0 ]))]
187
- row_format = "" .join (["{:<" + str (this_col ) + "}" for this_col in long_col ])
188
- for lib in failed_lib_prop :
189
- output_handler (row_format .format (* lib ))
223
+ print_list_output ("Libraries Have Mismatched Release Tag and library.properties Version: ({})" , failed_lib_prop )
190
224
191
225
if len (needs_release_list ) > 2 :
192
- output_handler ()
193
- output_handler ("Libraries have commits since last release: ({})" .format (len (needs_release_list )))
194
- long_col = [(max ([len (str (row [i ])) for row in needs_release_list ]) + 3 )
195
- for i in range (len (needs_release_list [0 ]))]
196
- row_format = "" .join (["{:<" + str (this_col ) + "}" for this_col in long_col ])
197
- for lib in needs_release_list :
198
- output_handler (row_format .format (* lib ))
226
+ print_list_output ("Libraries have commits since last release: ({})" , needs_release_list );
227
+
228
+ if len (missing_travis_list ) > 2 :
229
+ print_list_output ("Libraries that is not configured with Travis (but have *.ino files): ({})" , missing_travis_list )
230
+
231
+ if len (missing_library_properties_list ) > 2 :
232
+ print_list_output ("Libraries that is missing library.properties file (but have *.ino files): ({})" , missing_library_properties_list )
233
+
199
234
200
235
if __name__ == "__main__" :
201
236
cmd_line_args = cmd_line_parser .parse_args ()
0 commit comments