keep icon indicating copy to clipboard operation
keep copied to clipboard

[➕ Feature]: Add a way to validate Keep workflows from CI

Open shahargl opened this issue 10 months ago • 6 comments

shahargl avatar Feb 10 '25 13:02 shahargl

/bounty 20

Matvey-Kuk avatar Feb 14 '25 00:02 Matvey-Kuk

💎 $20 bounty • Keep (YC W23)

Steps to solve:

  1. Start working: Comment /attempt #3376 with your implementation plan
  2. Submit work: Create a pull request including /claim #3376 in the PR body to claim the bounty
  3. 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 bountyShare 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

algora-pbc[bot] avatar Feb 14 '25 00:02 algora-pbc[bot]

/attempt #3376

Algora profile Completed bounties Tech Active attempts Options
@Mayank77maruti 1 bounty from 1 project
CSS, JavaScript,
TypeScript & more
Cancel attempt

Mayank77maruti avatar Feb 14 '25 06:02 Mayank77maruti

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 avatar Feb 15 '25 06:02 Mayank77maruti

@Mayank77maruti looks good!

talboren avatar Feb 15 '25 08:02 talboren

/attempt #3376

Options

dharmitpatel81 avatar Mar 29 '25 20:03 dharmitpatel81

@shahargl does this PR addresses the issue? https://github.com/keephq/keep/pull/4667

Kiryous avatar May 05 '25 23:05 Kiryous