From cd0ffcc806dc25b8cae6ac4f8faa3aea3737a9cc Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 12 Nov 2024 19:41:15 +1300 Subject: [PATCH 1/2] Refactor how Zashi pipeline rows are handled --- zashi-pipeline.py | 74 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/zashi-pipeline.py b/zashi-pipeline.py index 4b349cc6..3f2a429d 100644 --- a/zashi-pipeline.py +++ b/zashi-pipeline.py @@ -31,9 +31,57 @@ RELEASE_MATRIX = { ZASHI_IOS: [] } -class TrackedIssue: - def __init__(self, issue): - self.issue = issue + +class Release: + def __init__(self, repo_id, child): + self.repo_id = repo_id + + # Extract version number from title + if repo_id == RUST: + self.version = re.search(r'zcash_[^ ]+ \d+(\.\d+)+', child.title).group() + else: + self.version = re.search(r'\d+(\.\d+)+', child.title).group() + + self.is_closed = child.state == 'closed' + self.url = child.url + + def __repr__(self): + return self.version + + def __eq__(self, other): + return (self.repo_id, self.version) == (other.repo_id, other.version) + + def __hash__(self): + return hash((self.repo_id, self.version)) + + +def build_release(row, repo_id): + child = row.get(repo_id) + if child is None: + return None + else: + return Release(repo_id, child) + + +class ReleasePipeline: + def __init__(self, row): + self.rust = build_release(row, RUST) + self.android_sdk = build_release(row, ANDROID_SDK) + self.swift_sdk = build_release(row, SWIFT_SDK) + self.zashi_android = build_release(row, ZASHI_ANDROID) + self.zashi_ios = build_release(row, ZASHI_IOS) + + def __repr__(self): + return '%s | %s | %s | %s | %s' % self.columns() + + def columns(self): + return ( + self.rust, + self.android_sdk, + self.swift_sdk, + self.zashi_android, + self.zashi_ios, + ) def build_release_matrix_from(dg, issue, repo_id): acc = [] @@ -200,7 +248,8 @@ def main(): f.write(html_header) for issue in tracked_issues.values(): - rows = build_release_matrix_from(dg, issue, RUST); + rows = [ReleasePipeline(row) for row in build_release_matrix_from(dg, issue, RUST)] + for i, row in enumerate(rows): f.write('') @@ -220,22 +269,15 @@ def main(): issue.title, )) - for repo_id in [RUST, ANDROID_SDK, SWIFT_SDK, ZASHI_ANDROID, ZASHI_IOS]: - child = row.get(repo_id) - if child is None: + for release in row.columns(): + if release is None: # Release not found in this repo f.write('📥') else: - # Extract version number from title - if repo_id == RUST: - version = re.search(r'zcash_[^ ]+ \d+(\.\d+)+', child.title).group() - else: - version = re.search(r'\d+(\.\d+)+', child.title).group() - f.write('{} {}'.format( - '✅' if child.state == 'closed' else '🛑', - child.url, - version, + '✅' if release.is_closed else '🛑', + release.url, + release.version, )) f.write('') From 33740c2174aefa5418894d893dcea4347cbd2f5d Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 12 Nov 2024 20:13:04 +1300 Subject: [PATCH 2/2] Deduplicate the rows for each tracked issue in the pipeline --- zashi-pipeline.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zashi-pipeline.py b/zashi-pipeline.py index 3f2a429d..3fd30106 100644 --- a/zashi-pipeline.py +++ b/zashi-pipeline.py @@ -74,6 +74,12 @@ class ReleasePipeline: def __repr__(self): return '%s | %s | %s | %s | %s' % self.columns() + def __eq__(self, other): + return self.columns() == other.columns() + + def __hash__(self): + return hash(self.columns()) + def columns(self): return ( self.rust, @@ -250,6 +256,9 @@ def main(): for issue in tracked_issues.values(): rows = [ReleasePipeline(row) for row in build_release_matrix_from(dg, issue, RUST)] + # Deduplicate rows + rows = list(dict.fromkeys(rows)) + for i, row in enumerate(rows): f.write('')