-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add docker image from the YAML config integration #3339
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 9 commits
442c68a
961c18e
aa15e78
a705f9d
eb7c4b2
8d1a58d
c27686e
67d5595
5708f10
edfca36
d0ee0f7
da7ec2b
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 |
---|---|---|
|
@@ -69,6 +69,40 @@ The file option specified the Conda `environment file`_ to use. | |
|
||
.. note:: Conda is only supported via the YAML file. | ||
|
||
|
||
build | ||
~~~~~ | ||
|
||
The ``build`` block configures specific aspects of the documentation build. | ||
|
||
.. _yaml_build_image: | ||
|
||
build.image | ||
``````````` | ||
|
||
|
||
* Default: :djangosetting:`DOCKER_IMAGE` | ||
* Options: ``1.0``, ``2.0``, ``latest`` | ||
|
||
The build image to use for specific builds. | ||
This lets users specify a more experimental build image, | ||
if they want to be on the cutting edge. | ||
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. For consistency and clarity: "docker image" -> "build image" |
||
|
||
Certain Python versions require a certain build image, | ||
as defined here:: | ||
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. Same on "builder" here, builder is an internal term, this refers to the build image instead. |
||
|
||
* `'1.0': 2, 2.7, 3, 3.4` | ||
* `'2.0': 2, 2.7, 3, 3.5` | ||
* `'latest': 2, 2.7, 3, 3.3, 3.4, 3.5, 3.6` | ||
|
||
.. code-block:: yaml | ||
|
||
build: | ||
image: latest | ||
|
||
python: | ||
version: 3.6 | ||
|
||
python | ||
~~~~~~ | ||
|
||
|
@@ -85,15 +119,12 @@ This is the version of Python to use when building your documentation. If you | |
specify only the major version of Python, the highest supported minor version | ||
will be selected. | ||
|
||
The supported Python versions depends on the version of the build image your | ||
project is using. The default build image that is used to build documentation | ||
contains support for Python ``2.7`` and ``3.5``. | ||
|
||
There is also an image in testing that supports Python versions ``2.7``, | ||
``3.3``, ``3.4``, ``3.5``, and ``3.6``. If you would like access to this build | ||
image, you can sign up for beta access here: | ||
.. warning:: | ||
|
||
https://goo.gl/forms/AKEoeWHixlzVfqKT2 | ||
The supported Python versions depends on the version of the build image your | ||
project is using. The default build image that is used to build documentation | ||
contains support for Python ``2.7`` and ``3.5``. | ||
See the :ref:`yaml_build_image` for more information on supported Python versions. | ||
|
||
.. code-block:: yaml | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,14 @@ | |
from __future__ import ( | ||
absolute_import, division, print_function, unicode_literals) | ||
|
||
import logging | ||
import os | ||
import re | ||
|
||
from django.conf import settings | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
SPHINX_TEMPLATE_DIR = os.path.join( | ||
settings.SITE_ROOT, | ||
'readthedocs', | ||
|
@@ -33,24 +36,17 @@ | |
) | ||
DOCKER_VERSION = getattr(settings, 'DOCKER_VERSION', 'auto') | ||
DOCKER_IMAGE = getattr(settings, 'DOCKER_IMAGE', 'readthedocs/build:2.0') | ||
DOCKER_IMAGE_SETTINGS = getattr(settings, 'DOCKER_IMAGE_SETTINGS', {}) | ||
|
||
old_config = getattr(settings, 'DOCKER_BUILD_IMAGES', None) | ||
if old_config: | ||
log.warning('Old config detected, DOCKER_BUILD_IMAGES->DOCKER_IMAGE_SETTINGS') | ||
DOCKER_IMAGE_SETTINGS.update(old_config) | ||
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. This warning could be a good use of a django system check warning as well. |
||
|
||
DOCKER_LIMITS = {'memory': '200m', 'time': 600} | ||
DOCKER_LIMITS.update(getattr(settings, 'DOCKER_LIMITS', {})) | ||
|
||
DOCKER_TIMEOUT_EXIT_CODE = 42 | ||
DOCKER_OOM_EXIT_CODE = 137 | ||
|
||
DOCKER_HOSTNAME_MAX_LEN = 64 | ||
|
||
# Build images | ||
DOCKER_BUILD_IMAGES = { | ||
'readthedocs/build:1.0': { | ||
'python': {'supported_versions': [2, 2.7, 3, 3.4]}, | ||
}, | ||
'readthedocs/build:2.0': { | ||
'python': {'supported_versions': [2, 2.7, 3, 3.5]}, | ||
}, | ||
'readthedocs/build:latest': { | ||
'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, | ||
}, | ||
} | ||
DOCKER_BUILD_IMAGES.update(getattr(settings, 'DOCKER_BUILD_IMAGES', {})) | ||
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 keeping full build image names here on |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,45 +54,37 @@ def test_python_supported_versions_default_image_1_0(self, load_config): | |
self.assertEqual(load_config.call_count, 1) | ||
load_config.assert_has_calls([ | ||
mock.call(path=mock.ANY, env_config={ | ||
'python': {'supported_versions': [2, 2.7, 3, 3.4]}, | ||
'build': {'image': 'readthedocs/build:1.0'}, | ||
'type': 'sphinx', | ||
'output_base': '', | ||
'name': mock.ANY | ||
}), | ||
]) | ||
self.assertEqual(config.python_version, 2) | ||
|
||
def test_python_supported_versions_image_1_0(self, load_config): | ||
load_config.side_effect = create_load() | ||
self.project.container_image = 'readthedocs/build:1.0' | ||
self.project.save() | ||
config = load_yaml_config(self.version) | ||
self.assertEqual(config._yaml_config.get_valid_python_versions(), | ||
[2, 2.7, 3, 3.4]) | ||
|
||
def test_python_supported_versions_image_2_0(self, load_config): | ||
load_config.side_effect = create_load() | ||
self.project.container_image = 'readthedocs/build:2.0' | ||
self.project.save() | ||
config = load_yaml_config(self.version) | ||
self.assertEqual(load_config.call_count, 1) | ||
load_config.assert_has_calls([ | ||
mock.call(path=mock.ANY, env_config={ | ||
'python': {'supported_versions': [2, 2.7, 3, 3.5]}, | ||
'type': 'sphinx', | ||
'output_base': '', | ||
'name': mock.ANY | ||
}), | ||
]) | ||
self.assertEqual(config.python_version, 2) | ||
self.assertEqual(config._yaml_config.get_valid_python_versions(), | ||
[2, 2.7, 3, 3.5]) | ||
|
||
def test_python_supported_versions_image_latest(self, load_config): | ||
load_config.side_effect = create_load() | ||
self.project.container_image = 'readthedocs/build:latest' | ||
self.project.save() | ||
config = load_yaml_config(self.version) | ||
self.assertEqual(load_config.call_count, 1) | ||
load_config.assert_has_calls([ | ||
mock.call(path=mock.ANY, env_config={ | ||
'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, | ||
'type': 'sphinx', | ||
'output_base': '', | ||
'name': mock.ANY | ||
}), | ||
]) | ||
self.assertEqual(config.python_version, 2) | ||
self.assertEqual(config._yaml_config.get_valid_python_versions(), | ||
[2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]) | ||
|
||
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. These are some of the tests I was looking for in |
||
def test_python_default_version(self, load_config): | ||
load_config.side_effect = create_load() | ||
|
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.
With settings re-enabled, this can be pulled from settings. See
settings.rst
anddoc_extensions.py
inconf/