Skip to content

Commit a7c81f5

Browse files
Copilotmrjf
andauthored
Remove pyyaml dependency from sync-branches lock-file test
Agent-Logs-Url: https://github.com/githubnext/autoloop/sessions/eb03ca6e-1e28-4ca4-aa3d-bd15025f0fee Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent 34b7262 commit a7c81f5

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

tests/test_scheduling.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)