Skip to content

Allow sorting commitfest entries by "failing since" #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 97 additions & 4 deletions pgcommitfest/commitfest/fixtures/commitfest_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,27 @@
]
}
},
{
"model": "commitfest.patch",
"pk": 7,
"fields": {
"name": "Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs",
"topic": 3,
"wikilink": "",
"gitlink": "",
"targetversion": null,
"committer": null,
"created": "2025-03-01T22:27:53.214",
"modified": "2025-03-01T22:27:53.221",
"lastmail": "2025-01-18T07:14:02",
"authors": [],
"reviewers": [],
"subscribers": [],
"mailthread_set": [
7
]
}
},
{
"model": "commitfest.patchoncommitfest",
"pk": 1,
Expand Down Expand Up @@ -293,6 +314,17 @@
"status": 6
}
},
{
"model": "commitfest.patchoncommitfest",
"pk": 8,
"fields": {
"patch": 7,
"commitfest": 2,
"enterdate": "2025-03-01T22:27:53.214",
"leavedate": null,
"status": 1
}
},
{
"model": "commitfest.patchhistory",
"pk": 1,
Expand Down Expand Up @@ -480,6 +512,28 @@
"what": "Closed in commitfest Sample In Progress Commitfest with status: Rejected"
}
},
{
"model": "commitfest.patchhistory",
"pk": 18,
"fields": {
"patch": 7,
"date": "2025-03-01T22:27:53.215",
"by": 1,
"by_cfbot": false,
"what": "Created patch record"
}
},
{
"model": "commitfest.patchhistory",
"pk": 19,
"fields": {
"patch": 7,
"date": "2025-03-01T22:27:53.218",
"by": 1,
"by_cfbot": false,
"what": "Attached mail thread example@message-31"
}
},
{
"model": "commitfest.mailthread",
"pk": 1,
Expand Down Expand Up @@ -564,6 +618,20 @@
"latestmsgid": "example@message-16"
}
},
{
"model": "commitfest.mailthread",
"pk": 7,
"fields": {
"messageid": "example@message-31",
"subject": "Re: Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs",
"firstmessage": "2025-01-18T07:14:02",
"firstauthor": "test@test.com",
"latestmessage": "2025-01-18T07:14:02",
"latestauthor": "test@test.com",
"latestsubject": "Re: Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs",
"latestmsgid": "example@message-31"
}
},
{
"model": "commitfest.patchstatus",
"pk": 1,
Expand Down Expand Up @@ -638,6 +706,7 @@
"apply_url": "http://cfbot.cputube.org/patch_4573.log",
"status": "finished",
"needs_rebase_since": null,
"failing_since": null,
"created": "2025-01-26T22:06:02.980",
"modified": "2025-01-29T22:50:37.805",
"version": "",
Expand All @@ -657,10 +726,11 @@
"commit_id": null,
"apply_url": "http://cfbot.cputube.org/patch_4573.log",
"status": "failed",
"needs_rebase_since": null,
"needs_rebase_since": "2025-03-01T22:30:42",
"failing_since": "2025-02-01T22:30:42",
"created": "2025-01-26T22:11:09.961",
"modified": "2025-01-26T22:20:39.372",
"version": null,
"modified": "2025-03-01T22:59:14.717",
"version": "",
"patch_count": null,
"first_additions": null,
"first_deletions": null,
Expand All @@ -678,8 +748,9 @@
"apply_url": "http://cfbot.cputube.org/patch_4748.log",
"status": "failed",
"needs_rebase_since": null,
"failing_since": "2025-03-01T23:18:06",
"created": "2025-01-26T22:22:46.602",
"modified": "2025-01-29T22:58:51.032",
"modified": "2025-03-01T23:18:10.856",
"version": "",
"patch_count": 3,
"first_additions": 345,
Expand All @@ -698,6 +769,7 @@
"apply_url": "http://cfbot.cputube.org/patch_4748.log",
"status": "testing",
"needs_rebase_since": null,
"failing_since": null,
"created": "2025-01-31T13:32:22.017",
"modified": "2025-01-31T13:32:22.017",
"version": "",
Expand All @@ -708,6 +780,27 @@
"all_deletions": 14
}
},
{
"model": "commitfest.cfbotbranch",
"pk": 7,
"fields": {
"branch_id": 12,
"branch_name": "cf/7",
"commit_id": "efg123",
"apply_url": "http://cfbot.cputube.org/patch_7.log",
"status": "timeout",
"needs_rebase_since": null,
"failing_since": "2025-03-01T22:29:07",
"created": "2025-03-01T22:29:25.461",
"modified": "2025-03-01T22:30:14.495",
"version": "",
"patch_count": 1,
"first_additions": 1,
"first_deletions": 2,
"all_additions": 1,
"all_deletions": 2
}
},
{
"model": "commitfest.cfbottask",
"pk": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.19 on 2025-03-01 13:53

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("commitfest", "0009_extra_branch_fields"),
]

