-
Notifications
You must be signed in to change notification settings - Fork 88
Cache koji builds #748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Cache koji builds #748
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,7 +209,7 @@ def find_previous_build_commit(session, build_tag, build): | |
] | ||
if not tagged: | ||
return None | ||
previous_build = session.getBuild(tagged[0]['build_id']) | ||
previous_build = get_koji_build(session, tagged[0]['build_id']) | ||
if not previous_build.get('source'): | ||
return None | ||
return parse_source(previous_build['source'])[1] | ||
|
@@ -253,6 +253,14 @@ def find_pull_requests(gh, repo, start_sha, end_sha): | |
prs.update(commit_prs) | ||
return sorted(prs, key=lambda p: p.number, reverse=True) | ||
|
||
def get_koji_build(session, build_id) -> dict: | ||
cache_key = f'koji-build-{build_id}' | ||
if not args.re_cache and cache_key in CACHE: | ||
return cast(dict, CACHE[cache_key]) | ||
else: | ||
build = session.getBuild(build_id) | ||
CACHE.set(cache_key, build, expire=RETENTION_TIME) | ||
return build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of managing such a cache manually, wouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a persistent cache, using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right. Looks like this is a common pattern, though, and there are some libs for this, like: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or maybe I can set the |
||
|
||
started_at = datetime.now() | ||
|
||
|
@@ -328,7 +336,7 @@ def find_pull_requests(gh, repo, start_sha, end_sha): | |
taggeds = (t for t in taggeds if t['package_name'] in args.packages or args.packages == []) | ||
taggeds = sorted(taggeds, key=lambda t: (tag_history[t['build_id']], t['build_id']), reverse=True) | ||
for tagged in taggeds: | ||
build = session.getBuild(tagged['build_id']) | ||
build = get_koji_build(session, tagged['build_id']) | ||
prs: list[PullRequest] = [] | ||
maintained_by = None | ||
previous_build_sha = find_previous_build_commit(session, tag, build) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cast looks necessary just because
CACHE
itself cannot be properly type-hinted?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking twice about it,
CACHE
could be typed using aTypeDict
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it would fit well.
I could
assert isinstance(…)
instead of casting if you prefer