Skip to content
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

Execute checkout step respecting docker setting #6436

Merged
merged 5 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,17 @@ def __init__(

# pylint: disable=arguments-differ
def run(
self, version_pk, build_pk=None, commit=None, record=True, docker=None,
self, version_pk, build_pk=None, commit=None, record=True,
force=False, **__
):
"""
Run a documentation sync n' build.

This is fully wrapped in exception handling to account for a number of
failure cases. We first run a few commands in a local build environment,
failure cases. We first run a few commands in a build environment,
but do not report on environment success. This avoids a flicker on the
build output page where the build is marked as finished in between the
local environment steps and the docker build steps.
checkout steps and the build steps.

If a failure is raised, or the build is not successful, return
``False``, otherwise, ``True``.
Expand All @@ -381,17 +381,13 @@ def run(
:param build_pk int: Build id (if None, commands are not recorded)
:param commit: commit sha of the version required for sending build status reports
:param record bool: record a build object in the database
:param docker bool: use docker to build the project (if ``None``,
``settings.DOCKER_ENABLE`` is used)
:param force bool: force Sphinx build

:returns: whether build was successful or not

:rtype: bool
"""
try:
if docker is None:
docker = settings.DOCKER_ENABLE
self.version = self.get_version(version_pk)
self.project = self.version.project
self.build = self.get_build(build_pk)
Expand All @@ -403,7 +399,7 @@ def run(
setup_successful = self.run_setup(record=record)
if not setup_successful:
return False
self.run_build(docker=docker, record=record)
self.run_build(record=record)
return True
except Exception:
log.exception(
Expand Down Expand Up @@ -444,11 +440,16 @@ def run(

def run_setup(self, record=True):
"""
Run setup in the local environment.
Run setup in a build environment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: the comment above this line (which I can't comment on directly) should be updated.

Return True if successful.
"""
environment = LocalBuildEnvironment(
if settings.DOCKER_ENABLE:
env_cls = DockerBuildEnvironment
else:
env_cls = LocalBuildEnvironment

environment = env_cls(
project=self.project,
version=self.version,
build=self.build,
Expand Down Expand Up @@ -524,19 +525,16 @@ def additional_vcs_operations(self, environment):
if version_repo.supports_submodules:
version_repo.update_submodules(self.config)

def run_build(self, docker, record):
def run_build(self, record):
"""
Build the docs in an environment.

:param docker: if ``True``, the build uses a ``DockerBuildEnvironment``,
otherwise it uses a ``LocalBuildEnvironment`` to run all the
commands to build the docs
:param record: whether or not record all the commands in the ``Build``
instance
"""
env_vars = self.get_env_vars()

if docker:
if settings.DOCKER_ENABLE:
env_cls = DockerBuildEnvironment
else:
env_cls = LocalBuildEnvironment
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/rtd_tests/tests/test_config_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def test_conda_environment(self, build_failed, checkout_path, tmpdir):
)

update_docs = self.get_update_docs_task()
update_docs.run_build(docker=False, record=False)
update_docs.run_build(record=False)

assert update_docs.config.conda.environment == conda_file
assert isinstance(update_docs.python_env, Conda)
Expand Down