Skip to content

Commit 499120c

Browse files
committed
Use the build and task URLs provided by CFBot
1 parent d33830d commit 499120c

7 files changed

Lines changed: 73 additions & 14 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Generated by Django 5.2.12 on 2026-06-04 06:54
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("commitfest", "0018_undo_pg19_final_close"),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name="cfbotbranch",
14+
name="build_url",
15+
field=models.TextField(blank=True, null=True),
16+
),
17+
migrations.AddField(
18+
model_name="cfbottask",
19+
name="task_url",
20+
field=models.TextField(blank=True, null=True),
21+
),
22+
# Backfill existing rows, which all predate cfbot sending these URLs
23+
# and thus are known to be Cirrus CI builds with deterministic URLs.
24+
migrations.RunSQL(
25+
"""UPDATE commitfest_cfbotbranch
26+
SET build_url = 'https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F' || patch_id""",
27+
reverse_sql=migrations.RunSQL.noop,
28+
),
29+
migrations.RunSQL(
30+
"""UPDATE commitfest_cfbottask
31+
SET task_url = 'https://cirrus-ci.com/task/' || task_id""",
32+
reverse_sql=migrations.RunSQL.noop,
33+
),
34+
# The fields are added as nullable and only made NOT NULL here, after
35+
# the backfill has filled in all existing rows.
36+
migrations.AlterField(
37+
model_name="cfbotbranch",
38+
name="build_url",
39+
field=models.TextField(),
40+
),
41+
migrations.AlterField(
42+
model_name="cfbottask",
43+
name="task_url",
44+
field=models.TextField(),
45+
),
46+
]

pgcommitfest/commitfest/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,9 @@ class CfbotBranch(models.Model):
931931
branch_name = models.TextField(null=False)
932932
commit_id = models.TextField(null=True, blank=True)
933933
apply_url = models.TextField(null=False)
934+
# 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)
934937
# Actually a postgres enum column
935938
status = models.TextField(choices=STATUS_CHOICES, null=False)
936939
needs_rebase_since = models.DateTimeField(null=True, blank=True)
@@ -978,6 +981,9 @@ class CfbotTask(models.Model):
978981
# CI provider might use e.g. UUIDs, we prefer to consider the format of the
979982
# ID opaque and store it as text.
980983
task_id = models.TextField()
984+
# URL of the task in the CI system. Sent by cfbot so we don't have to know
985+
# which CI provider it uses.
986+
task_url = models.TextField(null=False)
981987
task_name = models.TextField(null=False)
982988
patch = models.ForeignKey(
983989
Patch, on_delete=models.CASCADE, related_name="cfbot_tasks"

pgcommitfest/commitfest/templates/commitfest.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ <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="https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F{{p.id}}"
77+
<a href="{{cfb.build_url}}"
7878
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%}">
7979
{%if cfb.branch_status == 'failed' or cfb.branch_status == 'timeout' or cfb.failed_non_formatting > 0 %}
8080
<img src="/media/commitfest/new_failure.svg"/>

pgcommitfest/commitfest/templates/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ <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="https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F{{p.id}}"
183+
<a href="{{cfb.build_url}}"
184184
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%}">
185185
{%if cfb.branch_status == 'failed' or cfb.branch_status == 'timeout' or cfb.failed_non_formatting > 0 %}
186186
<img src="/media/commitfest/new_failure.svg"/>

pgcommitfest/commitfest/templates/patch.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@
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="https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F{{patch.id}}">
32+
<a href="{{cfbot_branch.build_url}}">
3333
<span class="badge bg-secondary">Summary</span></a>
3434
{%else%}
3535
<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="https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F{{patch.id}}">
36+
<a href="{{cfbot_branch.build_url}}">
3737
<span class="badge bg-secondary">Summary</span></a>
3838
{%for c in cfbot_tasks %}
3939
{%if c.status == 'COMPLETED'%}
40-
<a href="https://cirrus-ci.com/task/{{c.task_id}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/new_success.svg"/></a>
40+
<a href="{{c.task_url}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/new_success.svg"/></a>
4141
{%elif c.status == 'PAUSED'%}
42-
<a href="https://cirrus-ci.com/task/{{c.task_id}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/paused.svg"/></a>
42+
<a href="{{c.task_url}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/paused.svg"/></a>
4343
{%elif c.status == 'CREATED' or c.status == 'SCHEDULED' %}
44-
<a href="https://cirrus-ci.com/task/{{c.task_id}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/waiting_to_start.svg"/></a>
44+
<a href="{{c.task_url}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/waiting_to_start.svg"/></a>
4545
{%elif c.status == 'EXECUTING' %}
46-
<a href="https://cirrus-ci.com/task/{{c.task_id}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/running.svg"/></a>
46+
<a href="{{c.task_url}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/running.svg"/></a>
4747
{%else %}
4848
{%if c.task_name == 'FormattingCheck' %}
49-
<a href="https://cirrus-ci.com/task/{{c.task_id}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/formatting_failure.svg"/></a>
49+
<a href="{{c.task_url}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/formatting_failure.svg"/></a>
5050
{%else%}
51-
<a href="https://cirrus-ci.com/task/{{c.task_id}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/new_failure.svg"/></a>
51+
<a href="{{c.task_url}}" title="{{c.task_name}}: {{c.status}}"><img src="/media/commitfest/new_failure.svg"/></a>
5252
{%endif%}
5353
{%endif%}
5454
{%endfor%}

