from secure.types import Action, ActionResult, MSSession, PipelineContext


async def run_pipeline(
    session: MSSession, actions: list[Action], ctx: PipelineContext
) -> list[ActionResult]:
    results: list[ActionResult] = []
    for action in actions:
        try:
            result = await action.run(session, ctx)
        except Exception as e:
            result = ActionResult(action.name, ok=False, detail=f"{type(e).__name__}: {e}")
        results.append(result)
    return results
