Skip to content

Commit 094e52f

Browse files
committed
Include trigger reason
1 parent 33c5272 commit 094e52f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: build_docs.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -616,13 +616,14 @@ def run(self, http: urllib3.PoolManager) -> bool:
616616
self.cpython_repo.switch(self.version.branch_or_tag)
617617
if self.language.tag != "en":
618618
self.clone_translation()
619-
if self.should_rebuild():
619+
if trigger_reason := self.should_rebuild():
620620
self.build_venv()
621621
self.build()
622622
self.copy_build_to_webroot(http)
623623
self.save_state(
624624
build_start=start_timestamp,
625625
build_duration=perf_counter() - start_time,
626+
trigger=trigger_reason,
626627
)
627628
except Exception as err:
628629
logging.exception("Badly handled exception, human, please help.")
@@ -889,7 +890,7 @@ def should_rebuild(self):
889890
state = self.load_state()
890891
if not state:
891892
logging.info("Should rebuild: no previous state found.")
892-
return True
893+
return "no previous state"
893894
cpython_sha = self.cpython_repo.run("rev-parse", "HEAD").stdout.strip()
894895
if self.language.tag != "en":
895896
translation_sha = self.translation_repo.run(
@@ -901,7 +902,7 @@ def should_rebuild(self):
901902
state["translation_sha"],
902903
translation_sha,
903904
)
904-
return True
905+
return "new translations"
905906
if cpython_sha != state["cpython_sha"]:
906907
diff = self.cpython_repo.run(
907908
"diff", "--name-only", state["cpython_sha"], cpython_sha
@@ -912,7 +913,7 @@ def should_rebuild(self):
912913
state["cpython_sha"],
913914
cpython_sha,
914915
)
915-
return True
916+
return "Doc/ has changed"
916917
logging.info("Nothing changed, no rebuild needed.")
917918
return False
918919

@@ -925,7 +926,7 @@ def load_state(self) -> dict:
925926
except (KeyError, FileNotFoundError):
926927
return {}
927928

928-
def save_state(self, build_start: dt, build_duration: float):
929+
def save_state(self, build_start: dt, build_duration: float, trigger: str):
929930
"""Save current CPython sha1 and current translation sha1.
930931
931932
Using this we can deduce if a rebuild is needed or not.
@@ -940,6 +941,7 @@ def save_state(self, build_start: dt, build_duration: float):
940941
state = {
941942
"last_build_start": build_start,
942943
"last_build_duration": round(build_duration, 0),
944+
"triggered_by": trigger,
943945
"cpython_sha": self.cpython_repo.run("rev-parse", "HEAD").stdout.strip(),
944946
}
945947
if self.language.tag != "en":

0 commit comments

Comments
 (0)