operations = [
migrations.AddField(
model_name="cfbotbranch",
name="failing_since",
field=models.DateTimeField(blank=True, null=True),
),
]
1 change: 1 addition & 0 deletions pgcommitfest/commitfest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ class CfbotBranch(models.Model):
# Actually a postgres enum column
status = models.TextField(choices=STATUS_CHOICES, null=False)
needs_rebase_since = models.DateTimeField(null=True, blank=True)
failing_since = models.DateTimeField(null=True, blank=True)
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
version = models.TextField(null=True, blank=True)
Expand Down
22 changes: 12 additions & 10 deletions pgcommitfest/commitfest/templates/commitfest.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(4);">ID</a>{%if sortkey == 4%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -4%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
<th>Status</th>
<th>Ver</th>
<th>CI status</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(7);">CI status</a>{%if sortkey == 7%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -7%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(6);">Stats</a>{%if sortkey == 6%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -6%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
<th>Author</th>
<th>Reviewers</th>
Expand All @@ -91,34 +91,36 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
<td><span class="label label-{{p.status|patchstatuslabel}}">{{p.status|patchstatusstring}}</span></td>
<td>{%if p.targetversion%}<span class="label label-default">{{p.targetversion}}</span>{%endif%}</td>
<td class="cfbot-summary">
{%if not p.cfbot_results %}
{%with p.cfbot_results as cfb%}
{%if not cfb %}
<span class="label label-default">Not processed</span>
{%elif p.cfbot_results.needs_rebase %}
<a href="{{p.cfbot_results.apply_url}}" title="View git apply logs">
{%elif p.needs_rebase_since %}
<a href="{{cfb.apply_url}}" title="View git apply logs. Needs rebase since {{p.needs_rebase_since|timesince}}. {%if p.failing_since and p.failing_since != p.needs_rebase_since %}Failing since {{p.failing_since|timesince}}.{%endif%}">
<span class="label label-warning">Needs rebase!</span>
</a>
{%else%}
<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>
<a href="https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F{{p.id}}"
title="View CI history{%if p.cfbot_results.failed_task_names %}. Failed jobs: {{p.cfbot_results.failed_task_names}}{%endif%}">
{%if p.cfbot_results.failed > 0 or p.cfbot_results.branch_status == 'failed' or p.cfbot_results.branch_status == 'timeout' %}
title="View CI history. {%if p.failing_since%}Failing since {{p.failing_since|timesince}}. {%endif%}{%if cfb.failed_task_names %}Failed jobs: {{cfb.failed_task_names}}{%endif%}">
{%if cfb.failed > 0 or cfb.branch_status == 'failed' or cfb.branch_status == 'timeout' %}
<img src="/media/commitfest/new_failure.svg"/>
{%elif p.cfbot_results.completed < p.cfbot_results.total %}
{%elif cfb.completed < cfb.total %}
<img src="/media/commitfest/running.svg"/>
{%else%}
<img src="/media/commitfest/new_success.svg"/>
{%endif%}
<span class="run-counters">
{{p.cfbot_results.completed}}/{{p.cfbot_results.total}}
{{cfb.completed}}/{{cfb.total}}
</span>
</a>
{%endif%}
</td>
<td>
{%if p.cfbot_results and p.cfbot_results.all_additions is not none %}
<span class="additions">+{{ p.cfbot_results.all_additions }}</span><span class="deletions">&#8722;{{ p.cfbot_results.all_deletions }}</span>
{%if cfb and cfb.all_additions is not none %}
<span class="additions">+{{ cfb.all_additions }}</span><span class="deletions">&#8722;{{ cfb.all_deletions }}</span>
{%endif%}
</td>
{%endwith%}
<td>{{p.author_names|default:''}}</td>
<td>{{p.reviewer_names|default:''}}</td>
<td>{{p.committer|default:''}}</td>
Expand Down
4 changes: 2 additions & 2 deletions pgcommitfest/commitfest/templates/patch.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<td>
{%if not cfbot_branch %}
<span class="label label-default">Not processed</span></a>
{%elif not cfbot_branch.commit_id %}
{%elif cfbot_branch.needs_rebase_since %}
<a href="{{cfbot_branch.apply_url}}">
<span class="label label-warning" title="View git apply logs">Needs rebase!</span></a>
Additional links previous successfully applied patch (outdated):
Needs rebase since {{cfbot_branch.needs_rebase_since|timesince}}. {%if cfbot_branch.failing_since and cfbot_branch.failing_since != cfbot_branch.needs_rebase_since %}Failing since {{cfbot_branch.failing_since|timesince}}. {%endif%}<br>Additional links previous successfully applied patch (outdated):<br>
<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>
<a href="https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F{{patch.id}}">
<span class="label label-default">Summary</span></a>
Expand Down
33 changes: 29 additions & 4 deletions pgcommitfest/commitfest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ def commitfest(request, cfid):
)
elif sortkey == -6:
orderby_str = "branch.all_additions + branch.all_deletions DESC NULLS LAST, created DESC"
elif sortkey == 7:
orderby_str = "branch.failing_since DESC NULLS FIRST, branch.created DESC"
elif sortkey == -7:
orderby_str = "branch.failing_since NULLS LAST, branch.created"
else:
orderby_str = "p.id"
sortkey = 0
Expand Down Expand Up @@ -294,6 +298,8 @@ def commitfest(request, cfid):
(SELECT string_agg(first_name || ' ' || last_name || ' (' || username || ')', ', ') FROM auth_user INNER JOIN commitfest_patch_authors cpa ON cpa.user_id=auth_user.id WHERE cpa.patch_id=p.id) AS author_names,
(SELECT string_agg(first_name || ' ' || last_name || ' (' || username || ')', ', ') FROM auth_user INNER JOIN commitfest_patch_reviewers cpr ON cpr.user_id=auth_user.id WHERE cpr.patch_id=p.id) AS reviewer_names,
(SELECT count(1) FROM commitfest_patchoncommitfest pcf WHERE pcf.patch_id=p.id) AS num_cfs,
branch.needs_rebase_since,
branch.failing_since,
(
SELECT row_to_json(t) as cfbot_results
from (
Expand All @@ -303,12 +309,9 @@ def commitfest(request, cfid):
count(*) FILTER (WHERE task.status in ('ABORTED', 'ERRORED', 'FAILED')) failed,
count(*) total,
string_agg(task.task_name, ', ') FILTER (WHERE task.status in ('ABORTED', 'ERRORED', 'FAILED')) as failed_task_names,
branch.commit_id IS NULL as needs_rebase,
branch.status as branch_status,
branch.apply_url,
branch.patch_count,
branch.first_additions,
branch.first_deletions,
branch.all_additions,
branch.all_deletions
FROM commitfest_cfbotbranch branch
Expand Down Expand Up @@ -1250,13 +1253,14 @@ def cfbot_ingest(message):
# CONFLICT does not allow us to return that). We need to know the previous
# state so we can skip sending notifications if the needs_rebase status did
# not change.
needs_save = False
needs_rebase = branch_status["commit_id"] is None
if bool(branch_in_db.needs_rebase_since) is not needs_rebase:
if needs_rebase:
branch_in_db.needs_rebase_since = datetime.now()
else:
branch_in_db.needs_rebase_since = None
branch_in_db.save()
needs_save = True

if needs_rebase:
PatchHistory(
Expand All @@ -1270,6 +1274,27 @@ def cfbot_ingest(message):
what="Patch does not need rebase anymore",
).save_and_notify(authors_only=True)

# Similarly, we change the failing_since field using a separate UPDATE
failing = branch_status["status"] in ("failed", "timeout") or needs_rebase
finished = branch_status["status"] == "finished"

if "task_status" in message and message["task_status"]["status"] in (
"ABORTED",
"ERRORED",
"FAILED",
):
failing = True

if (failing or finished) and bool(branch_in_db.failing_since) is not failing:
if failing:
branch_in_db.failing_since = datetime.now()
else:
branch_in_db.failing_since = None
needs_save = True

if needs_save:
branch_in_db.save()


@csrf_exempt
def cfbot_notify(request):
Expand Down