Skip to content

Conversation

@ericsciple
Copy link
Collaborator

@ericsciple ericsciple commented Oct 31, 2025

Workflow used for end-to-end testing:

on:
  push:
    paths:
      .github/workflows/self-hosted.yml
jobs:
  build:
    runs-on: self-hosted
    #container: ${{ fromjson('"alpine:latest"') }}
    #container: ${{ fromjson('{"image":"alpine:latest"}') }}
    outputs:
      my_job_output: ${{ steps.set_output.outputs.my_output }}
      from_ref: ${{ github.ref }}
    env:
      JOB_ENV: ${{ github.ref }}
    steps:
      - name: Hello from ${{ github.ref }}
        run: echo hi

      - name: Print env
        env:
          STEP_ENV: ${{ github.ref }}
        run: printenv | sort

      - name: With timeout
        timeout-minutes: ${{ github.event_name == 'push' && 2 || 1 }}
        run: echo hi

      - name: Set an output
        id: set_output
        run: echo "my_output=foo" >> $GITHUB_OUTPUT

#      - name: Exceed depth
 #       env:
  #        foo: ${{ fromjson('[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]') }}
   #     run: echo hi

#      - name: Exceed memory
 #       env:
  #        foo: ${{ format('{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}', format('{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}', format('{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}', format('{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}', format('{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}', format('{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}', tojson(github))))))) }}
   #     run: echo hi

      - name: Print the output
        run: |
          echo "Output from previous step: ${{ steps.set_output.outputs.my_output }}"

@ericsciple ericsciple force-pushed the users/ericsciple/25-10-parser branch 5 times, most recently from daefa5b to 5928c4d Compare November 4, 2025 19:41
@ericsciple ericsciple changed the title Side-by-side updated workflow parser Side-by-side updated template evaluator Nov 4, 2025
@ericsciple ericsciple changed the title Side-by-side updated template evaluator Compare updated template evaluator Nov 4, 2025
/// <summary>
/// Evaluates parts of the workflow DOM. For example, a job strategy or step inputs.
/// </summary>
public interface IPipelineTemplateEvaluator
Copy link
Collaborator Author

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; }
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@ericsciple ericsciple force-pushed the users/ericsciple/25-10-parser branch 2 times, most recently from ca91081 to 90b4af4 Compare November 4, 2025 19:58
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")))
Copy link
Collaborator Author

@ericsciple ericsciple Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature flag check

@ericsciple ericsciple marked this pull request as ready for review November 4, 2025 20:02
@ericsciple ericsciple requested a review from a team as a code owner November 4, 2025 20:02
Copilot AI review requested due to automatic review settings November 4, 2025 20:02
Copy link
Contributor

Copilot AI left a 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, and TemplateUnraveler for 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
Copy link

Copilot AI Nov 4, 2025

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'

Suggested change
// Check if only ony segment
// Check if only one segment

Copilot uses AI. Check for mistakes.
/// <summary>
/// Add a prefix in the error message of the given index.
/// </summary>
public void PrefixMessage(int index, String prefix) {
Copy link

Copilot AI Nov 4, 2025

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.

Suggested change
public void PrefixMessage(int index, String prefix) {
public void PrefixMessage(int index, String prefix)
{

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +85
public void PrefixMessage(int index, String prefix) {
if (index < 0 || index >= m_errors.Count) {
Copy link

Copilot AI Nov 4, 2025

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.

Suggested change
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)
{

Copilot uses AI. Check for mistakes.
/// <summary>
/// Index and depth while replaying a YAML anchor
/// </summary>
sealed class YamlReplayState
Copy link

Copilot AI Nov 4, 2025

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.

Suggested change
sealed class YamlReplayState
internal sealed class YamlReplayState

Copilot uses AI. Check for mistakes.
}

/// <summary>
/// Gets or sets the credentials used for pulling the container iamge.
Copy link

Copilot AI Nov 4, 2025

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'

Suggested change
/// Gets or sets the credentials used for pulling the container iamge.
/// Gets or sets the credentials used for pulling the container image.

Copilot uses AI. Check for mistakes.
{
if (m_current is Scalar scalar)
{
// Verify not using achors
Copy link

Copilot AI Nov 4, 2025

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'

Copilot uses AI. Check for mistakes.
}
else if (m_current is MappingStart mappingStart)
{
// Verify not using achors
Copy link

Copilot AI Nov 4, 2025

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'

Copilot uses AI. Check for mistakes.
}
else if (m_current is SequenceStart sequenceStart)
{
// Verify not using achors
Copy link

Copilot AI Nov 4, 2025

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'

Copilot uses AI. Check for mistakes.
@ericsciple ericsciple enabled auto-merge (squash) November 7, 2025 20:14
@ericsciple ericsciple force-pushed the users/ericsciple/25-10-parser branch from 90b4af4 to 3f4d210 Compare November 7, 2025 20:14
@ericsciple ericsciple merged commit b5b7986 into main Nov 7, 2025
9 checks passed
@ericsciple ericsciple deleted the users/ericsciple/25-10-parser branch November 7, 2025 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants