Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #6 from justaprogrammer/core-update
Browse files Browse the repository at this point in the history
Core update
  • Loading branch information
StanleyGoldman authored Nov 1, 2018
2 parents 7349da7 + 709a7b5 commit 33b9949
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 77 deletions.
Empty file added lib/.placeholder
Empty file.
Binary file added lib/BCC-Core.0.1.5-comparable0001.nupkg
Binary file not shown.
5 changes: 2 additions & 3 deletions src/BCC.MSBuildLog.Tests/BCC.MSBuildLog.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@

<ItemGroup>
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="BCC-Core" Version="0.1.3" />
<PackageReference Include="Bogus" Version="24.3.0" />
<PackageReference Include="FluentAssertions" Version="5.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="2.1.0.256" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
83 changes: 47 additions & 36 deletions src/BCC.MSBuildLog.Tests/Services/BinaryLogProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public void Should_TestConsoleApp1_Warning()
logData.WarningCount.Should().Be(1);
logData.Annotations.Should().AllBeEquivalentTo(
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Warning, "CS0219",
"CS0219: The variable 'hello' is assigned but its value is never used",
13, 13)
"TestConsoleApp1/Program.cs",
13,
13,
CheckWarningLevel.Warning,
"CS0219: The variable 'hello' is assigned but its value is never used")
);
}

Expand All @@ -72,9 +73,10 @@ public void Should_TestConsoleApp1_Warning_ConfigureAs_Warning_For_Other_Code()
logData.Annotations.Should().AllBeEquivalentTo(
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Warning, "CS0219",
"CS0219: The variable 'hello' is assigned but its value is never used",
13, 13)
13,
13,
CheckWarningLevel.Warning,
"CS0219: The variable 'hello' is assigned but its value is never used")
);
}

Expand All @@ -101,9 +103,10 @@ public void Should_TestConsoleApp1_Warning_ConfigureAs_Warning()
logData.Annotations.Should().AllBeEquivalentTo(
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Warning, "CS0219",
"CS0219: The variable 'hello' is assigned but its value is never used",
13, 13)
13,
13,
CheckWarningLevel.Warning,
"CS0219: The variable 'hello' is assigned but its value is never used")
);
}

Expand All @@ -130,9 +133,10 @@ public void Should_TestConsoleApp1_Warning_ConfigureAs_Notice()
logData.Annotations.Should().AllBeEquivalentTo(
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Notice, "CS0219",
"CS0219: The variable 'hello' is assigned but its value is never used",
13, 13)
13,
13,
CheckWarningLevel.Notice,
"CS0219: The variable 'hello' is assigned but its value is never used")
);
}

Expand All @@ -159,9 +163,10 @@ public void Should_TestConsoleApp1_Warning_ConfigureAs_Error()
logData.Annotations.Should().AllBeEquivalentTo(
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Failure, "CS0219",
"CS0219: The variable 'hello' is assigned but its value is never used",
13, 13)
13,
13,
CheckWarningLevel.Failure,
"CS0219: The variable 'hello' is assigned but its value is never used")
);
}

Expand Down Expand Up @@ -197,9 +202,10 @@ public void Should_TestConsoleApp1_Error()
logData.Annotations.Should().AllBeEquivalentTo(
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Failure, "CS1002",
"CS1002: ; expected",
13, 13)
13,
13,
CheckWarningLevel.Failure,
"CS1002: ; expected")
);
}

Expand All @@ -215,9 +221,10 @@ public void Should_TestConsoleApp1_CodeAnalysis()
logData.Annotations.Should().AllBeEquivalentTo(
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Warning, "CA2213",
"CA2213: Microsoft.Usage : 'Program.MyClass' contains field 'Program.MyClass._inner' that is of IDisposable type: 'Program.MyOTherClass'. Change the Dispose method on 'Program.MyClass' to call Dispose or Close on this field.",
20, 20)
20,
20,
CheckWarningLevel.Warning,
"CA2213: Microsoft.Usage : 'Program.MyClass' contains field 'Program.MyClass._inner' that is of IDisposable type: 'Program.MyOTherClass'. Change the Dispose method on 'Program.MyClass' to call Dispose or Close on this field.")
);
}

Expand All @@ -234,17 +241,19 @@ public void Should_MSBLOC()

