-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Build: disable builds after 25 consecutive failed builds on default version #12624
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
Changes from all commits
ae1b38b
93f3bae
a935aae
70b50cb
1b8fdcb
31cfff7
2379e21
a93cbf3
e4f51d1
0e469a4
d5dc06d
cdcdd7c
021918f
729b337
eb5fff1
212b7c2
26a0469
64334ab
d330cb4
b535aa7
31f0696
f78911f
1dc405c
8aea75c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,9 @@ | |
| from readthedocs.notifications.models import Notification | ||
| from readthedocs.organizations.models import Organization | ||
| from readthedocs.projects.models import Project | ||
| from readthedocs.projects.notifications import ( | ||
| MESSAGE_PROJECT_BUILDS_DISABLED_DUE_TO_CONSECUTIVE_FAILURES, | ||
| ) | ||
| from readthedocs.projects.notifications import MESSAGE_PROJECT_SKIP_BUILDS | ||
| from readthedocs.subscriptions.notifications import MESSAGE_ORGANIZATION_DISABLED | ||
|
|
||
|
|
@@ -32,6 +35,16 @@ def project_skip_builds(instance, *args, **kwargs): | |
| ) | ||
|
|
||
|
|
||
| @receiver(post_save, sender=Project) | ||
| def project_n_consecutive_failed_builds(instance, *args, **kwargs): | ||
|
Comment on lines
+38
to
+39
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can cancel the notification just once after the value has been changed from the form. Otherwise, we will run the cancel query every time an active project is saved (probably isn't bad, but still...)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but then we need to cancel the notification if we change this value from the Django admin also, and maybe other places. I prefer to follow the same pattern we are following with |
||
| """Check if the project has not N+ consecutive failed builds anymore and cancel the notification.""" | ||
| if not instance.n_consecutive_failed_builds: | ||
| Notification.objects.cancel( | ||
humitos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| message_id=MESSAGE_PROJECT_BUILDS_DISABLED_DUE_TO_CONSECUTIVE_FAILURES, | ||
| attached_to=instance, | ||
| ) | ||
|
|
||
|
|
||
| @receiver(post_save, sender=Organization) | ||
| def organization_disabled(instance, *args, **kwargs): | ||
| """Check if the organization is ``disabled`` and add/cancel the notification.""" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Generated by Django 5.2.7 on 2025-12-02 09:19 | ||
|
|
||
| from django.db import migrations | ||
| from django.db import models | ||
| from django_safemigrate import Safe | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| safe = Safe.before_deploy() | ||
|
|
||
| dependencies = [ | ||
| ("projects", "0156_project_search_indexing_enabled"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="historicalproject", | ||
| name="n_consecutive_failed_builds", | ||
| field=models.BooleanField( | ||
| db_default=False, | ||
| default=False, | ||
| help_text="Builds on this project were automatically disabled due to many consecutive failures. Uncheck this field to re-enable building.", | ||
| verbose_name="Disable builds for this project", | ||
| ), | ||
| ), | ||
| migrations.AddField( | ||
| model_name="project", | ||
| name="n_consecutive_failed_builds", | ||
| field=models.BooleanField( | ||
| db_default=False, | ||
| default=False, | ||
| help_text="Builds on this project were automatically disabled due to many consecutive failures. Uncheck this field to re-enable building.", | ||
| verbose_name="Disable builds for this project", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -524,6 +524,14 @@ class Project(models.Model): | |
| featured = models.BooleanField(_("Featured"), default=False) | ||
|
|
||
| skip = models.BooleanField(_("Skip (disable) building this project"), default=False) | ||
| n_consecutive_failed_builds = models.BooleanField( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can make this a more generic name so it can be used for disabling projects based on other rules (
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, that was my initial thought by using I think it's fine for now to have a specific field for this use case. We can refactor later if we consider that a shared field between multiple reason is better.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, we can also do something like |
||
| _("Disable builds for this project"), | ||
| default=False, | ||
| db_default=False, | ||
| help_text=_( | ||
| "Builds on this project were automatically disabled due to many consecutive failures. Uncheck this field to re-enable building." | ||
| ), | ||
| ) | ||
|
|
||
| # null=True can be removed in a later migration | ||
| # be careful if adding new queries on this, .filter(delisted=False) does not work | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also wonder if there is a way to know that we are dealing with the default version, so we don't call this task for every version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one is tricky because it requires access to the database, so we can't perform this from the build task.