Skip to content

Commit d4f9446

Browse files
authored
Merge pull request #331 from tekktrik/dev/improve-update-check
Improve library update check for Adafruit Bundle libraries
2 parents 85a9103 + 194e624 commit d4f9446

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

adabot/circuitpython_libraries.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from adabot.lib import common_funcs
2424
from adabot.lib import assign_hacktober_label as hacktober
2525
from adabot.lib import blinka_funcs
26-
from adabot.lib import community_bundle_announcer
26+
from adabot.lib import bundle_announcer
2727
from adabot import circuitpython_library_download_stats as dl_stats
2828

2929
GH_INTERFACE = pygithub.Github(os.environ.get("ADABOT_GITHUB_ACCESS_TOKEN"))
@@ -124,8 +124,6 @@ def run_library_checks(validators, kw_args, error_depth):
124124
repo_needs_work = []
125125
since = datetime.datetime.now() - datetime.timedelta(days=7)
126126
repos_by_error = {}
127-
new_libs = {}
128-
updated_libs = {}
129127

130128
validator = cirpy_lib_vals.LibraryValidator(
131129
validators, bundle_submodules, latest_pylint, **kw_args
@@ -172,14 +170,6 @@ def run_library_checks(validators, kw_args, error_depth):
172170
logger.info(", ".join(validator.output_file_data))
173171
validator.output_file_data.clear()
174172

175-
# get a list of new & updated libraries for the last week
176-
if repo["name"] != "Adafruit_CircuitPython_Bundle":
177-
check_releases = common_funcs.is_new_or_updated(repo)
178-
if check_releases == "new":
179-
new_libs[repo["name"]] = repo["html_url"]
180-
elif check_releases == "updated":
181-
updated_libs[repo["name"]] = repo["html_url"]
182-
183173
logger.info("")
184174
logger.info("State of CircuitPython + Libraries + Blinka")
185175

@@ -332,21 +322,23 @@ def run_library_checks(validators, kw_args, error_depth):
332322
)
333323
logger.info("*This is normal for CI runs from PRs*")
334324

325+
new_libs, updated_libs = bundle_announcer.get_adafruit_bundle_updates()
326+
335327
logger.info("")
336328
logger.info("#### Library updates in the last seven days:")
337329
if len(new_libs) != 0:
338330
logger.info("* **New Libraries**")
339-
for title, link in new_libs.items():
331+
for title, link in new_libs:
340332
logger.info(" * [%s](%s)", title, link)
341333
if len(updated_libs) != 0:
342334
logger.info("* **Updated Libraries**")
343-
for title, link in updated_libs.items():
335+
for title, link in updated_libs:
344336
logger.info(" * [%s](%s)", title, link)
345337

346338
(
347339
new_community_libs,
348340
updated_community_libs,
349-
) = community_bundle_announcer.get_community_bundle_updates()
341+
) = bundle_announcer.get_community_bundle_updates()
350342
if len(new_community_libs) != 0:
351343
logger.info("* **New Community Libraries**")
352344
for title, link in new_community_libs:

adabot/lib/community_bundle_announcer.py renamed to adabot/lib/bundle_announcer.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,25 @@
2626

2727

2828
def get_community_bundle_updates() -> Tuple[Set[RepoResult], Set[RepoResult]]:
29+
"""Get new and updated libraries in the Community Bundle"""
30+
return get_bundle_updates("adafruit/CircuitPython_Community_Bundle")
31+
32+
33+
def get_adafruit_bundle_updates() -> Tuple[Set[RepoResult], Set[RepoResult]]:
34+
"""Get new and updated libraries in the Adafruit Bundle"""
35+
return get_bundle_updates("adafruit/Adafruit_CircuitPython_Bundle")
36+
37+
38+
# pylint: disable=too-many-locals
39+
def get_bundle_updates(full_repo_name: str) -> Tuple[Set[RepoResult], Set[RepoResult]]:
2940
"""
3041
Get the updates to the Community Bundle.
3142
3243
Returns new and updated libraries
3344
"""
3445
while True:
3546
try:
36-
repository = GH_INTERFACE.get_repo(
37-
"adafruit/CircuitPython_Community_Bundle"
38-
)
47+
repository = GH_INTERFACE.get_repo(full_repo_name)
3948
seven_days_ago = datetime.datetime.now() - datetime.timedelta(days=7)
4049
recent_releases = [
4150
release
@@ -81,8 +90,18 @@ def get_community_bundle_updates() -> Tuple[Set[RepoResult], Set[RepoResult]]:
8190

8291

8392
if __name__ == "__main__":
84-
results = get_community_bundle_updates()
85-
for new_lib in results[0]:
86-
print(f"New libraries: {new_lib[0]} { {new_lib[1]} }")
87-
for updated_lib in results[1]:
88-
print(f"New libraries: {updated_lib[0]} { {updated_lib[1]} }")
93+
adafruit_results = get_adafruit_bundle_updates()
94+
community_results = get_community_bundle_updates()
95+
for new_adafruit_lib in adafruit_results[0]:
96+
print(f"New libraries: {new_adafruit_lib[0]} { {new_adafruit_lib[1]} }")
97+
for updated_adafruit_lib in adafruit_results[1]:
98+
print(
99+
f"Updated libraries: {updated_adafruit_lib[0]} { {updated_adafruit_lib[1]} }"
100+
)
101+
print("-----")
102+
for new_community_lib in community_results[0]:
103+
print(f"New libraries: {new_community_lib[0]} { {new_community_lib[1]} }")
104+
for updated_community_lib in community_results[1]:
105+
print(
106+
f"Updated libraries: {updated_community_lib[0]} { {updated_community_lib[1]} }"
107+
)

0 commit comments

Comments
 (0)