validate_actions.domain_model.primitives¶
Primitive building blocks for creating a GHA ast.
Classes
|
Represents a GitHub Actions expression like ${{ context.value }}. |
|
Position information for tracking locations in YAML source files. |
|
Represents a string value with position metadata and embedded expressions. |
- class validate_actions.domain_model.primitives.Pos(line, col, idx=0)[source]¶
Bases:
objectPosition information for tracking locations in YAML source files.
This class provides precise position tracking for AST nodes, enabling accurate error reporting and automatic fixes. Position information includes line number, column number, and character index within the file.
- Parameters:
line (int)
col (int)
idx (int)
- line¶
Zero-based line number in the source file
- Type:
int
- col¶
Zero-based column number within the line
- Type:
int
- idx¶
Character index from start of file
- Type:
int
Examples
- Creating a position from YAML token:
pos = Pos.from_token(token)
- Manual position creation:
pos = Pos(line=5, col=10, idx=125)
- class validate_actions.domain_model.primitives.Expression(pos, string, parts)[source]¶
Bases:
objectRepresents a GitHub Actions expression like ${{ context.value }}.
Expressions are parsed from strings and broken down into parts for validation. Each expression maintains position information for error reporting.
- string¶
Raw expression string as it appears in the YAML
- Type:
str
Examples
- Expression for ${{ github.event.pull_request.number }}:
- expr = Expression(
pos=Pos(5, 10), string=”github.event.pull_request.number”, parts=[String(“github”), String(“event”), String(“pull_request”), String(“number”)]
)
- class validate_actions.domain_model.primitives.String(string, pos, expr=<factory>)[source]¶
Bases:
objectRepresents a string value with position metadata and embedded expressions.
This is the core string representation used throughout the AST. It preserves the original string content along with precise position information and any GitHub Actions expressions (${{ … }}) found within the string.
- Parameters:
string (str)
pos (Pos)
expr (List[Expression])
- string¶
The string value extracted from the YAML token
- Type:
str
- expr¶
List of Expression objects found within this string
- Type:
List[Expression]
Examples
- Simple string:
s = String(“hello world”, Pos(1, 0))
- String with expression:
s = String(“Hello ${{ github.actor }}”, pos, [expr])
- From YAML token:
s = String.from_token(scalar_token)