@@ -786,18 +786,31 @@ def _load_steps(self):
786786 return step_names
787787
788788 def _load_lock_steps (self ):
789- """Return the list of step names from .github/workflows/sync-branches.lock.yml."""
789+ """Return the list of step names from the agent job in
790+ .github/workflows/sync-branches.lock.yml.
791+
792+ Parsed with a regex (rather than PyYAML) so the test has no
793+ external dependencies beyond pytest.
794+ """
790795 import os
791- import yaml
792796
793797 lock_path = os .path .join (
794798 os .path .dirname (__file__ ), ".." , ".github" , "workflows" , "sync-branches.lock.yml"
795799 )
796800 with open (lock_path ) as f :
797- data = yaml .safe_load (f )
798- # Collect step names from the 'agent' job
799- steps = data .get ("jobs" , {}).get ("agent" , {}).get ("steps" , [])
800- return [s .get ("name" , "" ) for s in steps if s .get ("name" )]
801+ content = f .read ()
802+ # Restrict to the 'agent:' job body so we don't pick up step names
803+ # from other jobs (e.g. 'activation').
804+ agent_match = re .search (r"^ agent:\n((?: .*\n|\n)+)" , content , re .MULTILINE )
805+ if not agent_match :
806+ return []
807+ agent_body = agent_match .group (1 )
808+ # Step names appear as either ' - name: <Name>' or
809+ # ' name: <Name>' (when the step starts with '- env:').
810+ step_names = []
811+ for m in re .finditer (r'^\s{6,8}(?:- )?name:\s*(.+)$' , agent_body , re .MULTILINE ):
812+ step_names .append (m .group (1 ).strip ())
813+ return step_names
801814
802815 def test_cred_step_exists (self ):
803816 """A step that configures Git identity/auth must exist in the source."""
0 commit comments