Coverage for src/fastapi_cloud_cli/commands/ci/print_workflow.py: 100%
19 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-09 00:25 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-09 00:25 +0000
1from typing import Annotated, Any 1abcdefg
3import typer 1abcdefg
4from pydantic import BaseModel 1abcdefg
5from rich_toolkit import RichToolkit 1abcdefg
7from fastapi_cloud_cli.commands.ci._app import ci_app 1abcdefg
8from fastapi_cloud_cli.commands.setup_ci import ( 1abcdefg
9 DEFAULT_WORKFLOW_PATH,
10 _get_default_branch,
11 _get_workflow_content,
12)
13from fastapi_cloud_cli.utils.cli import get_rich_toolkit 1abcdefg
14from fastapi_cloud_cli.utils.execution import JsonOutputOption 1abcdefg
17class CIWorkflowOutput(BaseModel): 1abcdefg
18 filename: str 1abcdefg
19 content: str 1abcdefg
22def _render_workflow_output(data: CIWorkflowOutput, toolkit: RichToolkit) -> None: 1abhcdiefgj
23 toolkit.console.print(data.content, markup=False, end="", soft_wrap=True) 1klmhnopiqrstuj
26@ci_app.command("print-workflow") 1abcdefg
27def print_workflow( 1abCcdDefgE
28 branch: Annotated[
29 str | None,
30 typer.Option(
31 "--branch",
32 "-b",
33 help="Branch that triggers deploys (defaults to the repo's default branch).",
34 ),
35 ] = None,
36 json_output: JsonOutputOption = False,
37) -> Any:
38 """Prints the GitHub Actions workflow YAML without writing files or secrets."""
40 branch = branch or _get_default_branch() 1vklwmhxnoypizqrAstBuj
41 workflow = CIWorkflowOutput( 1vklwmhxnoypizqrAstBuj
42 filename=DEFAULT_WORKFLOW_PATH.name,
43 content=_get_workflow_content(branch),
44 )
46 with get_rich_toolkit(minimal=True, json_output=json_output) as toolkit: 1vklwmhxnoypizqrAstBuj
47 toolkit.success(workflow, render_output=_render_workflow_output) 1vklwmhxnoypizqrAstBuj