Handle "no workspace containing repo" errors gracefully

This commit is contained in:
Jack Grigg 2024-11-02 11:45:14 +13:00
parent e3b9d60b59
commit e5ae7c59c0
1 changed files with 11 additions and 5 deletions

View File

@ -21,8 +21,12 @@ DAG_VIEW = os.environ.get('DAG_VIEW', 'core')
REPOS = github.REPO_SETS[DAG_VIEW]
WORKSPACES = {
workspace_id: [repo_id for repo_id in repos if repo_id in REPOS]
for (workspace_id, repos) in zenhub.WORKSPACE_SETS.items()
workspace_id: repos
for (workspace_id, repos) in {
workspace_id: [repo_id for repo_id in repos if repo_id in REPOS]
for (workspace_id, repos) in zenhub.WORKSPACE_SETS.items()
}.items()
if len(repos) > 0
}
SUPPORTED_CATEGORIES = set(['releases', 'targets'])
@ -57,12 +61,15 @@ def main():
gapi = github.api(GITHUB_TOKEN)
zapi = zenhub.api(ZENHUB_TOKEN)
if len(WORKSPACES) == 0:
print('Error: DAG_VIEW="{}" has no matching ZenHub workspaces'.format(DAG_VIEW))
return
# Build the full dependency graph from ZenHub's per-workspace API.
print('Fetching graph')
dg = nx.compose_all([
zenhub.get_dependency_graph(zapi, workspace_id, repos)
for (workspace_id, repos) in WORKSPACES.items()
if len(repos) > 0
])
print('Rendering DAG')
@ -70,8 +77,7 @@ def main():
if SHOW_EPICS:
epics_issues = []
for (workspace_id, repos) in WORKSPACES.items():
if len(repos) > 0:
epics_issues += zenhub.get_epics(zapi, workspace_id, repos)
epics_issues += zenhub.get_epics(zapi, workspace_id, repos)
epics_issues = set(epics_issues)
epics_mapping = github.download_issues(gapi, [gh_ref for (_, gh_ref) in epics_issues], REPOS)