@@ -616,13 +616,14 @@ def run(self, http: urllib3.PoolManager) -> bool:
616
616
self .cpython_repo .switch (self .version .branch_or_tag )
617
617
if self .language .tag != "en" :
618
618
self .clone_translation ()
619
- if self .should_rebuild ():
619
+ if trigger_reason := self .should_rebuild ():
620
620
self .build_venv ()
621
621
self .build ()
622
622
self .copy_build_to_webroot (http )
623
623
self .save_state (
624
624
build_start = start_timestamp ,
625
625
build_duration = perf_counter () - start_time ,
626
+ trigger = trigger_reason ,
626
627
)
627
628
except Exception as err :
628
629
logging .exception ("Badly handled exception, human, please help." )
@@ -889,7 +890,7 @@ def should_rebuild(self):
889
890
state = self .load_state ()
890
891
if not state :
891
892
logging .info ("Should rebuild: no previous state found." )
892
- return True
893
+ return "no previous state"
893
894
cpython_sha = self .cpython_repo .run ("rev-parse" , "HEAD" ).stdout .strip ()
894
895
if self .language .tag != "en" :
895
896
translation_sha = self .translation_repo .run (
@@ -901,7 +902,7 @@ def should_rebuild(self):
901
902
state ["translation_sha" ],
902
903
translation_sha ,
903
904
)
904
- return True
905
+ return "new translations"
905
906
if cpython_sha != state ["cpython_sha" ]:
906
907
diff = self .cpython_repo .run (
907
908
"diff" , "--name-only" , state ["cpython_sha" ], cpython_sha
@@ -912,7 +913,7 @@ def should_rebuild(self):
912
913
state ["cpython_sha" ],
913
914
cpython_sha ,
914
915
)
915
- return True
916
+ return "Doc/ has changed"
916
917
logging .info ("Nothing changed, no rebuild needed." )
917
918
return False
918
919
@@ -925,7 +926,7 @@ def load_state(self) -> dict:
925
926
except (KeyError , FileNotFoundError ):
926
927
return {}
927
928
928
- def save_state (self , build_start : dt , build_duration : float ):
929
+ def save_state (self , build_start : dt , build_duration : float , trigger : str ):
929
930
"""Save current CPython sha1 and current translation sha1.
930
931
931
932
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):
940
941
state = {
941
942
"last_build_start" : build_start ,
942
943
"last_build_duration" : round (build_duration , 0 ),
944
+ "triggered_by" : trigger ,
943
945
"cpython_sha" : self .cpython_repo .run ("rev-parse" , "HEAD" ).stdout .strip (),
944
946
}
945
947
if self .language .tag != "en" :
0 commit comments