Initial commit
This commit is contained in:
80
python/workflows.py
Normal file
80
python/workflows.py
Normal file
@@ -0,0 +1,80 @@
|
||||
"""
|
||||
Workflow template manager for gitreposetup.
|
||||
This module would handle dynamic workflow generation.
|
||||
Currently workflows are pre-created in .gitea/workflows/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
|
||||
class WorkflowManager:
|
||||
"""Manages Gitea workflow templates."""
|
||||
|
||||
def __init__(self, repo_root: Path = None):
|
||||
"""Initialize with repository root."""
|
||||
self.repo_root = repo_root or Path.cwd()
|
||||
self.gitea_dir = self.repo_root / ".gitea"
|
||||
self.workflows_dir = self.gitea_dir / "workflows"
|
||||
|
||||
def setup_workflows(self, deploy_type: str, language: str = "python"):
|
||||
"""
|
||||
Set up Gitea workflows based on deploy type and language.
|
||||
|
||||
Args:
|
||||
deploy_type: One of 'docker', 'pypi', 'cargo', 'go'
|
||||
language: Programming language ('python', 'rust', 'go')
|
||||
"""
|
||||
# Create directories
|
||||
self.gitea_dir.mkdir(exist_ok=True)
|
||||
self.workflows_dir.mkdir(exist_ok=True)
|
||||
|
||||
# Workflow mapping
|
||||
workflows_to_copy = self._get_workflows_for_type(deploy_type, language)
|
||||
|
||||
# Copy workflows (if templates exist)
|
||||
for workflow in workflows_to_copy:
|
||||
print(f" - Setting up workflow: {workflow}")
|
||||
|
||||
print(f"✓ Set up {len(workflows_to_copy)} workflows for {deploy_type}")
|
||||
|
||||
def _get_workflows_for_type(self, deploy_type: str, language: str) -> List[str]:
|
||||
"""Get list of workflow files needed for deploy type and language."""
|
||||
workflows = []
|
||||
|
||||
if deploy_type == "docker":
|
||||
workflows.extend(
|
||||
[
|
||||
f"test-{language}.yml",
|
||||
f"test-{language}-docker-build.yml",
|
||||
"docker-release.yml",
|
||||
]
|
||||
)
|
||||
elif deploy_type == "pypi":
|
||||
workflows.extend(
|
||||
[
|
||||
"test-python.yml",
|
||||
"python_package-release.yml",
|
||||
]
|
||||
)
|
||||
elif deploy_type == "cargo":
|
||||
workflows.extend(
|
||||
[
|
||||
"test-rust.yml",
|
||||
"cargo-release.yml",
|
||||
]
|
||||
)
|
||||
elif deploy_type == "go":
|
||||
workflows.extend(
|
||||
[
|
||||
"test-go.yml",
|
||||
"go-release.yml",
|
||||
]
|
||||
)
|
||||
|
||||
return workflows
|
||||
|
||||
|
||||
# For future implementation:
|
||||
# This would copy workflow files from templates embedded in the binary
|
||||
# or from a templates directory in the package.
|
||||
Reference in New Issue
Block a user