Skip to content

Commit f0841dc

Browse files
committed
Make build_url nullable
1 parent 886723c commit f0841dc

5 files changed

Lines changed: 21 additions & 12 deletions

File tree

pgcommitfest/commitfest/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,9 @@ class CfbotBranch(models.Model):
932932
commit_id = models.TextField(null=True, blank=True)
933933
apply_url = models.TextField(null=False)
934934
# URL of the CI build for this branch. Sent by cfbot so we don't have to
935-
# know which CI provider it uses.
936-
build_url = models.TextField(null=False)
935+
# know which CI provider it uses. It's null until cfbot hears about the
936+
# branch's first build, and "timeout" branches might never get one.
937+
build_url = models.TextField(null=True, blank=True)
937938
# Actually a postgres enum column
938939
status = models.TextField(choices=STATUS_CHOICES, null=False)
939940
needs_rebase_since = models.DateTimeField(null=True, blank=True)

pgcommitfest/commitfest/templates/commitfest.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
7474
</a>
7575
{%else%}
7676
<a href="https://github.com/postgresql-cfbot/postgresql/compare/cf/{{p.id}}~1...cf/{{p.id}}" title="View last patch set on GitHub"><img class="github-logo" src="/media/commitfest/github-mark.svg"/></a>
77-
<a href="{{cfb.build_url}}"
77+
{# Until cfbot has seen the branch's first build there is no build_url, #}
78+
{# in that case we show the status icon and counters without a link. #}
79+
{%if cfb.build_url%}<a href="{{cfb.build_url}}"{%else%}<span{%endif%}
7880
title="View CI history. {%if p.failing_since%}Failing {% cfsince p.failing_since %}. {%endif%}{%if cfb.failed_task_names %}Failed jobs: {{cfb.failed_task_names}}{%endif%}">
7981
{%if cfb.branch_status == 'failed' or cfb.branch_status == 'timeout' or cfb.failed_non_formatting > 0 %}
8082
<img src="/media/commitfest/new_failure.svg"/>
@@ -88,7 +90,7 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
8890
<span class="run-counters">
8991
{{cfb.completed}}/{{cfb.total}}
9092
</span>
91-
</a>
93+
{%if cfb.build_url%}</a>{%else%}</span>{%endif%}
9294
{%endif%}
9395
</td>
9496
<td>

pgcommitfest/commitfest/templates/home.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ <h3>{%if user.is_authenticated%}Open patches you are subscribed to{%elif p.is_op
180180
</a>
181181
{%else%}
182182
<a href="https://github.com/postgresql-cfbot/postgresql/compare/cf/{{p.id}}~1...cf/{{p.id}}" title="View last patch set on GitHub"><img class="github-logo" src="/media/commitfest/github-mark.svg"/></a>
183-
<a href="{{cfb.build_url}}"
183+
{# Until cfbot has seen the branch's first build there is no build_url, #}
184+
{# in that case we show the status icon and counters without a link. #}
185+
{%if cfb.build_url%}<a href="{{cfb.build_url}}"{%else%}<span{%endif%}
184186
title="View CI history. {%if p.failing_since%}Failing {% cfsince p.failing_since %}. {%endif%}{%if cfb.failed_task_names %}Failed jobs: {{cfb.failed_task_names}}{%endif%}">
185187
{%if cfb.branch_status == 'failed' or cfb.branch_status == 'timeout' or cfb.failed_non_formatting > 0 %}
186188
<img src="/media/commitfest/new_failure.svg"/>
@@ -194,7 +196,7 @@ <h3>{%if user.is_authenticated%}Open patches you are subscribed to{%elif p.is_op
194196
<span class="run-counters">
195197
{{cfb.completed}}/{{cfb.total}}
196198
</span>
197-
</a>
199+
{%if cfb.build_url%}</a>{%else%}</span>{%endif%}
198200
{%endif%}
199201
</td>
200202
<td>

pgcommitfest/commitfest/templates/patch.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@
2929
<span class="badge bg-warning" title="View git apply logs">Needs rebase!</span></a>
3030
Needs rebase {% cfsince cfbot_branch.needs_rebase_since %}. {%if cfbot_branch.failing_since and cfbot_branch.failing_since != cfbot_branch.needs_rebase_since %}Failing {% cfsince cfbot_branch.failing_since %}. {%endif%}<br>Additional links previous successfully applied patch (outdated):<br>
3131
<a href="https://github.com/postgresql-cfbot/postgresql/compare/cf/{{patch.id}}~1...cf/{{patch.id}}" title="View previous successfully applied patch set on GitHub"><img class="github-logo" src="/media/commitfest/github-mark.svg"/></a>
32-
<a href="{{cfbot_branch.build_url}}">
33-
<span class="badge bg-secondary">Summary</span></a>
32+
{%if cfbot_branch.build_url%}
33+
<a href="{{cfbot_branch.build_url}}">
34+
<span class="badge bg-secondary">Summary</span></a>
35+
{%endif%}
3436
{%else%}
3537
<a href="https://github.com/postgresql-cfbot/postgresql/compare/cf/{{patch.id}}~1...cf/{{patch.id}}" title="View last patch set on GitHub"><img class="github-logo" src="/media/commitfest/github-mark.svg"/></a>
36-
<a href="{{cfbot_branch.build_url}}">
37-
<span class="badge bg-secondary">Summary</span></a>
38+
{%if cfbot_branch.build_url%}
39+
<a href="{{cfbot_branch.build_url}}">
40+
<span class="badge bg-secondary">Summary</span></a>
41+
{%endif%}
3842
{%for c in cfbot_tasks %}
3943
{%if c.status == 'COMPLETED'%}
4044
<a href="{{c.task_url}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/new_success.svg"/></a>

pgcommitfest/commitfest/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ def cfbot_ingest(message):
16001600
branch_status["branch_name"],
16011601
branch_status["commit_id"],
16021602
branch_status["apply_url"],
1603-
branch_status.get("build_url", ""),
1603+
branch_status["build_url"],
16041604
branch_status["status"],
16051605
branch_status["created"],
16061606
branch_status["modified"],
@@ -1642,7 +1642,7 @@ def cfbot_ingest(message):
16421642
WHERE commitfest_cfbottask.modified < EXCLUDED.modified""",
16431643
(
16441644
task_status["task_id"],
1645-
task_status.get("task_url", ""),
1645+
task_status["task_url"],
16461646
task_status["task_name"],
16471647
patch_id,
16481648
branch_id,

0 commit comments

Comments
 (0)