From f2eab7823fc8e81a0b5ae3334060f596966cb722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bertrand?= Date: Tue, 17 May 2022 08:30:39 +0200 Subject: [PATCH 1/5] switch to net6.0 --- .github/workflows/build.yml | 12 ++++++------ src/NVika.Tests/NVika.Tests.csproj | 2 +- src/NVika/NVika.csproj | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index efa0f2ae..419e22cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,9 +29,9 @@ jobs: nuget- - name: Setup .NET Core - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v2 with: - dotnet-version: 3.1.x + dotnet-version: '6.0.x' - name: Install GitVersion uses: gittools/actions/gitversion/setup@v0.9.11 @@ -60,10 +60,10 @@ jobs: - name: GendarmeAnalysis run: | nuget install mono.gendarme -ExcludeVersion -OutputDirectory tools - ./tools/Mono.Gendarme/tools/gendarme.exe --xml GendarmeReport.xml --ignore gendarme.ignore .\src\NVika\bin\Release\netcoreapp3.1\NVika.exe + ./tools/Mono.Gendarme/tools/gendarme.exe --xml GendarmeReport.xml --ignore gendarme.ignore .\src\NVika\bin\Release\net6.0\NVika.exe - name: LaunchNVika - run: .\src\NVika\bin\Release\netcoreapp3.1\NVika.exe --debug --includesource inspectcodereport.xml ./src/NVika/bin/Release/netcoreapp3.1/static-analysis.sarif.json GendarmeReport.xml + run: .\src\NVika\bin\Release\net6.0\NVika.exe --debug --includesource inspectcodereport.xml ./src/NVika/bin/Release/net6.0/static-analysis.sarif.json GendarmeReport.xml # - name: Create release notes # run: | @@ -74,13 +74,13 @@ jobs: run: | Copy-Item -Path resources/icon.png -Destination src\NVika.MSBuild\ mkdir src\NVika.MSBuild\tools\ - Copy-Item -Path "src/NVika/bin/Release/netcoreapp3.1/publish/*" -Destination src\NVika.MSBuild\tools\ + Copy-Item -Path "src/NVika/bin/Release/net6.0/publish/*" -Destination src\NVika.MSBuild\tools\ nuget pack src/NVika.MSBuild/NVika.MSBuild.nuspec -Version ${{ steps.gitversion.outputs.nuGetVersionV2 }} -OutputDirectory artifacts/nuget - name: Create netcore packages run: | mkdir ./artifacts/zips - Compress-Archive -Path src/NVika/bin/Release/netcoreapp3.1/publish/* -DestinationPath "artifacts/zips/NVika.netcore.${{ steps.gitversion.outputs.nuGetVersionV2 }}.zip" + Compress-Archive -Path src/NVika/bin/Release/net6.0/publish/* -DestinationPath "artifacts/zips/NVika.netcore.${{ steps.gitversion.outputs.nuGetVersionV2 }}.zip" Copy-Item -Path "src/NVika/bin/Release/NVika.${{ steps.gitversion.outputs.nuGetVersionV2 }}.nupkg" -Destination artifacts/nuget - name: Create windows version diff --git a/src/NVika.Tests/NVika.Tests.csproj b/src/NVika.Tests/NVika.Tests.csproj index 795f72e5..6d0abf83 100644 --- a/src/NVika.Tests/NVika.Tests.csproj +++ b/src/NVika.Tests/NVika.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 false diff --git a/src/NVika/NVika.csproj b/src/NVika/NVika.csproj index 8486122b..4a526ffd 100644 --- a/src/NVika/NVika.csproj +++ b/src/NVika/NVika.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 bin\$(Configuration)\$(TargetFramework)\static-analysis.sarif.json;version=2 true nvika From 54186b88edf0bf4e32241c75dd6289b7a50577ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bertrand?= Date: Tue, 17 May 2022 08:41:25 +0200 Subject: [PATCH 2/5] skip tests if output is empty --- src/NVika.Tests/NVika.Tests.csproj | 1 + src/NVika.Tests/ProgramTest.cs | 42 ++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/NVika.Tests/NVika.Tests.csproj b/src/NVika.Tests/NVika.Tests.csproj index 6d0abf83..86c117bd 100644 --- a/src/NVika.Tests/NVika.Tests.csproj +++ b/src/NVika.Tests/NVika.Tests.csproj @@ -46,6 +46,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/NVika.Tests/ProgramTest.cs b/src/NVika.Tests/ProgramTest.cs index 110842c8..780e3a88 100644 --- a/src/NVika.Tests/ProgramTest.cs +++ b/src/NVika.Tests/ProgramTest.cs @@ -8,7 +8,7 @@ namespace NVika.Tests { public class ProgramTest { - [Fact] + [SkippableFact] public void Run_NoParameters_ShouldShowHelp() { // arrange @@ -16,17 +16,21 @@ public void Run_NoParameters_ShouldShowHelp() Console.SetOut(new StringWriter(output)); // act - var exitCode = new Program().Run(new string[0]); + var exitCode = new Program().Run(Array.Empty()); - // assert var consoleOutput = output.ToString(); + + // skip + Skip.If(string.IsNullOrEmpty(consoleOutput)); + + // assert Assert.Equal(1, exitCode); Assert.Contains($"NVika \"{Assembly.GetAssembly(typeof(Program)).GetName().Version}\"", consoleOutput); Assert.Contains("Executing parsereport (Parse the report and show warnings in console or inject them to the build server):", consoleOutput); Assert.Contains("No report was specified. You must indicate at least one report file.", consoleOutput); } - [Fact] + [SkippableFact] public void Run_UnknownCommand_BuildServerIsDefaultCommand() { // arrange @@ -36,15 +40,19 @@ public void Run_UnknownCommand_BuildServerIsDefaultCommand() // act var exitCode = new Program().Run(new[] { "unkowncommand" }); - // assert var consoleOutput = output.ToString(); + + // skip + Skip.If(string.IsNullOrEmpty(consoleOutput)); + + // assert Assert.Equal(2, exitCode); Assert.Contains($"NVika \"{Assembly.GetAssembly(typeof(Program)).GetName().Version}\"", consoleOutput); Assert.Contains("Executing parsereport (Parse the report and show warnings in console or inject them to the build server):", consoleOutput); Assert.Contains("The report \"unkowncommand\" was not found.", consoleOutput); } - [Fact] + [SkippableFact] public void Run_BuildServer_NonExistingReport_ShouldLogErrorToConsole() { // arrange @@ -54,14 +62,18 @@ public void Run_BuildServer_NonExistingReport_ShouldLogErrorToConsole() // act var exitCode = new Program().Run(new[] { "parsereport", "nonexistingreport.abc" }); - // assert var consoleOutput = output.ToString(); + + // skip + Skip.If(string.IsNullOrEmpty(consoleOutput)); + + // assert Assert.Equal(2, exitCode); Assert.Contains($"NVika \"{Assembly.GetAssembly(typeof(Program)).GetName().Version}\"", consoleOutput); Assert.Contains("The report \"nonexistingreport.abc\" was not found.", consoleOutput); } - [Fact] + [SkippableFact] public void Run_NoParameters_ExceptionAreLogged() { // arrange @@ -71,15 +83,19 @@ public void Run_NoParameters_ExceptionAreLogged() // act var exitCode = new Program().Run(null); - // assert var consoleOutput = output.ToString(); + + // skip + Skip.If(string.IsNullOrEmpty(consoleOutput)); + + // assert Assert.Equal(1, exitCode); Assert.Contains($"NVika \"{Assembly.GetAssembly(typeof(Program)).GetName().Version}\"", consoleOutput); Assert.Contains("An unexpected error occurred:", consoleOutput); Assert.Contains("System.NullReferenceException: Object reference not set to an instance of an object", consoleOutput); } - [Fact] + [SkippableFact] public void Run_ApplicationException_AreLoggedAndHaveExitCode() { // arrange @@ -90,8 +106,12 @@ public void Run_ApplicationException_AreLoggedAndHaveExitCode() // act var exitCode = new Program().Run(new[] { "parsereport", reportPath, "--debug" }); - // assert var consoleOutput = output.ToString(); + + // skip + Skip.If(string.IsNullOrEmpty(consoleOutput)); + + // assert Assert.Equal(3, exitCode); Assert.Contains($"NVika \"{Assembly.GetAssembly(typeof(Program)).GetName().Version}\"", consoleOutput); Assert.Contains($"Report path is \"{reportPath}\"", consoleOutput); From b52637b9c40906d464f341ecf903e306d80846e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bertrand?= Date: Tue, 17 May 2022 10:10:14 +0200 Subject: [PATCH 3/5] update release notes --- ReleaseNotes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index c588deca..972670da 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,7 @@ +# 3.0.0 (2022-05-xx) + +- [#347](https://github.com/laedit/vika/pull/347) - Switch to .NET 6 +breaking + # 2.3.0 (2022-05-17) - [#343](https://github.com/laedit/vika/pull/343) - Include suggestions in GitHub output by [DanRigby](https://github.com/DanRigby) +enhancement From 906363fe3b4c497c1a69f3bc804a228f0e2d5e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bertrand?= Date: Tue, 17 May 2022 10:16:04 +0200 Subject: [PATCH 4/5] Fix tests --- src/NVika.Tests/BuildServers/AppVeyorTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NVika.Tests/BuildServers/AppVeyorTest.cs b/src/NVika.Tests/BuildServers/AppVeyorTest.cs index 9703279c..ec087143 100644 --- a/src/NVika.Tests/BuildServers/AppVeyorTest.cs +++ b/src/NVika.Tests/BuildServers/AppVeyorTest.cs @@ -214,7 +214,7 @@ public void WriteIntegration_AppVeyorAPIError() var logs = _loggerOutput.ToString(); Assert.NotNull(logs); - Assert.Contains("An error is occurred during the call to AppVeyor API: \"StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: , Headers:", logs); + Assert.Contains("An error is occurred during the call to AppVeyor API: \"StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.EmptyContent, Headers:", logs); } private MockHttpClientFactory GetHttpClientFactory(HttpStatusCode responseStatusCode = HttpStatusCode.OK) From 5fc392db8dc56d10a131476d118b9d2b9f1f4d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bertrand?= Date: Tue, 17 May 2022 10:34:28 +0200 Subject: [PATCH 5/5] fix sarif parser --- src/NVika/Parsers/SarifParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NVika/Parsers/SarifParser.cs b/src/NVika/Parsers/SarifParser.cs index 41014e5a..210cfc61 100644 --- a/src/NVika/Parsers/SarifParser.cs +++ b/src/NVika/Parsers/SarifParser.cs @@ -63,7 +63,7 @@ public override IEnumerable Parse(string reportPath) string filePath = null; Region region = null; - if (result.Locations.Count > 0) + if (result.Locations?.Count > 0) { if (result.Locations[0].PhysicalLocation != null) {