-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Compare updated template evaluator #4092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
daefa5b to
5928c4d
Compare
| /// <summary> | ||
| /// Evaluates parts of the workflow DOM. For example, a job strategy or step inputs. | ||
| /// </summary> | ||
| public interface IPipelineTemplateEvaluator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enables IExecutionContext.ToPipelineTemplateEvaluator to return a wrapper
| public bool WriteDebug { get; set; } | ||
| public string InfrastructureFailureCategory { get; set; } | ||
| public JObject ContainerHookState { get; set; } | ||
| public bool HasTemplateEvaluatorMismatch { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevents adding to telemetry multiple times. Once per job is enough.
| } | ||
| } | ||
|
|
||
| public sealed class NewAlwaysFunction : GitHub.Actions.Expressions.Sdk.Function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated because this needs to inherit from the new namespace
ca91081 to
90b4af4
Compare
| public static IPipelineTemplateEvaluator ToPipelineTemplateEvaluator(this IExecutionContext context, ObjectTemplating.ITraceWriter traceWriter = null) | ||
| { | ||
| // Create wrapper? | ||
| if ((context.Global.Variables.GetBoolean(Constants.Runner.Features.CompareTemplateEvaluator) ?? false) || StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("ACTIONS_RUNNER_COMPARE_TEMPLATE_EVALUATOR"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature flag check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new template evaluator and related components for processing GitHub Actions workflow templates. The changes add comprehensive support for parsing, validating, and evaluating workflow YAML files with expression support, schema validation, and various token types.
Key Changes
- Implements core template evaluation infrastructure including
TemplateEvaluator,TemplateReader, andTemplateUnravelerfor processing workflow templates - Adds schema validation framework with multiple definition types (String, Number, Boolean, Mapping, Sequence, etc.)
- Introduces token system for representing template elements (BasicExpressionToken, MappingToken, SequenceToken, etc.)
Reviewed Changes
Copilot reviewed 150 out of 188 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| BasicExpressionToken.cs | Implements token type for basic expressions with evaluation and display methods |
| TemplateWriter.cs | Converts template tokens to other object formats |
| TemplateValidationException.cs | Exception class for template validation errors |
| TemplateValidationErrors.cs | Collection for managing validation errors with limits |
| TemplateValidationError.cs | Individual validation error representation |
| TemplateUnraveler.cs | Core logic for traversing and expanding template expressions |
| TemplateStrings.resx | Resource file containing localized error messages |
| TemplateStrings.cs | Auto-generated resource accessor class |
| TemplateReader.cs | Converts source objects into template tokens with validation |
| TemplateMemory.cs | Tracks memory usage during template processing |
| TemplateEvaluator.cs | Evaluates templates by expanding expressions based on context |
| TemplateContext.cs | Context object for template loading and evaluation |
| TemplateConstants.cs | Constants used throughout template processing |
| Telemetry.cs | Tracks telemetry data during workflow parsing |
| Various Schema files | Schema definitions for validating template structure |
| Various Conversion files | Workflow conversion utilities and helpers |
| Job-related files | Job and step type definitions |
| Various interface files | Interface definitions for extensibility |
| return new StringToken(m_fileId, token.Line, token.Column, str); | ||
| } | ||
|
|
||
| // Check if only ony segment |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'ony' to 'one'
| // Check if only ony segment | |
| // Check if only one segment |
| /// <summary> | ||
| /// Add a prefix in the error message of the given index. | ||
| /// </summary> | ||
| public void PrefixMessage(int index, String prefix) { |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening brace should be on a new line to match the C# coding style used throughout this codebase.
| public void PrefixMessage(int index, String prefix) { | |
| public void PrefixMessage(int index, String prefix) | |
| { |
| public void PrefixMessage(int index, String prefix) { | ||
| if (index < 0 || index >= m_errors.Count) { |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening brace should be on a new line to match the C# coding style used throughout this codebase.
| public void PrefixMessage(int index, String prefix) { | |
| if (index < 0 || index >= m_errors.Count) { | |
| public void PrefixMessage(int index, String prefix) | |
| if (index < 0 || index >= m_errors.Count) | |
| { |
| /// <summary> | ||
| /// Index and depth while replaying a YAML anchor | ||
| /// </summary> | ||
| sealed class YamlReplayState |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class should have an access modifier. Add 'internal' to match the pattern used in this codebase.
| sealed class YamlReplayState | |
| internal sealed class YamlReplayState |
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the credentials used for pulling the container iamge. |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'iamge' to 'image'
| /// Gets or sets the credentials used for pulling the container iamge. | |
| /// Gets or sets the credentials used for pulling the container image. |
| { | ||
| if (m_current is Scalar scalar) | ||
| { | ||
| // Verify not using achors |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'achors' to 'anchors'
| } | ||
| else if (m_current is MappingStart mappingStart) | ||
| { | ||
| // Verify not using achors |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'achors' to 'anchors'
| } | ||
| else if (m_current is SequenceStart sequenceStart) | ||
| { | ||
| // Verify not using achors |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'achors' to 'anchors'
90b4af4 to
3f4d210
Compare
Workflow used for end-to-end testing: