[➕ Feature]: Add a way to validate Keep workflows from CI
/bounty 20
💎 $20 bounty • Keep (YC W23)
Steps to solve:
- Start working: Comment
/attempt #3376with your implementation plan - Submit work: Create a pull request including
/claim #3376in the PR body to claim the bounty - Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts
Thank you for contributing to keephq/keep!
Add a bounty • Share on socials
| Attempt | Started (GMT+0) | Solution |
|---|---|---|
| 🟢 @Mayank77maruti | Feb 14, 2025, 6:54:14 AM | WIP |
| 🟢 @dharmitpatel81 | Mar 29, 2025, 8:05:12 PM | WIP |
/attempt #3376
| Algora profile | Completed bounties | Tech | Active attempts | Options |
|---|---|---|---|---|
| @Mayank77maruti | 1 bounty from 1 project | CSS, JavaScript, TypeScript & more |
Cancel attempt |
Aim - The purpose was adding a new CLI function that can validate if a workflow is valid syntax or not
Proposed Solution -we'll introduce a new validate subcommand under the workflow group. This command will check the syntax and structure of a workflow
Proposed Code:- (In cli.py)
@workflow.command(name="validate")
@click.option(
"--file",
"-f",
type=click.Path(exists=True),
help="Path to the workflow YAML file to validate",
required=True,
)
@pass_info
def validate_workflow(info: Info, file: str):
"""Validate workflow syntax and structure"""
try:
with open(file, "r") as f:
workflow_config = cyaml.safe_load(f)
# Check required top-level fields
required_fields = ["id", "name", "triggers", "steps"]
for field in required_fields:
if field not in workflow_config:
raise ValueError(f"Missing required field: {field}")
# Check triggers configuration
triggers = workflow_config.get("triggers", [])
if not isinstance(triggers, list) or len(triggers) == 0:
raise ValueError("Workflow must contain at least one trigger")
# Check steps configuration
steps = workflow_config.get("steps", [])
if not isinstance(steps, list) or len(steps) == 0:
raise ValueError("Workflow must contain at least one step")
click.echo(click.style("Workflow syntax is valid", fg="green", bold=True))
except Exception as e:
click.echo(click.style(f"Invalid workflow: {str(e)}", fg="red", bold=True))
sys.exit(1)
@talboren @shahargl Please ptal at the approach if i am moving in the right direction. Thank you
@Mayank77maruti looks good!
@shahargl does this PR addresses the issue? https://github.com/keephq/keep/pull/4667