Skip to content

Commit d5a5443

Browse files
committed
Support local cfbot integration development with dummy data (#8)
This adds some basic functionality to allow making changes to the CFBot integration locally, without having to push to prod/staging. To do so this adds the CFBot integration tables to the admin panel and adds some dummy CFBot data to our dummy development dataset. One somewhat interesting thing this required that now the `CfbotBranch` has an overridden `save` method, which stores `NULL` in the commit_id if an empty string is saved. This only impacts the save behaviour of the Django admin interface because the webhook that the actual CFBot calls bypasses the Django models and inserts directly into the underlying tables.
1 parent 262dac4 commit d5a5443

File tree

3 files changed

+152
-0
lines changed

3 files changed

+152
-0
lines changed

pgcommitfest/commitfest/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class MailThreadAttachmentAdmin(admin.ModelAdmin):
2727
admin.site.register(Patch, PatchAdmin)
2828
admin.site.register(PatchHistory)
2929
admin.site.register(TargetVersion)
30+
admin.site.register(CfbotBranch)
31+
admin.site.register(CfbotTask)
3032

3133
admin.site.register(MailThread)
3234
admin.site.register(MailThreadAttachment, MailThreadAttachmentAdmin)

pgcommitfest/commitfest/fixtures/commitfest_data.json

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,5 +369,145 @@
369369
"statusstring": "Withdrawn",
370370
"sortkey": 50
371371
}
372+
},
373+
{
374+
"model": "commitfest.cfbotbranch",
375+
"pk": 1,
376+
"fields": {
377+
"branch_id": 123,
378+
"branch_name": "cf/1",
379+
"commit_id": "abcdefg",
380+
"apply_url": "http://cfbot.cputube.org/patch_4573.log",
381+
"status": "finished",
382+
"needs_rebase_since": null,
383+
"created": "2025-01-26T22:06:02.980",
384+
"modified": "2025-01-26T22:06:02.980"
385+
}
386+
},
387+
{
388+
"model": "commitfest.cfbotbranch",
389+
"pk": 2,
390+
"fields": {
391+
"branch_id": 345,
392+
"branch_name": "cf/2",
393+
"commit_id": null,
394+
"apply_url": "http://cfbot.cputube.org/patch_4573.log",
395+
"status": "failed",
396+
"needs_rebase_since": null,
397+
"created": "2025-01-26T22:11:09.961",
398+
"modified": "2025-01-26T22:20:39.372"
399+
}
400+
},
401+
{
402+
"model": "commitfest.cfbotbranch",
403+
"pk": 3,
404+
"fields": {
405+
"branch_id": 567,
406+
"branch_name": "cf/3",
407+
"commit_id": "abc123",
408+
"apply_url": "http://cfbot.cputube.org/patch_4748.log",
409+
"status": "failed",
410+
"needs_rebase_since": null,
411+
"created": "2025-01-26T22:22:46.602",
412+
"modified": "2025-01-26T22:26:41.587"
413+
}
414+
},
415+
{
416+
"model": "commitfest.cfbottask",
417+
"pk": 1,
418+
"fields": {
419+
"task_id": "12345",
420+
"task_name": "Linux build",
421+
"patch": 1,
422+
"branch_id": 123,
423+
"position": 1,
424+
"status": "COMPLETED",
425+
"created": "2025-01-26T22:06:49.237",
426+
"modified": "2025-01-26T22:07:40.405"
427+
}
428+
},
429+
{
430+
"model": "commitfest.cfbottask",
431+
"pk": 2,
432+
"fields": {
433+
"task_id": "12346",
434+
"task_name": "MacOS Build",
435+
"patch": 1,
436+
"branch_id": 123,
437+
"position": 2,
438+
"status": "COMPLETED",
439+
"created": "2025-01-26T22:07:32.041",
440+
"modified": "2025-01-26T22:07:32.041"
441+
}
442+
},
443+
{
444+
"model": "commitfest.cfbottask",
445+
"pk": 3,
446+
"fields": {
447+
"task_id": "4561",
448+
"task_name": "Redhat",
449+
"patch": 3,
450+
"branch_id": 567,
451+
"position": 1,
452+
"status": "COMPLETED",
453+
"created": "2025-01-26T22:24:37.445",
454+
"modified": "2025-01-26T22:24:37.445"
455+
}
456+
},
457+
{
458+
"model": "commitfest.cfbottask",
459+
"pk": 4,
460+
"fields": {
461+
"task_id": "4562",
462+
"task_name": "MacOS build",
463+
"patch": 3,
464+
"branch_id": 567,
465+
"position": 2,
466+
"status": "EXECUTING",
467+
"created": "2025-01-26T22:25:15.283",
468+
"modified": "2025-01-26T22:27:09.055"
469+
}
470+
},
471+
{
472+
"model": "commitfest.cfbottask",
473+
"pk": 5,
474+
"fields": {
475+
"task_id": "4563",
476+
"task_name": "FreeBSD",
477+
"patch": 3,
478+
"branch_id": 567,
479+
"position": 3,
480+
"status": "FAILED",
481+
"created": "2025-01-26T22:25:48.021",
482+
"modified": "2025-01-26T22:25:48.021"
483+
}
484+
},
485+
{
486+
"model": "commitfest.cfbottask",
487+
"pk": 6,
488+
"fields": {
489+
"task_id": "4564",
490+
"task_name": "NetBSD",
491+
"patch": 3,
492+
"branch_id": 567,
493+
"position": 4,
494+
"status": "CREATED",
495+
"created": "2025-01-26T22:29:09.156",
496+
"modified": "2025-01-26T22:29:09.156"
497+
}
498+
},
499+
{
500+
"model": "commitfest.cfbottask",
501+
"pk": 7,
502+
"fields": {
503+
"task_id": "4565",
504+
"task_name": "Linux Valgrind",
505+
"patch": 3,
506+
"branch_id": 567,
507+
"position": 5,
508+
"status": "SCHEDULED",
509+
"created": "2025-01-26T22:30:03.199",
510+
"modified": "2025-01-26T22:30:03.199"
511+
}
372512
}
373513
]

pgcommitfest/commitfest/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,16 @@ class CfbotBranch(models.Model):
381381
created = models.DateTimeField(auto_now_add=True)
382382
modified = models.DateTimeField(auto_now=True)
383383

384+
def save(self, *args, **kwargs):
385+
"""Only used by the admin panel to save empty commit id as NULL
386+
387+
The actual cfbot webhook doesn't use the django ORM to save the data.
388+
"""
389+
390+
if not self.commit_id:
391+
self.commit_id = None
392+
super(CfbotBranch, self).save(*args, **kwargs)
393+
384394

385395
class CfbotTask(models.Model):
386396
STATUS_CHOICES = [

0 commit comments

Comments
 (0)