validate_actions.rules.rule¶
Interface for GitHub Actions workflow validation rules.
Classes
|
Base class for all GitHub Actions workflow validation rules. |
- class validate_actions.rules.rule.Rule(workflow, fixer)[source]¶
Bases:
ABCBase class for all GitHub Actions workflow validation rules.
Rules examine workflows for specific issues and can optionally fix them automatically. Each rule operates on a workflow AST and yields Problem instances for any issues found.
The rule system supports both validation-only and auto-fixing modes, controlled by the fixer implementation provided during initialization.
- workflow¶
The workflow AST to validate
- fixer¶
Fixer instance for making automatic corrections
Examples
- Creating a custom rule:
- class MyRule(Rule):
- def check(self) -> Generator[Problem, None, None]:
- if some_condition:
yield Problem(pos, ProblemLevel.ERR, “Error message”, “rule-name”)
- Using a rule:
rule = MyRule(workflow, fixer) problems = list(rule.check())
- abstractmethod check()[source]¶
Perform validation checks on the workflow.
Examines the workflow for rule-specific issues and yields Problem instances for any violations found. May also apply automatic fixes through the fixer if enabled.
- Yields:
Problem –
- Validation issues found, with position, level, description,
and rule name information.
- Return type:
Generator[Problem, None, None]