pgcommitfest/commitfest/tests/test_closure_notifications.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ def test_no_auto_move_when_failing_too_long(alice, in_progress_cf, open_cf):
290290
branch_id=1,
291291
branch_name="test-branch",
292292
apply_url="https://example.com",
293+
build_url="https://example.com/build/1",
293294
status="failed",
294295
failing_since=datetime.now()
295296
- timedelta(days=settings.AUTO_MOVE_MAX_FAILING_DAYS + 10),
@@ -329,6 +330,7 @@ def test_auto_move_when_failing_within_threshold(alice, in_progress_cf, open_cf)
329330
branch_id=2,
330331
branch_name="test-branch-2",
331332
apply_url="https://example.com",
333+
build_url="https://example.com/build/2",
332334
status="failed",
333335
failing_since=datetime.now()
334336
- timedelta(days=settings.AUTO_MOVE_MAX_FAILING_DAYS - 5),

pgcommitfest/commitfest/views.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ def patchlist(request, cf, personalized=False):
575575
string_agg(task.task_name, ', ') FILTER (WHERE task.status in ('ABORTED', 'ERRORED', 'FAILED')) as failed_task_names,
576576
branch.status as branch_status,
577577
branch.apply_url,
578+
branch.build_url,
578579
branch.patch_count,
579580
branch.all_additions,
580581
branch.all_deletions
@@ -1567,20 +1568,21 @@ def cfbot_ingest(message):
15671568
cursor.execute(
15681569
"""INSERT INTO commitfest_cfbotbranch (patch_id, branch_id,
15691570
branch_name, commit_id,
1570-
apply_url, status,
1571+
apply_url, build_url, status,
15711572
created, modified,
15721573
version, patch_count,
15731574
first_additions, first_deletions,
15741575
all_additions, all_deletions
15751576
)
1576-
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
1577+
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
15771578
ON CONFLICT (patch_id) DO UPDATE
15781579
SET status = EXCLUDED.status,
15791580
modified = EXCLUDED.modified,
15801581
branch_id = EXCLUDED.branch_id,
15811582
branch_name = EXCLUDED.branch_name,
15821583
commit_id = EXCLUDED.commit_id,
15831584
apply_url = EXCLUDED.apply_url,
1585+
build_url = EXCLUDED.build_url,
15841586
created = EXCLUDED.created,
15851587
version = EXCLUDED.version,
15861588
patch_count = EXCLUDED.patch_count,
@@ -1598,6 +1600,7 @@ def cfbot_ingest(message):
15981600
branch_status["branch_name"],
15991601
branch_status["commit_id"],
16001602
branch_status["apply_url"],
1603+
branch_status["build_url"],
16011604
branch_status["status"],
16021605
branch_status["created"],
16031606
branch_status["modified"],
@@ -1625,19 +1628,21 @@ def cfbot_ingest(message):
16251628
task_status = message["task_status"]
16261629
if task_status["status"] in [x[0] for x in CfbotTask.STATUS_CHOICES]:
16271630
cursor.execute(
1628-
"""INSERT INTO commitfest_cfbottask (task_id, task_name, patch_id, branch_id,
1631+
"""INSERT INTO commitfest_cfbottask (task_id, task_url, task_name, patch_id, branch_id,
16291632
position, status,
16301633
created, modified)
1631-
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
1634+
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
16321635
ON CONFLICT (branch_id, position) DO UPDATE
16331636
SET task_id = EXCLUDED.task_id,
1637+
task_url = EXCLUDED.task_url,
16341638
task_name = EXCLUDED.task_name,
16351639
status = EXCLUDED.status,
16361640
created = EXCLUDED.created,
16371641
modified = EXCLUDED.modified
16381642
WHERE commitfest_cfbottask.modified < EXCLUDED.modified""",
16391643
(
16401644
task_status["task_id"],
1645+
task_status["task_url"],
16411646
task_status["task_name"],
16421647
patch_id,
16431648
branch_id,

0 commit comments

Comments
 (0)