@@ -45,6 +45,11 @@ def _preflight_script(workflow_text: str) -> str:
4545 return "\n " .join (lines )
4646
4747
48+ def _job_block (workflow_text : str , job : str ) -> str :
49+ start = workflow_text .index (f" { job } :\n " )
50+ return workflow_text [start :]
51+
52+
4853def _run_preflight (script : str , values : dict [str , str ]) -> subprocess .CompletedProcess [str ]:
4954 env = {"PATH" : os .environ .get ("PATH" , "" )}
5055 env .update (values )
@@ -106,6 +111,17 @@ def test_watchdog_uses_repository_variables_before_remote_actions(self) -> None:
106111 self .assertIn ("service_account: ${{ env.GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT }}" , text )
107112 self .assertIn ("WATCHDOG_MAX_AGE_SECONDS: ${{ vars.WATCHDOG_MAX_AGE_SECONDS || '4500' }}" , text )
108113
114+ def test_watchdog_skips_entire_job_when_runtime_target_is_not_explicitly_enabled (self ) -> None :
115+ text = self .workflow_text
116+ job = _job_block (text , "check" )
117+
118+ self .assertIn ("RUNTIME_TARGET_ENABLED: ${{ vars.RUNTIME_TARGET_ENABLED || 'false' }}" , text )
119+ self .assertIn ("if: ${{ vars.RUNTIME_TARGET_ENABLED == 'true' }}" , job )
120+ self .assertLess (
121+ job .index ("if: ${{ vars.RUNTIME_TARGET_ENABLED == 'true' }}" ),
122+ job .index ("runs-on: ubuntu-latest" ),
123+ )
124+
109125 def test_oidc_identity_digest_is_fixed_and_shared (self ) -> None :
110126 scripts = (
111127 _preflight_script (RUNTIME_WORKFLOW .read_text (encoding = "utf-8" )),
0 commit comments