Skip to content

Commit 292a689

Browse files
authored
[ci] Add unauthorized commit as another reason for builds not starting (#15324)
## Change Description Follow on from #15307. Adds "unauthorized commit" as a reason why a commit might have no builds, rather than assuming it's because the build is queued. Also adds a button right next to the message on the PR page for developers to authorize the commit/build immediately. ## Security Assessment - This change potentially impacts the Hail Batch instance as deployed by Broad Institute in GCP ### Impact Rating - This change has a low security impact ### Impact Description - Developer only page - Mostly just adds information. The only active functionality change button is a duplicate of functionality that already exists elsewhere in the UI, just somewhere less convenient. ### Appsec Review - [ ] Required: The impact has been assessed and approved by appsec
1 parent 9c489a3 commit 292a689

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

ci/ci/ci.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,13 @@ async def _populate_batch_context(page_context: Dict[str, Any], batch: Batch) ->
193193
page_context['logging_queries'] = None
194194

195195

196-
async def _populate_active_pr_context(page_context: Dict[str, Any], wb: WatchedBranch, pr_number: int) -> None:
196+
async def _populate_active_pr_context(
197+
page_context: Dict[str, Any], wb: WatchedBranch, pr_number: int, db: Database
198+
) -> None:
197199
pr = wb.prs[pr_number]
198200
page_context['pr'] = pr
199201
page_context['active_pr'] = True
202+
page_context['pr_authorized'] = await pr.authorized(db)
200203

201204
# Merge eligibility checklist
202205
page_context['review_approved'] = pr.review_state == 'approved'
@@ -271,7 +274,7 @@ async def get_pr(request: web.Request, userdata: UserData) -> web.Response:
271274
page_context: Dict[str, Any] = {'repo': wb.branch.repo.short_str(), 'wb': wb}
272275

273276
if wb.prs and pr_number in wb.prs:
274-
await _populate_active_pr_context(page_context, wb, pr_number)
277+
await _populate_active_pr_context(page_context, wb, pr_number, request.app[AppKeys.DB])
275278
else:
276279
await _populate_historical_pr_context(page_context, request.app[AppKeys.GH_CLIENT], wb, pr_number)
277280

ci/ci/templates/pr.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,16 @@ <h3>Jobs</h3>
132132
</pre>
133133
{% else %}
134134
{% if active_pr %}
135-
<p>Build queued - waiting for a build slot. <a href="{{ ci_base_url }}">View CI dashboard</a>.</p>
135+
{% if pr_authorized %}
136+
<p>Build queued - waiting for a build slot. <a href="{{ ci_base_url }}">View CI dashboard</a>.</p>
137+
{% else %}
138+
<p>Build blocked: this PR's latest commit is not authorized. It must be reviewed and approved manually by a developer before authorizing.</p>
139+
<form action="{{ base_path }}/authorize_source_sha" method="post">
140+
<input type="hidden" name="_csrf" value="{{ csrf_token }}"/>
141+
<input type="hidden" name="sha" value="{{ pr.source_sha }}"/>
142+
<button type="submit">Authorize now</button>
143+
</form>
144+
{% endif %}
136145
{% else %}
137146
<p>No builds found.</p>
138147
{% endif %}

0 commit comments

Comments
 (0)