Skip to content

Commit

Permalink
Add a list of failing builds to the user page (hail-is#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoterba authored and cseed committed Sep 19, 2018
1 parent e0279ea commit b8f7be9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
16 changes: 12 additions & 4 deletions scorecard/scorecard.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def get_user(user):
user_data = {
'CHANGES_REQUESTED': [],
'NEEDS_REVIEW': [],
'FAILING': [],
'ISSUES': []
}

Expand All @@ -124,6 +125,9 @@ def get_user(user):
else:
assert state == 'APPROVED'

if pr['status'] == 'failure' and user == pr['user']:
user_data['FAILING'].append(pr)

for issue in repo_data['issues']:
if user in issue['assignees']:
user_data['ISSUES'].append(issue)
Expand All @@ -139,7 +143,7 @@ def get_id(repo_name, number):
else:
return f'{repo_name}/{number}'

def get_pr_data(repo_name, pr):
def get_pr_data(repo, repo_name, pr):
assignees = [a.login for a in pr.assignees]

state = 'NEEDS_REVIEW'
Expand All @@ -154,15 +158,19 @@ def get_pr_data(repo_name, pr):
break
else:
assert review.state == 'COMMENTED'


sha = pr.head.sha
status = repo.get_commit(sha=sha).get_combined_status().state

return {
'repo': repo_name,
'id': get_id(repo_name, pr.number),
'title': pr.title,
'user': pr.user.login,
'assignees': assignees,
'html_url': pr.html_url,
'state': state
'state': state,
'status': status
}

def get_issue_data(repo_name, issue):
Expand Down Expand Up @@ -193,7 +201,7 @@ def update_data():
repo = github.get_repo(fq_repo)

for pr in repo.get_pulls(state='open'):
pr_data = get_pr_data(repo_name, pr)
pr_data = get_pr_data(repo, repo_name, pr)
new_data[repo_name]['prs'].append(pr_data)

for issue in repo.get_issues(state='open'):
Expand Down
30 changes: 23 additions & 7 deletions scorecard/templates/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@
<h3>Needs Review</h3>
{% if user_data['NEEDS_REVIEW'] %}
<table>
<thead>
<tr>
<th align="left">id</th>
<th align="left">author</th>
<th align="left">title</th>
</tr>
</thead>
<tbody>
{% for pr in user_data['NEEDS_REVIEW'] %}
<tr>
Expand Down Expand Up @@ -75,6 +68,29 @@ <h3>Changes Requested</h3>
<p>No changes requested.</p>
{% endif %}

<h3>Failing tests</h3>
{% if user_data['FAILING'] %}
<table>
<thead>
<tr>
<th align="left">id</th>
<th align="left">title</th>
</tr>
</thead>
<tbody>
{% for pr in user_data['FAILING'] %}
<tr>
<td><a href="{{ pr.html_url }}">{{ pr.id }}</a></td>
<td>{{ pr.title }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No failing builds.</p>
{% endif %}


<h3>Issues</h3>
{% if user_data['ISSUES'] %}
<table>
Expand Down

0 comments on commit b8f7be9

Please sign in to comment.