Skip to content

Commit 641ae52

Browse files
committed
Support requeueing CFBot builds
1 parent abac679 commit 641ae52

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

pgcommitfest/commitfest/templates/patch.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
git fetch commitfest cf/{{patch.id}}
5353
git checkout commitfest/cf/{{patch.id}}" onclick="addGitCheckoutToClipboard({{patch.id}})">Copy git checkout commands</button>
5454
{%endif%}
55+
{%if user.is_authenticated%}
56+
<form method="post" action="/patch/{{patch.id}}/cfbot_requeue/" style="display: inline;">
57+
{%csrf_token%}
58+
<button type="submit" class="btn btn-secondary" title="Requeue this patch for CFBot processing">Requeue CFBot</button>
59+
</form>
60+
{%endif%}
5561
</a>
5662
</td>
5763
</tr>

pgcommitfest/commitfest/views.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,3 +1700,35 @@ def thread_notify(request):
17001700
refresh_single_thread(t)
17011701

17021702
return HttpResponse(status=200)
1703+
1704+
1705+
@login_required
1706+
def cfbot_requeue(request, patchid):
1707+
"""Trigger a requeue of a patch in the cfbot."""
1708+
if request.method != "POST":
1709+
return HttpResponseForbidden(b"Invalid method")
1710+
1711+
patch = get_object_or_404(Patch, pk=patchid)
1712+
cf = patch.current_commitfest()
1713+
1714+
# Make API call to cfbot
1715+
import requests
1716+
1717+
payload = {
1718+
"commitfest_id": cf.id,
1719+
"submission_id": patchid,
1720+
"shared_secret": settings.CFBOT_SECRET,
1721+
}
1722+
1723+
try:
1724+
response = requests.post(
1725+
f"{settings.CFBOT_API_URL}/requeue-patch", json=payload, timeout=10
1726+
)
1727+
if response.status_code == 200:
1728+
messages.success(request, "Patch requeued successfully")
1729+
else:
1730+
messages.error(request, f"Failed to requeue patch: {response.status_code}")
1731+
except requests.exceptions.RequestException as e:
1732+
messages.error(request, f"Failed to requeue patch: {e}")
1733+
1734+
return HttpResponseRedirect(f"/patch/{patchid}/")

pgcommitfest/local_settings_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
)
3333

3434
CFBOT_SECRET = "INSECURE"
35+
CFBOT_API_URL = "http://localhost:5000/api"
3536

3637
# There are already commitfests in the default dummy database data.
3738
# Automatically creating new ones would cause the ones that are visible on the

pgcommitfest/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@
166166

167167
AUTO_CREATE_COMMITFESTS = True
168168

169+
CFBOT_API_URL = "https://cfbot.cputube.org/api"
170+
169171
# Load local settings overrides
170172
try:
171173
from .local_settings import * # noqa: F403

pgcommitfest/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
re_path(r"^patch/(\d+)/committer/(become|remove)/$", views.committer),
3737
re_path(r"^patch/(\d+)/(un)?subscribe/$", views.subscribe),
3838
re_path(r"^patch/(\d+)/(comment|review)/", views.comment),
39+
re_path(r"^patch/(\d+)/cfbot_requeue/$", views.cfbot_requeue),
3940
re_path(r"^(\d+)/send_email/$", views.send_email),
4041
re_path(r"^patch/(\d+)/send_email/$", views.send_patch_email),
4142
re_path(r"^(\d+)/reports/authorstats/$", reports.authorstats),

0 commit comments

Comments
 (0)