logData.Annotations[0].Should().BeEquivalentTo(
new Annotation(
"MSBLOC.Core.Tests/Services/BinaryLogProcessorTests.cs",
CheckWarningLevel.Warning,"CS0219",
"CS0219: The variable 'filename' is assigned but its value is never used",
56, 56));
"MSBLOC.Core.Tests/Services/BinaryLogProcessorTests.cs",
56,
56,
CheckWarningLevel.Warning,
"CS0219: The variable 'filename' is assigned but its value is never used"));

logData.Annotations[1].Should().BeEquivalentTo(
new Annotation(
"MSBLOC.Core.Tests/Services/BinaryLogProcessorTests.cs",
CheckWarningLevel.Warning,"CS0219",
"CS0219: The variable 'filename' is assigned but its value is never used",
83, 83));
"MSBLOC.Core.Tests/Services/BinaryLogProcessorTests.cs",
83,
83,
CheckWarningLevel.Warning,
"CS0219: The variable 'filename' is assigned but its value is never used"));
}

[Fact]
Expand All @@ -261,16 +270,18 @@ public void Should_Parse_OctokitGraphQL()
logData.Annotations[0].Should().BeEquivalentTo(
new Annotation(
"Octokit.GraphQL.Core/Connection.cs",
CheckWarningLevel.Warning,"CS1591",
"CS1591: Missing XML comment for publicly visible type or member 'Connection.Uri'",
43, 43));
43,
43,
CheckWarningLevel.Warning,
"CS1591: Missing XML comment for publicly visible type or member 'Connection.Uri'"));

logData.Annotations[1].Should().BeEquivalentTo(
new Annotation(
"Octokit.GraphQL.Core/Connection.cs",
CheckWarningLevel.Warning,"CS1591",
"CS1591: Missing XML comment for publicly visible type or member 'Connection.CredentialStore'",
44, 44));
44,
44,
CheckWarningLevel.Warning,
"CS1591: Missing XML comment for publicly visible type or member 'Connection.CredentialStore'"));
}
[Fact]
public void Should_Parse_GitHubVisualStudio()
Expand Down
66 changes: 34 additions & 32 deletions src/BCC.MSBuildLog.Tests/Services/BuildLogProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Should_Create_Empty_CheckRun()

var checkRun = GetCheckRun(CreateMockBinaryLogProcessor(annotations));

checkRun.Success.Should().BeTrue();
checkRun.Conclusion.Should().Be(CheckConclusion.Success);
checkRun.Name.Should().Be("MSBuild Log");
checkRun.Title.Should().Be("0 Errors 0 Warnings");
checkRun.Summary.Should().Be(string.Empty);
Expand Down Expand Up @@ -91,7 +91,7 @@ public void Should_Create_Empty_CheckRun_With_Configuration()

var checkRun = GetCheckRun(CreateMockBinaryLogProcessor(annotations), configurationFile: configurationFile, mockFileSystem: mockFileSystem);

checkRun.Success.Should().BeTrue();
checkRun.Conclusion.Should().Be(CheckConclusion.Success);
checkRun.Name.Should().Be("MSBuild Log");
checkRun.Title.Should().Be("0 Errors 0 Warnings");
checkRun.Summary.Should().Be(string.Empty);
Expand All @@ -105,14 +105,15 @@ public void Should_Create_CheckRun_With_Warning()
{
new Annotation(
Faker.System.FilePath(),
Faker.Random.Int(),
Faker.Random.Int(),
CheckWarningLevel.Warning,
Faker.Lorem.Word(), Faker.Lorem.Word(),
Faker.Random.Int(), Faker.Random.Int())
Faker.Lorem.Word())
};

var checkRun = GetCheckRun(CreateMockBinaryLogProcessor(annotations));

checkRun.Success.Should().BeTrue();
checkRun.Conclusion.Should().Be(CheckConclusion.Success);
checkRun.Name.Should().Be("MSBuild Log");
checkRun.Title.Should().Be("0 Errors 0 Warnings");
checkRun.Summary.Should().Be(string.Empty);
Expand All @@ -126,9 +127,10 @@ public void Should_Create_CheckRun_With_Configuration()
{
new Annotation(
Faker.System.FilePath(),
CheckWarningLevel.Warning,
Faker.Lorem.Word(), Faker.Lorem.Word(),
Faker.Random.Int(), Faker.Random.Int())
Faker.Random.Int(),
Faker.Random.Int(),
CheckWarningLevel.Warning,
Faker.Lorem.Word())
};

