@@ -23,13 +23,13 @@ def _require_pattern(text: str, pattern: str, message: str) -> None:
2323 raise CheckError (message )
2424
2525
26- def _job (text : str , name : str ) -> str :
26+ def _job (text : str , name : str , * , source : str = "publish workflow" ) -> str :
2727 match = re .search (
2828 rf"(?ms)^ { re .escape (name )} :\n(?P<body>.*?)(?=^ [a-zA-Z0-9_-]+:\n|\Z)" ,
2929 text ,
3030 )
3131 if match is None :
32- raise CheckError (f"publish workflow has no { name !r} job" )
32+ raise CheckError (f"{ source } has no { name !r} job" )
3333 return match .group (0 )
3434
3535
@@ -135,20 +135,21 @@ def check_publish_workflow(text: str, live_smoke_text: str) -> None:
135135 if write_permissions != ["id-token" ]:
136136 raise CheckError ("id-token: write on the publish job must be the only write permission" )
137137
138+ monitoring_live = _job (live_smoke_text , "smoke" , source = "live-smoke workflow" )
138139 _require_pattern (
139140 live_smoke_text ,
140141 r"(?m)^concurrency:\n group: trusted-live-smoke\n cancel-in-progress: false$" ,
141142 "release and monitoring live smokes must share one non-cancelling concurrency group" ,
142143 )
143- _require (
144- live_smoke_text ,
145- "(github.event_name == 'workflow_dispatch' || vars.LIVE_SMOKE_ENABLED == 'true')" ,
146- "scheduled live smoke must require LIVE_SMOKE_ENABLED=true" ,
147- )
148- _require (
149- live_smoke_text ,
150- "github.ref == format('refs/heads/{0}', github.event.repository.default_branch)" ,
151- "monitoring live smoke must run only against the canonical default branch " ,
144+ _require_pattern (
145+ monitoring_live ,
146+ r"(?m)^ if: >-\n"
147+ r" github\.ref == format\('refs/heads/\{0\}', "
148+ r"github\.event\.repository\.default_branch\) &&\n"
149+ r" vars\.LIVE_SMOKE_ENABLED == 'true'\n"
150+ r" runs-on:" ,
151+ "monitoring live smoke must run only against the canonical default branch and "
152+ "require LIVE_SMOKE_ENABLED=true for every trigger " ,
152153 )
153154
154155 build = _job (text , "build" )
0 commit comments