Core Concepts
Rules
Understanding rule structure and behavior
Rules are the core building blocks of Rulesets. Each ruleset consists of one or more rules that define how to validate pull requests and what actions to take based on validation results.
Rule Structure
A rule consists of the following components:
Components
A descriptive name for the rule
GitHub events that trigger this rule (e.g., “pull_request.opened”)
Conditions that determine if the rule should be applied
Validations to run on the pull request
Actions to perform when all validations pass
Actions to perform when any validation fails
Execution Flow
- Event Matching: When a GitHub event occurs, Rulesets checks if it matches any rules’
when
criteria - Condition Evaluation: For matching rules, it evaluates the
if
conditions (if any) - Validation: If conditions pass, it runs the
validate
checks - Action Execution: Based on validation results, it executes either
on_success
oron_failure
actions
Behavior Details
- All conditions in
if
must pass for a rule to be applied - All validations in
validate
must pass for a rule to be considered successful - If there are no validations, the rule is always considered successful
- Rules are processed in the order they appear in the configuration
- Multiple rules can be triggered by the same event
Best Practices
Use descriptive names for your rules
Create focused rules that address specific aspects of PR validation
Place important rules first, especially those that might block progress
Provide meaningful feedback in comments
Use template variables to customize messages
Be careful when multiple rules validate the same aspects of a PR, as this could lead to confusing feedback