var expectedCheckRunConfiguration = new CheckRunConfiguration
Expand All @@ -155,7 +157,7 @@ public void Should_Create_CheckRun_With_Configuration()
var checkRunConfiguration = mockBinaryLogProcessor.ReceivedCalls().First().GetArguments()[2] as CheckRunConfiguration;
checkRunConfiguration.Should().BeEquivalentTo(expectedCheckRunConfiguration);

checkRun.Success.Should().BeTrue();
checkRun.Conclusion.Should().Be(CheckConclusion.Success);
checkRun.Name.Should().Be(expectedCheckRunConfiguration.Name);
checkRun.Title.Should().Be("0 Errors 0 Warnings");
checkRun.Summary.Should().Be(string.Empty);
Expand All @@ -169,14 +171,14 @@ public void Should_Create_CheckRun_With_Failure()
{
new Annotation(
Faker.System.FilePath(),
CheckWarningLevel.Failure,
Faker.Lorem.Word(), Faker.Lorem.Word(),
Faker.Random.Int(), Faker.Random.Int())
Faker.Random.Int(),
Faker.Random.Int(),
CheckWarningLevel.Failure, Faker.Lorem.Word())
};

var checkRun = GetCheckRun(CreateMockBinaryLogProcessor(annotations));

checkRun.Success.Should().BeFalse();
checkRun.Conclusion.Should().Be(CheckConclusion.Failure);
checkRun.Name.Should().Be("MSBuild Log");
checkRun.Title.Should().Be("0 Errors 0 Warnings");
checkRun.Summary.Should().Be(string.Empty);
Expand All @@ -190,19 +192,19 @@ public void Should_Create_CheckRun_With_WarningAndFailure()
{
new Annotation(
Faker.System.FilePath(),
CheckWarningLevel.Warning,
Faker.Lorem.Word(), Faker.Lorem.Word(),
Faker.Random.Int(), Faker.Random.Int()),
Faker.Random.Int(),
Faker.Random.Int(),
CheckWarningLevel.Warning, Faker.Lorem.Word()),
new Annotation(
Faker.System.FilePath(),
CheckWarningLevel.Failure,
Faker.Lorem.Word(), Faker.Lorem.Word(),
Faker.Random.Int(), Faker.Random.Int())
Faker.Random.Int(),
Faker.Random.Int(),
CheckWarningLevel.Failure, Faker.Lorem.Word())
};

var checkRun = GetCheckRun(CreateMockBinaryLogProcessor(annotations));

checkRun.Success.Should().BeFalse();
checkRun.Conclusion.Should().Be(CheckConclusion.Failure);
checkRun.Name.Should().Be("MSBuild Log");
checkRun.Title.Should().Be("0 Errors 0 Warnings");
checkRun.Summary.Should().Be(string.Empty);
Expand All @@ -216,17 +218,17 @@ public void Should_Create_CheckRun_TestConsoleApp1_Warning()
{
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Warning, "CS0219",
"CS0219: The variable 'hello' is assigned but its value is never used",
13, 13)
13,
13,
CheckWarningLevel.Warning, "CS0219: The variable 'hello' is assigned but its value is never used")
};

var cloneRoot = @"C:\projects\testconsoleapp1\";
var resourcePath = TestUtils.GetResourcePath("testconsoleapp1-1warning.binlog");

var checkRun = GetCheckRun(new BinaryLogProcessor(new BinaryLogReader(), TestLogger.Create<BinaryLogProcessor>(_testOutputHelper)), resourcePath, cloneRoot);

checkRun.Success.Should().BeTrue();
checkRun.Conclusion.Should().Be(CheckConclusion.Success);
checkRun.Name.Should().Be("MSBuild Log");
checkRun.Title.Should().Be("0 Errors 1 Warning");
checkRun.Summary.Should().Be(string.Empty);
Expand All @@ -240,17 +242,17 @@ public void Should_Create_CheckRun_TestConsoleApp1_Error()
{
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Failure, "CS1002",
"CS1002: ; expected",
13, 13)
13,
13,
CheckWarningLevel.Failure, "CS1002: ; expected")
};

var cloneRoot = @"C:\projects\testconsoleapp1\";
var resourcePath = TestUtils.GetResourcePath("testconsoleapp1-1error.binlog");

var checkRun = GetCheckRun(new BinaryLogProcessor(new BinaryLogReader(), TestLogger.Create<BinaryLogProcessor>(_testOutputHelper)), resourcePath, cloneRoot);

