Skip to content

Commit

Permalink
Merge pull request #76 from zcash/pipeline-unscheduled-issues
Browse files Browse the repository at this point in the history
Handle unscheduled issues in the Zashi pipeline view
  • Loading branch information
str4d authored Nov 19, 2024
2 parents c1012e7 + c93ce9d commit f9f58fd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 25 deletions.
3 changes: 2 additions & 1 deletion helpers/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __hash__(self):

# To get the GitHub ID of a repo, see <https://stackoverflow.com/a/47223479/393146>.

ZIP32 = Repo(('zcash', 'zip32'), 141066493, 'Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTMzOTY2MzAy')
LIBRUSTZCASH = Repo(('zcash', 'librustzcash'), 85334928, 'Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTg5MDU1NTE')
ZCASH_ANDROID_WALLET_SDK = Repo(('Electric-Coin-Company', 'zcash-android-wallet-sdk'), 151763639, 'Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTg5MDI4MjE')
ZCASH_LIGHT_CLIENT_FFI = Repo(('Electric-Coin-Company', 'zcash-light-client-ffi'), 439137887, 'Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTMzMTMwNjcy')
Expand All @@ -43,7 +44,7 @@ def __hash__(self):
Repo(('zcash', 'zcash-test-vectors'), 133857578, 'Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTMyOTMxNTEx'),
Repo(('zcash', 'sapling-crypto'), 111058300, 'Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTMzOTY3ODY4'),
Repo(('zcash', 'orchard'), 305835578, 'Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTMyODU2MzA2'),
Repo(('zcash', 'zip32'), 141066493, 'Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTMzOTY2MzAy'),
ZIP32,
] + HALO2_REPOS

TFL_REPOS = [
Expand Down
59 changes: 35 additions & 24 deletions zashi-pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')
ZENHUB_TOKEN = os.environ.get('ZENHUB_TOKEN')

# IDs of repos we look for releases in.
RUST = 85334928
ANDROID_SDK = 151763639
SWIFT_SDK = 185480114
ZASHI_ANDROID = 390808594
ZASHI_IOS = 387551125
# Repository groups we look for releases in. Each of these groups corresponds to
# a column in the pipeline table; in some cases the releases for that column may
# be spread across several repositories.
RUST = (
repositories.LIBRUSTZCASH,
repositories.ZIP32,
)
ANDROID_SDK = (repositories.ZCASH_ANDROID_WALLET_SDK,)
SWIFT_SDK = (repositories.ZCASH_SWIFT_WALLET_SDK,)
ZASHI_ANDROID = (repositories.ZASHI_ANDROID,)
ZASHI_IOS = (repositories.ZASHI_IOS,)

REPOS = github.CORE_REPOS + github.WALLET_REPOS

Expand All @@ -33,14 +38,17 @@


class Release:
def __init__(self, repo_id, child):
self.repo_id = repo_id
def __init__(self, repo_group, child):
self.repo_group = repo_group

# Extract version number from title
if repo_id == RUST:
self.version = re.search(r'zcash_[^ ]+ \d+(\.\d+)+', child.title).group()
self.version_ints = tuple(int(x) for x in self.version.split(' ')[1].split('.'))
else:
self.version = None
if repo_group == RUST:
version = re.search(r'zcash_[^ ]+ \d+(\.\d+)+', child.title)
if version:
self.version = version.group()
self.version_ints = tuple(int(x) for x in self.version.split(' ')[1].split('.'))
if self.version is None:
self.version = re.search(r'\d+(\.\d+)+', child.title).group()
self.version_ints = tuple(int(x) for x in self.version.split('.'))

Expand All @@ -51,21 +59,21 @@ def __repr__(self):
return self.version

def __eq__(self, other):
return (self.repo_id, self.version) == (other.repo_id, other.version)
return (self.repo_group, self.version) == (other.repo_group, other.version)

def __hash__(self):
return hash((self.repo_id, self.version))
return hash((self.repo_group, self.version))

def __lt__(self, other):
return self.version_ints < other.version_ints


def build_release(row, repo_id):
child = row.get(repo_id)
def build_release(row, repo_group):
child = row.get(repo_group)
if child is None:
return None
else:
return Release(repo_id, child)
return Release(repo_group, child)


class ReleasePipeline:
Expand Down Expand Up @@ -97,14 +105,14 @@ def columns(self):
self.zashi_ios,
)

def build_release_matrix_from(dg, issue, repo_id):
def build_release_matrix_from(dg, issue, repo_group):
acc = []
for child in dg.neighbors(issue):
if child.repo.gh_id == repo_id and 'C-release' in child.labels:
if child.repo in repo_group and 'C-release' in child.labels:
# Fetch the rows that each child's downstreams need rendered.
child_deps = [
build_release_matrix_from(dg, child, dep_repo)
for dep_repo in RELEASE_MATRIX.get(repo_id)
for dep_repo in RELEASE_MATRIX.get(repo_group)
]

# Merge the rows from each downstream repo together.
Expand All @@ -115,13 +123,13 @@ def build_release_matrix_from(dg, issue, repo_id):

if len(child_releases) > 0:
for rec in child_releases:
rec[repo_id] = child
rec[repo_group] = child
else:
child_releases = [{repo_id: child}]
child_releases = [{repo_group: child}]

acc.extend(child_releases)
else:
acc.extend(build_release_matrix_from(dg, child, repo_id))
acc.extend(build_release_matrix_from(dg, child, repo_group))

return acc

Expand Down Expand Up @@ -263,8 +271,11 @@ def main():

for issue in tracked_issues.values():
rows = [ReleasePipeline(row) for row in build_release_matrix_from(dg, issue, RUST)]

# If we traversed the entire graph and there are no releases downstream of the
# issue, show this as an empty row.
if len(rows) == 0:
continue
rows = [ReleasePipeline({})]

# Deduplicate rows
rows = list(dict.fromkeys(rows))
Expand Down

0 comments on commit f9f58fd

Please sign in to comment.