diff --git a/docs/guides/autobuild-docs-for-pull-requests.rst b/docs/guides/autobuild-docs-for-pull-requests.rst index 0fa7fd3c900..2d82200619c 100644 --- a/docs/guides/autobuild-docs-for-pull-requests.rst +++ b/docs/guides/autobuild-docs-for-pull-requests.rst @@ -2,8 +2,11 @@ Autobuild Documentation for Pull Requests ========================================= Read the Docs allows autobuilding documentation for pull/merge requests for GitHub or GitLab projects. -This feature is currently available under a :doc:`Feature Flag `. -So, you can enable this feature by sending us an `email `__ including your project URL. +This feature is currently enabled for a subset of our projects while being rolled out. +You can check to see if your project has it enabled by looking at the :guilabel:`Admin > Advanced settings` and look for :guilabel:`Build pull requests for this project`. +We are rolling this feature out based on the projects age on Read the Docs, +so older projects will get it first. +You can also ask for this feature by sending us an `email `__ including your project URL. Features -------- diff --git a/readthedocs/api/v2/views/integrations.py b/readthedocs/api/v2/views/integrations.py index d4438e990ce..e08a01c2125 100644 --- a/readthedocs/api/v2/views/integrations.py +++ b/readthedocs/api/v2/views/integrations.py @@ -412,6 +412,7 @@ def handle_webhook(self): # Handle pull request events if all([ self.project.has_feature(Feature.EXTERNAL_VERSION_BUILD), + self.project.external_builds_enabled, event == GITHUB_PULL_REQUEST, action, ]): @@ -568,6 +569,7 @@ def handle_webhook(self): if ( self.project.has_feature(Feature.EXTERNAL_VERSION_BUILD) and + self.project.external_builds_enabled and event == GITLAB_MERGE_REQUEST and action ): if ( diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py index 138a40c2450..fcc271ce8f4 100644 --- a/readthedocs/projects/forms.py +++ b/readthedocs/projects/forms.py @@ -203,6 +203,7 @@ class Meta: 'analytics_code', 'show_version_warning', 'single_version', + 'external_builds_enabled' ) # These that can be set per-version using a config file. per_version_settings = ( @@ -259,6 +260,10 @@ def __init__(self, *args, **kwargs): else: self.fields['default_version'].widget.attrs['readonly'] = True + # Enable PR builder option on projects w/ feature flag + if not self.instance.has_feature(Feature.EXTERNAL_VERSION_BUILD): + self.fields.pop('external_builds_enabled') + def clean_conf_py_file(self): filename = self.cleaned_data.get('conf_py_file', '').strip() if filename and 'conf.py' not in filename: diff --git a/readthedocs/projects/migrations/0049_add_external_build_enabled.py b/readthedocs/projects/migrations/0049_add_external_build_enabled.py new file mode 100644 index 00000000000..04c7f6dcb28 --- /dev/null +++ b/readthedocs/projects/migrations/0049_add_external_build_enabled.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.10 on 2020-05-21 22:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0048_remove_version_privacy_field'), + ] + + operations = [ + migrations.AddField( + model_name='project', + name='external_builds_enabled', + field=models.BooleanField(default=False, help_text='More information in our docs', null=True, verbose_name='Build pull requests for this project'), + ), + ] diff --git a/readthedocs/projects/migrations/0050_migrate_external_builds.py b/readthedocs/projects/migrations/0050_migrate_external_builds.py new file mode 100644 index 00000000000..21a45cd7400 --- /dev/null +++ b/readthedocs/projects/migrations/0050_migrate_external_builds.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.10 on 2020-05-19 13:24 + +from django.db import migrations + + +def migrate_features(apps, schema_editor): + # Enable the PR builder for projects with the feature flag + Feature = apps.get_model('projects', 'Feature') + if Feature.objects.filter(feature_id='external_version_build').exists(): + for project in Feature.objects.get(feature_id='external_version_build').projects.all(): + project.external_builds_enabled = True + project.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0049_add_external_build_enabled'), + ] + + operations = [ + migrations.RunPython(migrate_features), + ] diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index 40af8e6fc44..92c24acf59f 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -202,6 +202,14 @@ class Project(models.Model): ), ) + external_builds_enabled = models.BooleanField( + _('Build pull requests for this project'), + default=False, + # TODO: Remove this after migrations + null=True, + help_text=_('More information in our docs') # noqa + ) + # Project features cdn_enabled = models.BooleanField(_('CDN Enabled'), default=False) analytics_code = models.CharField( diff --git a/readthedocs/rtd_tests/tests/test_api.py b/readthedocs/rtd_tests/tests/test_api.py index cb3106572ab..93a987acc8b 100644 --- a/readthedocs/rtd_tests/tests/test_api.py +++ b/readthedocs/rtd_tests/tests/test_api.py @@ -790,6 +790,7 @@ def setUp(self): self.project = get( Project, build_queue=None, + external_builds_enabled=True, ) self.feature_flag = get( Feature, diff --git a/requirements/testing.txt b/requirements/testing.txt index 97adde92c7c..2c93585dfa5 100644 --- a/requirements/testing.txt +++ b/requirements/testing.txt @@ -2,9 +2,9 @@ -r local-docs-build.txt django-dynamic-fixture==3.1.0 -pytest==5.2.2 +pytest==5.4.2 pytest-custom-exit-code==0.3.0 -pytest-django==3.6.0 +pytest-django==3.8.0 pytest-xdist==1.30.0 pytest-cov==2.8.1 apipkg==1.5