71 lines
2.1 KiBLFS
Python
71 lines
2.1 KiBLFS
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
SCRIPT = Path(__file__).resolve().parents[2] / ".github" / "scripts" / "agentbeats_task_env_matrix.py"
|
|
|
|
|
|
def test_agentbeats_task_env_matrix_expands_manifest(tmp_path: Path) -> None:
|
|
root = tmp_path / "repo"
|
|
task_sets = root / "integrations" / "agentbeats" / "task_sets"
|
|
task_sets.mkdir(parents=True)
|
|
for task_id in ("beta_task", "alpha-task"):
|
|
env_dir = root / "tasks" / task_id / "environment"
|
|
env_dir.mkdir(parents=True)
|
|
(env_dir / "Dockerfile").write_text("FROM scratch\n")
|
|
(task_sets / "test-set.json").write_text(json.dumps({"tasks": [{"task_id": "beta_task"}, {"task_id": "alpha-task"}]}))
|
|
|
|
env = {**os.environ, "GITHUB_SHA": "abcdef1234567890"}
|
|
completed = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
str(SCRIPT),
|
|
"--repo-root",
|
|
str(root),
|
|
"--task-set",
|
|
"test-set",
|
|
],
|
|
check=True,
|
|
capture_output=True,
|
|
env=env,
|
|
text=True,
|
|
)
|
|
|
|
assert json.loads(completed.stdout)["include"] == [
|
|
{
|
|
"task_id": "beta_task",
|
|
"context": "tasks/beta_task/environment",
|
|
"dockerfile": "tasks/beta_task/environment/Dockerfile",
|
|
"tag": "test-set-beta_task-abcdef123456",
|
|
},
|
|
{
|
|
"task_id": "alpha-task",
|
|
"context": "tasks/alpha-task/environment",
|
|
"dockerfile": "tasks/alpha-task/environment/Dockerfile",
|
|
"tag": "test-set-alpha-task-abcdef123456",
|
|
},
|
|
]
|
|
|
|
|
|
def test_agentbeats_task_env_matrix_rejects_pathlike_manifest(tmp_path: Path) -> None:
|
|
completed = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
str(SCRIPT),
|
|
"--repo-root",
|
|
str(tmp_path),
|
|
"--task-set",
|
|
"../bad",
|
|
],
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
assert completed.returncode != 0
|
|
assert "direct manifest name" in completed.stderr
|