checkRun.Success.Should().BeFalse();
checkRun.Conclusion.Should().Be(CheckConclusion.Failure);
checkRun.Name.Should().Be("MSBuild Log");
checkRun.Title.Should().Be("1 Error 0 Warnings");
checkRun.Summary.Should().Be(string.Empty);
Expand All @@ -264,17 +266,17 @@ public void Should_Create_CheckRun_TestConsoleApp1_CodeAnalysis()
{
new Annotation(
"TestConsoleApp1/Program.cs",
CheckWarningLevel.Warning, "CA2213",
"CA2213: Microsoft.Usage : 'Program.MyClass' contains field 'Program.MyClass._inner' that is of IDisposable type: 'Program.MyOTherClass'. Change the Dispose method on 'Program.MyClass' to call Dispose or Close on this field.",
20, 20)
20,
20,
CheckWarningLevel.Warning, "CA2213: Microsoft.Usage : 'Program.MyClass' contains field 'Program.MyClass._inner' that is of IDisposable type: 'Program.MyOTherClass'. Change the Dispose method on 'Program.MyClass' to call Dispose or Close on this field.")
};

var cloneRoot = @"C:\projects\testconsoleapp1\";
var resourcePath = TestUtils.GetResourcePath("testconsoleapp1-codeanalysis.binlog");

var checkRun = GetCheckRun(new BinaryLogProcessor(new BinaryLogReader(), TestLogger.Create<BinaryLogProcessor>(_testOutputHelper)), resourcePath, cloneRoot);

checkRun.Success.Should().BeTrue();
checkRun.Conclusion.Should().Be(CheckConclusion.Success);
checkRun.Name.Should().Be("MSBuild Log");
checkRun.Title.Should().Be("0 Errors 1 Warning");
checkRun.Summary.Should().Be(string.Empty);
Expand Down
1 change: 1 addition & 0 deletions src/BCC.MSBuildLog.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{FFB46A17
..\Build.fsx = ..\Build.fsx
..\codecov.yml = ..\codecov.yml
..\GitVersion.yml = ..\GitVersion.yml
nuget.config = nuget.config
..\nuget\Package.nuspec = ..\nuget\Package.nuspec
..\paket.dependencies = ..\paket.dependencies
EndProjectSection
Expand Down
2 changes: 1 addition & 1 deletion src/BCC.MSBuildLog/BCC.MSBuildLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BCC-Core" Version="0.1.3" />
<PackageReference Include="BCC-Core" Version="0.1.5" />
<PackageReference Include="FluentCommandLineParser" Version="1.4.3" Condition="'$(TargetFramework)' == 'net471'" />
<PackageReference Include="FluentCommandLineParser" Version="1.5.0.20-commands" />
<PackageReference Include="FluentCommandLineParser-netstandard" Version="1.4.3.13" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
Expand Down
11 changes: 11 additions & 0 deletions src/BCC.MSBuildLog/Model/LogData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using BCC.Core.Model.CheckRunSubmission;

namespace BCC.MSBuildLog.Model
{
public class LogData
{
public int WarningCount { get; set; }
public int ErrorCount { get; set; }
public Annotation[] Annotations { get; set; }
}
}
7 changes: 3 additions & 4 deletions src/BCC.MSBuildLog/Services/BinaryLogProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ private Annotation CreateAnnotation(CheckWarningLevel checkWarningLevel, [NotNul

var relativePath = GetRelativePath(filePath, cloneRoot).Replace("\\", "/");

return new Annotation(relativePath, checkWarningLevel,
title, message,
lineNumber,
endLineNumber == 0 ? lineNumber : endLineNumber);
return new Annotation(relativePath, lineNumber,
endLineNumber == 0 ? lineNumber : endLineNumber, checkWarningLevel,
message);
}

private string GetRelativePath(string filespec, string folder)
Expand Down
2 changes: 1 addition & 1 deletion src/BCC.MSBuildLog/Services/BuildLogProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void Proces(string inputFile, string outputFile, string cloneRoot, string
var contents = JsonConvert.SerializeObject(new CreateCheckRun
{
Annotations = logData.Annotations,
Success = !hasAnyFailure,
Conclusion = !hasAnyFailure ? CheckConclusion.Success : CheckConclusion.Failure,
StartedAt = dateTimeOffset,
CompletedAt = DateTimeOffset.Now,
Summary = string.Empty,
Expand Down
Loading

0 comments on commit 33b9949

Please sign in to comment.