Skip to content

Simplify update docs task #5694

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
merged 2 commits into from
May 28, 2019
Merged
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
48 changes: 14 additions & 34 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,18 @@ def run(
try:
if docker is None:
docker = settings.DOCKER_ENABLE

self.project = self.get_project(pk)
self.version = self.get_version(self.project, version_pk)
self.build = self.get_build(build_pk)
self.build_force = force
self.config = None

# Build process starts here
setup_successful = self.run_setup(record=record)
if not setup_successful:
return False

# Catch unhandled errors in the setup step
self.run_build(docker=docker, record=record)
return True
except Exception:
log.exception(
'An unhandled exception was raised during build setup',
Expand All @@ -401,7 +401,17 @@ def run(
},
},
)
if self.setup_env is not None:
# We should check first for build_env.
# If isn't None, it means that something got wrong
# in the second step (`self.run_build`)
if self.build_env is not None:
self.build_env.failure = BuildEnvironmentError(
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
build_id=build_pk,
),
)
self.build_env.update_build(BUILD_STATE_FINISHED)
elif self.setup_env is not None:
self.setup_env.failure = BuildEnvironmentError(
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
build_id=build_pk,
Expand All @@ -412,36 +422,6 @@ def run(
# Send notifications for unhandled errors
self.send_notifications(version_pk, build_pk)
return False
else:
# No exceptions in the setup step, catch unhandled errors in the
# build steps
try:
self.run_build(docker=docker, record=record)
except Exception:
log.exception(
'An unhandled exception was raised during project build',
extra={
'stack': True,
'tags': {
'build': build_pk,
'project': self.project.slug,
'version': self.version.slug,
},
},
)
if self.build_env is not None:
self.build_env.failure = BuildEnvironmentError(
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
build_id=build_pk,
),
)
self.build_env.update_build(BUILD_STATE_FINISHED)

# Send notifications for unhandled errors
self.send_notifications(version_pk, build_pk)
return False

return True

def run_setup(self, record=True):
"""
Expand Down