Skip to content

Update instance and model when record_as_success #3831

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
Mar 22, 2018
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
13 changes: 8 additions & 5 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,19 @@ def get_command(self):

def save(self):
"""Save this command and result via the API."""
exit_code = self.exit_code

# Force record this command as success to avoid Build reporting errors
# on commands that are just for checking purposes and do not interferes
# in the Build
if self.record_as_success:
log.warning('Recording command exit_code as success')
exit_code = 0
self.exit_code = 0

data = {
'build': self.build_env.build.get('id'),
'command': self.get_command(),
'description': self.description,
'output': self.output,
'exit_code': exit_code,
'exit_code': self.exit_code,
'start_time': self.start_time,
'end_time': self.end_time,
}
Expand Down Expand Up @@ -345,7 +343,6 @@ def run_command_class(
# ``build_env`` is passed as ``kwargs`` when it's called from a
# ``*BuildEnvironment``
build_cmd = cls(cmd, **kwargs)
self.commands.append(build_cmd)
build_cmd.run()

if record:
Expand All @@ -354,6 +351,12 @@ def run_command_class(
# only ones that can be saved/recorded)
self.record_command(build_cmd)

# We want append this command to the list of commands only if it has
# to be recorded in the database (to keep consistency) and also, it
# has to be added after ``self.record_command`` since its
# ``exit_code`` can be altered because of ``record_as_success``
self.commands.append(build_cmd)

if build_cmd.failed:
msg = u'Command {cmd} failed'.format(cmd=build_cmd.get_command())

Expand Down