mirror of
https://github.com/actions/runner.git
synced 2025-12-14 04:53:34 +00:00
separate logic into attachment summary func
This commit is contained in:
@@ -356,28 +356,8 @@ namespace GitHub.Runner.Worker
|
|||||||
private void CompleteStep(IStep step, TaskResult? result = null, string resultCode = null)
|
private void CompleteStep(IStep step, TaskResult? result = null, string resultCode = null)
|
||||||
{
|
{
|
||||||
var executionContext = step.ExecutionContext;
|
var executionContext = step.ExecutionContext;
|
||||||
var parentContext = executionContext.Root;
|
|
||||||
var stepSummaryFilePath = executionContext.GetGitHubContext("step_summary");
|
|
||||||
|
|
||||||
Trace.Info($"Reading step summary data from {stepSummaryFilePath}");
|
CreateSummaryAttachment(step);
|
||||||
|
|
||||||
var summaryExists = File.Exists(stepSummaryFilePath);
|
|
||||||
if (summaryExists)
|
|
||||||
{
|
|
||||||
Trace.Info($"File exists: {stepSummaryFilePath}");
|
|
||||||
|
|
||||||
var summaryFileIsEmpty = new FileInfo(stepSummaryFilePath).Length == 0;
|
|
||||||
if (summaryFileIsEmpty)
|
|
||||||
{
|
|
||||||
Trace.Info($"Summary file ({summaryFileIsEmpty}) is empty, skipping attachment upload");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var stepID = executionContext.Id;
|
|
||||||
Trace.Info($"Queueing file ({stepSummaryFilePath}) for attachment upload ({stepID})");
|
|
||||||
parentContext.QueueAttachFile(ChecksAttachmentType.StepSummary, stepID.ToString(), stepSummaryFilePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
executionContext.Complete(result, resultCode: resultCode);
|
executionContext.Complete(result, resultCode: resultCode);
|
||||||
}
|
}
|
||||||
@@ -398,5 +378,31 @@ namespace GitHub.Runner.Worker
|
|||||||
File.Create(stepSummaryFilePath).Close();
|
File.Create(stepSummaryFilePath).Close();
|
||||||
return stepSummaryFilePath;
|
return stepSummaryFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateSummaryAttachment(IStep step) {
|
||||||
|
var executionContext = step.ExecutionContext;
|
||||||
|
var parentContext = executionContext.Root;
|
||||||
|
var stepSummaryFilePath = executionContext.GetGitHubContext("step_summary");
|
||||||
|
var stepID = executionContext.Id;
|
||||||
|
|
||||||
|
Trace.Info($"Reading step summary data from {stepSummaryFilePath}");
|
||||||
|
|
||||||
|
var summaryExists = File.Exists(stepSummaryFilePath);
|
||||||
|
if (summaryExists)
|
||||||
|
{
|
||||||
|
Trace.Info($"File exists: {stepSummaryFilePath}");
|
||||||
|
|
||||||
|
var summaryFileIsEmpty = new FileInfo(stepSummaryFilePath).Length == 0;
|
||||||
|
if (summaryFileIsEmpty)
|
||||||
|
{
|
||||||
|
Trace.Info($"Summary file ({summaryFileIsEmpty}) is empty, skipping attachment upload");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Trace.Info($"Queueing file ({stepSummaryFilePath}) for attachment upload ({stepID})");
|
||||||
|
parentContext.QueueAttachFile(ChecksAttachmentType.StepSummary, stepID.ToString(), stepSummaryFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user