Skip to content

Commit

Permalink
[1742] Ensure multiple composite annoations are correctly written. (a…
Browse files Browse the repository at this point in the history
…ctions#2311)

* [1742] Ensure multiple composite annoations are correctly written.

This implementation uses a collector pattern to allow embedded ExecutionContexts to stash Issue objects for later processing by a non-embedded ancestor ExecutionContext.

Also:
 - Provide explicit constructor implementations for ExecutionContext
 - Leverage explicit constructors to solidify immutability of several ExecutionContext class members.
 - Fixed erroneous call to ExecutionContext.Complete in CompositeActionHandler.cs
 - Use a consistent timestamp for FinishTime in ExecutionContext::Complete

* Ensure collected issues are processed only by a non-embedded ExecutionContext.
This was already implicit.  Now, just making it explicit.

* Provide a clear mechanism that allows callers to opt-in/opt-out of ExecutionContext::AddIssue's logging behavior.
* Addressed deserialization inconsistencies in TimelineRecord.cs
* Added TimelineRecord unit tests.
* Refined unit tests related to TimelineRecord::Variables case-insensitivity
* Add a unit test that verifies ExecutionContextLogOptions::LogMessageOverride has the desired effect.
* Responded to PR feedback.
* Don't allow embedded ExecutionContexts to add Issues to a TimelineRecord
  • Loading branch information
jww3 authored May 10, 2023
1 parent 1bc14f0 commit f8a28c3
Show file tree
Hide file tree
Showing 21 changed files with 794 additions and 270 deletions.
10 changes: 5 additions & 5 deletions src/Runner.Common/JobServerQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,17 +756,17 @@ private List<TimelineRecord> MergeTimelineRecords(List<TimelineRecord> timelineR
timelineRecord.State = rec.State ?? timelineRecord.State;
timelineRecord.WorkerName = rec.WorkerName ?? timelineRecord.WorkerName;

if (rec.ErrorCount != null && rec.ErrorCount > 0)
if (rec.ErrorCount > 0)
{
timelineRecord.ErrorCount = rec.ErrorCount;
}

if (rec.WarningCount != null && rec.WarningCount > 0)
if (rec.WarningCount > 0)
{
timelineRecord.WarningCount = rec.WarningCount;
}

if (rec.NoticeCount != null && rec.NoticeCount > 0)
if (rec.NoticeCount > 0)
{
timelineRecord.NoticeCount = rec.NoticeCount;
}
Expand Down Expand Up @@ -797,7 +797,7 @@ private List<TimelineRecord> MergeTimelineRecords(List<TimelineRecord> timelineR
foreach (var record in mergedRecords)
{
Trace.Verbose($" Record: t={record.RecordType}, n={record.Name}, s={record.State}, st={record.StartTime}, {record.PercentComplete}%, ft={record.FinishTime}, r={record.Result}: {record.CurrentOperation}");
if (record.Issues != null && record.Issues.Count > 0)
if (record.Issues != null)
{
foreach (var issue in record.Issues)
{
Expand All @@ -807,7 +807,7 @@ private List<TimelineRecord> MergeTimelineRecords(List<TimelineRecord> timelineR
}
}

if (record.Variables != null && record.Variables.Count > 0)
if (record.Variables != null)
{
foreach (var variable in record.Variables)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Runner.Worker/ActionCommandManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GitHub.DistributedTask.Pipelines.ContextData;
using GitHub.DistributedTask.Pipelines.ContextData;
using GitHub.DistributedTask.WebApi;
using GitHub.Runner.Worker.Container;
using System;
Expand Down Expand Up @@ -276,7 +276,7 @@ public void ProcessCommand(IExecutionContext context, string line, ActionCommand
Message = $"Can't update {blocked} environment variable using ::set-env:: command."
};
issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = $"{Constants.Runner.UnsupportedCommand}_{envName}";
context.AddIssue(issue);
context.AddIssue(issue, ExecutionContextLogOptions.Default);

return;
}
Expand Down Expand Up @@ -315,7 +315,7 @@ public void ProcessCommand(IExecutionContext context, string line, ActionCommand
Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command)
};
issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand;
context.AddIssue(issue);
context.AddIssue(issue, ExecutionContextLogOptions.Default);
}

if (!command.Properties.TryGetValue(SetOutputCommandProperties.Name, out string outputName) || string.IsNullOrEmpty(outputName))
Expand Down Expand Up @@ -350,7 +350,7 @@ public void ProcessCommand(IExecutionContext context, string line, ActionCommand
Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command)
};
issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand;
context.AddIssue(issue);
context.AddIssue(issue, ExecutionContextLogOptions.Default);
}

if (!command.Properties.TryGetValue(SaveStateCommandProperties.Name, out string stateName) || string.IsNullOrEmpty(stateName))
Expand Down Expand Up @@ -666,7 +666,7 @@ public void ProcessCommand(IExecutionContext context, string inputLine, ActionCo
}
}

context.AddIssue(issue);
context.AddIssue(issue, ExecutionContextLogOptions.Default);
}

public static void ValidateLinesAndColumns(ActionCommand command, IExecutionContext context)
Expand Down
Loading

0 comments on commit f8a28c3

Please sign in to comment.