Skip to content

Commit

Permalink
Add a project-level configuration for PR builds
Browse files Browse the repository at this point in the history
This allows users with the feature flag to enable/disable this feature.
  • Loading branch information
ericholscher committed May 18, 2020
1 parent 9e10a03 commit f239442
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/guides/autobuild-docs-for-pull-requests.rst
Expand Up @@ -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 </guides/feature-flags>`.
So, you can enable this feature by sending us an `email <mailto:support@readthedocs.org>`__ 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 <mailto:support@readthedocs.org>`__ including your project URL.

Features
--------
Expand Down
5 changes: 5 additions & 0 deletions readthedocs/projects/forms.py
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions readthedocs/projects/migrations/0049_add_external_build_enabled.py
@@ -0,0 +1,18 @@
# Generated by Django 2.2.10 on 2020-05-18 20:17

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 <a href="https://docs.readthedocs.io/en/latest/guides/autobuild-docs-for-pull-requests.html">our docs</a>', verbose_name='Build pull requests for this project'),
),
]
6 changes: 6 additions & 0 deletions readthedocs/projects/models.py
Expand Up @@ -202,6 +202,12 @@ class Project(models.Model):
),
)

external_builds_enabled = models.BooleanField(
_('Build pull requests for this project'),
default=False,
help_text=_('More information in <a href="https://docs.readthedocs.io/en/latest/guides/autobuild-docs-for-pull-requests.html">our docs</a>') # noqa
)

# Project features
cdn_enabled = models.BooleanField(_('CDN Enabled'), default=False)
analytics_code = models.CharField(
Expand Down

0 comments on commit f239442

Please sign in to comment.