cloudnative-devops-debug-env / server /tasks /task_3_workflow_syntax.py
krishna-hub's picture
init
85b7ac8
Raw History Blame
1.82 kB
from __future__ import annotations
import random
from typing import Dict, Optional
from server.models import TaskDifficulty
from server.tasks.base import BaseTask
class WorkflowSyntaxStructureTask(BaseTask):
NAME = "Workflow Syntax and Structure"
DESCRIPTION = "Fix GitHub Actions YAML syntax and job structure issues"
DIFFICULTY = TaskDifficulty.EASY
AVAILABLE_SECRETS = ["GITHUB_TOKEN"]
SCENARIOS = [
{
"id": "checkout_after_build",
"files": [
{
"path": ".github/workflows/build.yml",
"type": "workflow",
"content": "name: Build\non: push\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - name: Build Docker image\n run: docker build -t myapp .\n - uses: actions/checkout@v4",
},
{"path": "Dockerfile", "type": "dockerfile", "content": "FROM python:3.11-slim\nWORKDIR /app\nCOPY . ."},
],
"error": {
"phase": "workflow_parse",
"message": "Build step runs before source checkout",
},
"expected_fixes": [
{
"file": ".github/workflows/build.yml",
"type": "contains",
"expected": "- uses: actions/checkout@v4",
"hint": "Checkout should happen before build commands",
}
],
}
]
def load_scenario(self, scenario_id: Optional[str] = None) -> Dict:
if scenario_id:
for scenario in self.SCENARIOS:
if scenario["id"] == scenario_id:
return scenario
raise ValueError(f"Unknown scenario: {scenario_id}")
return random.choice(self.SCENARIOS)