From a7aadf561531e581f92663e88d33e1d488cbcd7a Mon Sep 17 00:00:00 2001 From: Yang Cao Date: Wed, 20 Apr 2022 17:08:50 -0400 Subject: [PATCH] Update Actions Summary limit to 1MiB (#1839) * Update Actions Summary limit to 1MiB * Making limit a public const so other part of the codebase is aware of the limit too --- src/Runner.Worker/FileCommandManager.cs | 12 ++++++------ src/Test/L0/Worker/CreateStepSummaryCommandL0.cs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Runner.Worker/FileCommandManager.cs b/src/Runner.Worker/FileCommandManager.cs index 8d8ef770e..0005a5f5e 100644 --- a/src/Runner.Worker/FileCommandManager.cs +++ b/src/Runner.Worker/FileCommandManager.cs @@ -15,7 +15,7 @@ namespace GitHub.Runner.Worker { void InitializeFiles(IExecutionContext context, ContainerInfo container); void ProcessFiles(IExecutionContext context, ContainerInfo container); - + } public sealed class FileCommandManager : RunnerService, IFileCommandManager @@ -57,7 +57,7 @@ namespace GitHub.Runner.Worker TryDeleteFile(newPath); File.Create(newPath).Dispose(); - var pathToSet = container != null ? container.TranslateToContainerPath(newPath) : newPath; + var pathToSet = container != null ? container.TranslateToContainerPath(newPath) : newPath; context.SetGitHubContext(fileCommand.ContextName, pathToSet); } } @@ -66,7 +66,7 @@ namespace GitHub.Runner.Worker { foreach (var fileCommand in _commandExtensions) { - try + try { fileCommand.ProcessCommand(context, Path.Combine(_fileCommandDirectory, fileCommand.FilePrefix + _fileSuffix),container); } @@ -266,7 +266,7 @@ namespace GitHub.Runner.Worker public sealed class CreateStepSummaryCommand : RunnerService, IFileCommandExtension { - private const int _attachmentSizeLimit = 128 * 1024; + public const int AttachmentSizeLimit = 1024 * 1024; public string ContextName => "step_summary"; public string FilePrefix => "step_summary_"; @@ -296,9 +296,9 @@ namespace GitHub.Runner.Worker return; } - if (fileSize > _attachmentSizeLimit) + if (fileSize > AttachmentSizeLimit) { - context.Error(String.Format(Constants.Runner.UnsupportedSummarySize, _attachmentSizeLimit / 1024, fileSize / 1024)); + context.Error(String.Format(Constants.Runner.UnsupportedSummarySize, AttachmentSizeLimit / 1024, fileSize / 1024)); Trace.Info($"Step Summary file ({filePath}) is too large ({fileSize} bytes); skipping attachment upload"); return; diff --git a/src/Test/L0/Worker/CreateStepSummaryCommandL0.cs b/src/Test/L0/Worker/CreateStepSummaryCommandL0.cs index 3ce96b87e..a15e19ad3 100644 --- a/src/Test/L0/Worker/CreateStepSummaryCommandL0.cs +++ b/src/Test/L0/Worker/CreateStepSummaryCommandL0.cs @@ -33,7 +33,7 @@ namespace GitHub.Runner.Common.Tests.Worker using (var hostContext = Setup(featureFlagState: "false")) { var stepSummaryFile = Path.Combine(_rootDirectory, "feature-off"); - + _createStepCommand.ProcessCommand(_executionContext.Object, stepSummaryFile, null); _jobExecutionContext.Complete(); @@ -117,7 +117,7 @@ namespace GitHub.Runner.Common.Tests.Worker using (var hostContext = Setup()) { var stepSummaryFile = Path.Combine(_rootDirectory, "empty-file"); - File.WriteAllBytes(stepSummaryFile, new byte[128 * 1024 + 1]); + File.WriteAllBytes(stepSummaryFile, new byte[CreateStepSummaryCommand.AttachmentSizeLimit + 1]); _createStepCommand.ProcessCommand(_executionContext.Object, stepSummaryFile, null); _jobExecutionContext.Complete();