Version
v3.0.3
Environment
.NET 10
Steps to reproduce
Set the output destination with GITHUB_STEP_SUMMARY="./test-summary.md", then run the following tests using xunit.v3.mtp-v2 v3.2.2.
namespace Test;
public class UnitTest
{
public static TheoryData<string> GetText()
=> new(Enumerable.Range('一', 0xA000 - '一').Select(char.ConvertFromUtf32)
.Select(c => string.Join("", Enumerable.Repeat(c, 10))));
[Theory]
[MemberData(nameof(GetText))]
public void Test1(string text) => Assert.True(text.Length > 0);
[Theory]
[MemberData(nameof(GetText))]
public void Test2(string text) => Assert.True(text.Length > 0);
}
Details
test-summary.md
The summary should be under 1024 KB, but it is 3404 KB. It seems the issue is that it’s being truncated based on char length rather than the UTF-8 byte count.
|
private string TruncateSummary(string content) |
|
{ |
|
// Try to extract the underlying file path from the summary writer to monitor file size |
|
var filePath = summaryWriter is StreamWriter writer |
|
? writer.BaseStream switch |
|
{ |
|
ContentionTolerantWriteFileStream cts => cts.FilePath, |
|
FileStream fs => fs.Name, |
|
_ => null, |
|
} |
|
: null; |
|
|
|
if (string.IsNullOrWhiteSpace(filePath)) |
|
return content; |
|
|
|
var existingSize = File.Exists(filePath) ? new FileInfo(filePath).Length : 0L; |
|
|
|
// Calculate required size for the summary content |
|
var contentSize = Encoding.UTF8.GetByteCount(content); |
|
var newLineSize = Encoding.UTF8.GetByteCount(Environment.NewLine); |
|
var requiredSize = contentSize + newLineSize * 3; |
|
|
|
if (existingSize + requiredSize > GitHubEnvironment.SummaryFileSizeLimit) |
|
{ |
|
var availableSize = (int) |
|
Math.Min( |
|
GitHubEnvironment.SummaryFileSizeLimit - existingSize - newLineSize * 3L, |
|
int.MaxValue |
|
); |
|
|
|
return |
|
// There is enough space to fit the whole content |
|
availableSize > 0 |
|
&& requiredSize <= availableSize |
|
? content |
|
// There is enough space to fit some of the content |
|
: availableSize > 0 && requiredSize > availableSize ? content[..availableSize] |
|
// There is no space at all |
|
: string.Empty; |
|
} |
|
|
|
return content; |
|
} |
Checklist
Version
v3.0.3
Environment
.NET 10
Steps to reproduce
Set the output destination with
GITHUB_STEP_SUMMARY="./test-summary.md", then run the following tests using xunit.v3.mtp-v2 v3.2.2.Details
test-summary.md
The summary should be under 1024 KB, but it is 3404 KB. It seems the issue is that it’s being truncated based on
charlength rather than the UTF-8 byte count.GitHubActionsTestLogger/GitHubActionsTestLogger/GitHub/GitHubWorkflow.cs
Lines 89 to 131 in bac6569
Checklist