Skip to content

Commit d463e3d

Browse files
committed
Show "Pushing cache" status before finishing the build
1 parent 28e3944 commit d463e3d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

readthedocs/builds/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
BUILD_STATE_CLONING = 'cloning'
1010
BUILD_STATE_INSTALLING = 'installing'
1111
BUILD_STATE_BUILDING = 'building'
12+
BUILD_STATE_PUSHING_CACHE = 'pushing-cache'
1213
BUILD_STATE_FINISHED = 'finished'
1314

1415
BUILD_STATE = (
@@ -17,6 +18,7 @@
1718
(BUILD_STATE_CLONING, _('Cloning')),
1819
(BUILD_STATE_INSTALLING, _('Installing')),
1920
(BUILD_STATE_BUILDING, _('Building')),
21+
(BUILD_STATE_PUSHING_CACHE, _('Pushing cache')),
2022
(BUILD_STATE_FINISHED, _('Finished')),
2123
)
2224

readthedocs/doc_builder/environments.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def done(self):
662662
self.build['state'] == BUILD_STATE_FINISHED
663663
)
664664

665-
def update_build(self, state=None):
665+
def update_build(self, state=None, force=False):
666666
"""
667667
Record a build by hitting the API.
668668
@@ -747,6 +747,8 @@ def update_build(self, state=None):
747747
or (self.done and not self.successful)
748748
# Otherwise, are we explicitly to not update?
749749
or self.update_on_success
750+
# Explicit force the update
751+
or force
750752
)
751753
if update_build:
752754
try:

readthedocs/projects/tasks.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
BUILD_STATE_FINISHED,
3535
BUILD_STATE_INSTALLING,
3636
BUILD_STATE_PULLING_CACHE,
37+
BUILD_STATE_PUSHING_CACHE,
3738
BUILD_STATUS_SUCCESS,
3839
BUILD_STATUS_FAILURE,
3940
LATEST,
@@ -134,10 +135,12 @@ def pull_cached_environment(self, environment):
134135
if os.path.exists(tmp_filename):
135136
os.remove(tmp_filename)
136137

137-
def push_cached_environment(self):
138+
def push_cached_environment(self, environment):
138139
if not self.project.has_feature(feature_id=Feature.CACHED_ENVIRONMENT):
139140
return
140141

142+
environment.update_build(state=BUILD_STATE_PUSHING_CACHE)
143+
141144
project_path = self.project.doc_path
142145
directories = [
143146
'checkouts',
@@ -673,6 +676,7 @@ def run_build(self, record):
673676
build=self.build,
674677
record=record,
675678
environment=env_vars,
679+
update_on_success=False,
676680

677681
# Pass ``start_time`` here to not reset the timer
678682
start_time=self.build_start_time,
@@ -756,7 +760,7 @@ def run_build(self, record):
756760
self.send_notifications(self.version.pk, self.build['id'], email=False)
757761

758762
# Push cached environment on success for next build
759-
self.push_cached_environment()
763+
self.push_cached_environment(self.build_env)
760764

761765
if self.commit:
762766
send_external_build_status(
@@ -783,6 +787,7 @@ def run_build(self, record):
783787
}
784788
)
785789

790+
self.build_env.update_build(BUILD_STATE_FINISHED, force=True)
786791
build_complete.send(sender=Build, build=self.build_env.build)
787792

788793
@staticmethod

0 commit comments

Comments
 (0)