Skip to content

Commit 668b78f

Browse files
author
CometAPI
committed
ci: reject linked workflow directories
1 parent 357995e commit 668b78f

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

scripts/check_workflows.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,10 @@ def workflow_paths(directory: Path) -> list[Path]:
13361336

13371337

13381338
def check_workflow_inventory(directory: Path) -> list[Path]:
1339+
if directory.is_symlink() or directory.parent.is_symlink() or not directory.is_dir():
1340+
raise CheckError(
1341+
"workflow directory and .github parent must be real repository directories"
1342+
)
13391343
paths = workflow_paths(directory)
13401344
expected = {"ci.yml", "live-smoke.yml", "publish.yml", "release-please.yml"}
13411345
actual = {path.name for path in paths}

tests/test_release_workflow.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,27 @@ def test_workflow_inventory_rejects_expected_name_symlink(tmp_path: Path) -> Non
11791179
check_workflow_inventory(workflow_root)
11801180

11811181

1182+
@pytest.mark.parametrize("linked_component", ["github", "workflows"])
1183+
def test_workflow_inventory_rejects_linked_directory(tmp_path: Path, linked_component: str) -> None:
1184+
outside = tmp_path / "outside"
1185+
outside_workflows = outside / "workflows"
1186+
outside_workflows.mkdir(parents=True)
1187+
for name in ("ci.yml", "live-smoke.yml", "publish.yml", "release-please.yml"):
1188+
(outside_workflows / name).write_text("name: outside\n", encoding="utf-8")
1189+
1190+
repository = tmp_path / "repository"
1191+
repository.mkdir()
1192+
github = repository / ".github"
1193+
if linked_component == "github":
1194+
github.symlink_to(outside, target_is_directory=True)
1195+
else:
1196+
github.mkdir()
1197+
(github / "workflows").symlink_to(outside_workflows, target_is_directory=True)
1198+
1199+
with pytest.raises(RuntimeError, match="real repository directories"):
1200+
check_workflow_inventory(github / "workflows")
1201+
1202+
11821203
def test_secret_scope_scan_includes_yaml_workflows(tmp_path: Path) -> None:
11831204
workflow_root = tmp_path / ".github/workflows"
11841205
workflow_root.mkdir(parents=True)

0 commit comments

Comments
 (0)