Skip to content

Commit 98d4454

Browse files
committed
Implemente fastly invalidation for devguide.
1 parent 1a6bcd3 commit 98d4454

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

build_docs.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,20 @@ def build_one(version, isdev, quick, sphinxbuild, build_root, www_root,
137137

138138
def build_devguide(devguide_checkout, devguide_target, sphinxbuild,
139139
skip_cache_invalidation=False):
140+
build_directory = os.path.join(devguide_checkout, "build/html")
140141
logging.info("Building devguide")
141142
shell_out("git -C %s pull" % (devguide_checkout,))
142-
shell_out("%s %s %s" % (sphinxbuild, devguide_checkout, devguide_target))
143+
shell_out("%s %s %s" % (sphinxbuild, devguide_checkout, build_directory))
144+
changed = changed_files(build_directory, devguide_target)
145+
shell_out("mkdir -p {}".format(devguide_target))
146+
shell_out("cp -a {}/* {}".format(build_directory, devguide_target))
143147
shell_out("chmod -R o+r %s" % (devguide_target,))
144-
if not skip_cache_invalidation:
145-
# TODO Do Fastly invalidation.
146-
pass
148+
if changed and not skip_cache_invalidation:
149+
prefix = os.path.basename(devguide_target)
150+
to_purge = [prefix]
151+
to_purge.extend(prefix + "/" + p for p in changed)
152+
logging.info("Running CDN purge")
153+
shell_out("curl -X PURGE \"https://docs.python.org/{%s}\"" % ",".join(to_purge))
147154

148155

149156
def parse_args():

0 commit comments

Comments
 (0)