-
-
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
Merged
+249
−0
Merged
Changes from 6 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ae1b38b
Initial plan
Copilot 93f3bae
Add automatic project disabling after 50 consecutive failed builds
Copilot a935aae
Address code review feedback: improve code clarity and naming
Copilot 70b50cb
Update code to simplify checking for N consecutive failed builds usin…
humitos 1b8fdcb
Address review feedback: move docs section, use settings, simplify tests
Copilot 31cfff7
Apply suggestion from @humitos
humitos 2379e21
Apply suggestion from @humitos
humitos a93cbf3
Convert consecutive builds check to Celery task for database access
Copilot e4f51d1
Updates to use project slug and cancel the notification
humitos 0e469a4
Apply suggestion from @humitos
humitos d5dc06d
Add comment explaining early return check and simplify consecutive bu…
Copilot cdcdd7c
Revert task logic to use groupby for consecutive build checking
Copilot 021918f
Trigger the task from `on_failure` insteead of a Django signal
humitos 729b337
Give the user the ability to re-eanble builds
humitos eb5fff1
Make the project as non-active if it has N+ consecutive failed builds
humitos 212b7c2
Update notification copy
humitos 26a0469
Reduce N+ failed builds to 25 from 50
humitos 64334ab
Don't disable project builds on Read the Docs for Business
humitos d330cb4
Feedback received
humitos b535aa7
Fix test
humitos 31f0696
Update docs to reflect changes
humitos f78911f
Move the check for private repositories before triggering the task
humitos 1dc405c
Simplify counting of consecutive failed builds
humitos 8aea75c
Add a test case to verify the project is not disabled
humitos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
humitos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """Tests for build signal receivers.""" | ||
|
|
||
| from django.conf import settings | ||
| from django.test import TestCase, override_settings | ||
| from django_dynamic_fixture import get | ||
|
|
||
| from readthedocs.builds.constants import BUILD_STATE_FINISHED, LATEST | ||
| from readthedocs.builds.models import Build | ||
| from readthedocs.builds.signals_receivers import ( | ||
| disable_project_on_consecutive_failed_builds, | ||
| ) | ||
| from readthedocs.notifications.models import Notification | ||
| from readthedocs.projects.models import Project | ||
| from readthedocs.projects.notifications import ( | ||
| MESSAGE_PROJECT_BUILDS_DISABLED_DUE_TO_CONSECUTIVE_FAILURES, | ||
| ) | ||
|
|
||
|
|
||
| class TestDisableProjectOnConsecutiveFailedBuilds(TestCase): | ||
| def setUp(self): | ||
| self.project = get(Project, slug="test-project", skip=False) | ||
| self.version = self.project.versions.get(slug=LATEST) | ||
| self.version.active = True | ||
| self.version.save() | ||
|
|
||
| def _create_builds(self, count, success=False): | ||
| """Helper to create a series of builds.""" | ||
| builds = [] | ||
| for _ in range(count): | ||
| build = get( | ||
| Build, | ||
| project=self.project, | ||
| version=self.version, | ||
| success=success, | ||
| state=BUILD_STATE_FINISHED, | ||
| ) | ||
| builds.append(build) | ||
| return builds | ||
|
|
||
| @override_settings(RTD_BUILDS_MAX_CONSECUTIVE_FAILURES=50) | ||
| def test_signal_handler_disables_at_threshold(self): | ||
| """Test that the project is disabled at the failure threshold.""" | ||
| # Create failures at the threshold | ||
| self._create_builds(settings.RTD_BUILDS_MAX_CONSECUTIVE_FAILURES + 1, success=False) | ||
|
|
||
| build_dict = { | ||
| "success": False, | ||
| "project": self.project.pk, | ||
| "version_slug": self.version.slug, | ||
| } | ||
| disable_project_on_consecutive_failed_builds( | ||
| sender=Build, build=build_dict | ||
| ) | ||
|
|
||
| self.project.refresh_from_db() | ||
| self.assertTrue(self.project.skip) | ||
|
|
||
| # Verify notification was added | ||
| notification = Notification.objects.filter( | ||
| message_id=MESSAGE_PROJECT_BUILDS_DISABLED_DUE_TO_CONSECUTIVE_FAILURES | ||
| ).first() | ||
| self.assertIsNotNone(notification) | ||
| self.assertEqual(notification.attached_to, self.project) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.