Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Runner.Worker/ExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public interface IExecutionContext : IRunnerService
void FlushDeferredOutcomeConclusion();

void AddIssue(Issue issue, ExecutionContextLogOptions logOptions);
int GetErrorCount();
void Progress(int percentage, string currentOperation = null);
void UpdateDetailTimelineRecord(TimelineRecord record);

Expand Down Expand Up @@ -238,6 +239,13 @@ private ExecutionContext(ExecutionContext parent, bool embedded)
// as its enclosing execution context.
public bool IsEmbedded { get; private init; }

public int GetErrorCount()
{
return IsEmbedded
? (_embeddedIssueCollector?.Count(x => x.Type == IssueType.Error) ?? 0)
: _record.ErrorCount;
}

public TaskResult? Result
{
get
Expand Down
6 changes: 6 additions & 0 deletions src/Runner.Worker/Handlers/ContainerActionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,16 @@ public async Task RunAsync(ActionRunStage stage)
using (var stdoutManager = new OutputManager(ExecutionContext, ActionCommandManager, container))
using (var stderrManager = new OutputManager(ExecutionContext, ActionCommandManager, container))
{
var errorCountBeforeRun = ExecutionContext.GetErrorCount();
var runExitCode = await dockerManager.DockerRun(ExecutionContext, container, stdoutManager.OnDataReceived, stderrManager.OnDataReceived);
ExecutionContext.Debug($"Docker Action run completed with exit code {runExitCode}");
if (runExitCode != 0)
{
if (ExecutionContext.GetErrorCount() == errorCountBeforeRun)
{
ExecutionContext.Error($"Docker Action run completed with exit code {runExitCode}.");
}

ExecutionContext.Result = TaskResult.Failed;
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/Runner.Worker/Handlers/NodeScriptActionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ public async Task RunAsync(ActionRunStage stage)
StepHost.OutputDataReceived += stdoutManager.OnDataReceived;
StepHost.ErrorDataReceived += stderrManager.OnDataReceived;

var errorCountBeforeRun = ExecutionContext.GetErrorCount();

// Execute the process. Exit code 0 should always be returned.
// A non-zero exit code indicates infrastructural failure.
// Task failure should be communicated over STDOUT using ## commands.
Expand Down Expand Up @@ -188,6 +190,11 @@ public async Task RunAsync(ActionRunStage stage)
ExecutionContext.Debug($"Node Action run completed with exit code {exitCode}");
if (exitCode != 0)
{
if (ExecutionContext.GetErrorCount() == errorCountBeforeRun)
{
ExecutionContext.Error($"Node Action run completed with exit code {exitCode}.");
}

ExecutionContext.Result = TaskResult.Failed;
}
}
Expand Down