From b56c9ce138f59a5626d87eac5dc3c2abc88692b9 Mon Sep 17 00:00:00 2001 From: Oleg Shevchenko Date: Sat, 10 Aug 2019 13:47:28 +0300 Subject: [PATCH] Enable tests on CI build --- README.md | 9 ++++-- appveyor.yml | 2 ++ build.cake | 31 ++++++++++--------- .../ContextualLoggerSerilogFactoryAnalyzer.cs | 2 +- .../ReSharper.Structured.Logging.Rider.csproj | 3 ++ .../ReSharper.Structured.Logging.csproj | 3 ++ .../SerilogWrongContextType.cs.gold | 2 +- ...rper.Structured.Logging.Rider.Tests.csproj | 3 +- .../ReSharper.Structured.Logging.Tests.csproj | 3 ++ 9 files changed, 39 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8179c55..cfcdec4 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,20 @@ [![Build status](https://ci.appveyor.com/api/projects/status/c4riih64hbd4sebw?svg=true)](https://ci.appveyor.com/project/olsh/resharper-structured-logging) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=resharper-structured-logging&metric=alert_status)](https://sonarcloud.io/dashboard?id=resharper-structured-logging) -An extension for ReSharper that highlights structured logging templates and contains some useful analyzers +An extension for ReSharper and Rider IDE that highlights structured logging templates and contains some useful analyzers At the moment it supports Serilog, NLog, and Microsoft.Extensions.Logging -## Installation +## Installation ReSharper Look for `Structured Logging` in ReSharper -> Extension manager. [JetBrains Plugins Repository](https://plugins.jetbrains.com/plugin/12083-structured-logging) +## Installation Rider + +Look for `Structured Logging` in Settings -> Plugins -> Browse repositories. +[JetBrains Plugins Repository](https://plugins.jetbrains.com/plugin/12832-structured-logging) + ## Highlighting ![Highlighting](https://github.com/olsh/resharper-structured-logging/raw/master/images/highlighting.png) diff --git a/appveyor.yml b/appveyor.yml index bd82f70..037d236 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,6 +7,8 @@ build_script: dotnet cake -Target=CreateArtifact -buildConfig=Release dotnet cake -Host="Rider" -Target=CreateArtifact -buildConfig=Release + + dotnet cake -Target=Sonar -buildConfig=Release test: off cache: - '%USERPROFILE%\.nuget\packages -> **\*.csproj' diff --git a/build.cake b/build.cake index a3e3a00..ed1aa8f 100644 --- a/build.cake +++ b/build.cake @@ -1,5 +1,5 @@ #tool "nuget:?package=MSBuild.SonarQube.Runner.Tool&version=4.6.0" -#tool "nuget:?package=NUnit.Runners&version=2.6.4" +#tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0" #addin "nuget:?package=Cake.Sonar&version=1.1.18" @@ -16,6 +16,7 @@ if (host == riderHost) projectName = solutionName + ".Rider"; } +var testProjectName = projectName + ".Tests"; var solutionFile = string.Format("./src/{0}.sln", solutionName); var solutionFolder = string.Format("./src/{0}/", solutionName); var projectFile = string.Format("{0}{1}.csproj", solutionFolder, projectName); @@ -41,30 +42,37 @@ Task("UpdateBuildVersion") Task("Build") .Does(() => { - DotNetCoreBuild(projectFile, new DotNetCoreBuildSettings { - Configuration = buildConfiguration - }); + MSBuild(projectFile, s => + s.SetConfiguration(buildConfiguration) + .WithRestore()); }); Task("BuildSolution") .Does(() => { - DotNetCoreBuild(solutionFile, new DotNetCoreBuildSettings { - Configuration = buildConfiguration - }); + MSBuild(solutionFile, s => + s.SetConfiguration(buildConfiguration) + .WithRestore()); }); Task("Test") .IsDependentOn("Build") .Does(() => { - NUnit(string.Format("./test/src/bin/{0}/ReSharper.Structured.Logging.Tests.dll", buildConfiguration)); - NUnit(string.Format("./test/src/bin/{0}/ReSharper.Structured.Logging.Rider.Tests.dll", buildConfiguration)); + if (host == riderHost) + { + NUnit3(string.Format("./test/src/bin/{0}/{1}/ReSharper.Structured.Logging.Rider.Tests.dll", testProjectName, buildConfiguration)); + } + else + { + NUnit3(string.Format("./test/src/bin/{0}/{1}/ReSharper.Structured.Logging.Tests.dll", testProjectName, buildConfiguration)); + } }); Task("NugetPack") .IsDependentOn("AppendBuildNumber") .IsDependentOn("Build") + .IsDependentOn("Test") .Does(() => { var buildPath = string.Format("./src/{0}/bin/{1}", solutionName, buildConfiguration); @@ -154,11 +162,6 @@ Task("CreateArtifact") BuildSystem.AppVeyor.UploadArtifact(artifactFile); }); -Task("CI") - .IsDependentOn("Sonar") - .IsDependentOn("Test") - .IsDependentOn("CreateArtifact"); - Task("Default") .IsDependentOn("NugetPack"); diff --git a/src/ReSharper.Structured.Logging/Analyzer/ContextualLoggerSerilogFactoryAnalyzer.cs b/src/ReSharper.Structured.Logging/Analyzer/ContextualLoggerSerilogFactoryAnalyzer.cs index 3688345..5c85a6d 100644 --- a/src/ReSharper.Structured.Logging/Analyzer/ContextualLoggerSerilogFactoryAnalyzer.cs +++ b/src/ReSharper.Structured.Logging/Analyzer/ContextualLoggerSerilogFactoryAnalyzer.cs @@ -29,7 +29,7 @@ protected override void Run(IInvocationExpression element, ElementProblemAnalyze return; } - consumer.AddHighlighting(new DuplicateTemplatePropertyWarning(element.GetDocumentRange())); + consumer.AddHighlighting(new ContextualLoggerWarning(element.GetDocumentRange())); } } } diff --git a/src/ReSharper.Structured.Logging/ReSharper.Structured.Logging.Rider.csproj b/src/ReSharper.Structured.Logging/ReSharper.Structured.Logging.Rider.csproj index 6e3d855..6b21cc7 100644 --- a/src/ReSharper.Structured.Logging/ReSharper.Structured.Logging.Rider.csproj +++ b/src/ReSharper.Structured.Logging/ReSharper.Structured.Logging.Rider.csproj @@ -12,4 +12,7 @@ + + bin\$(MSBuildProjectName)\$(Configuration)\ + diff --git a/src/ReSharper.Structured.Logging/ReSharper.Structured.Logging.csproj b/src/ReSharper.Structured.Logging/ReSharper.Structured.Logging.csproj index 49b77c6..0bc525f 100644 --- a/src/ReSharper.Structured.Logging/ReSharper.Structured.Logging.csproj +++ b/src/ReSharper.Structured.Logging/ReSharper.Structured.Logging.csproj @@ -7,4 +7,7 @@ + + bin\$(MSBuildProjectName)\$(Configuration)\ + diff --git a/test/data/Analyzers/ContextualLoggerSerilogFactory/SerilogWrongContextType.cs.gold b/test/data/Analyzers/ContextualLoggerSerilogFactory/SerilogWrongContextType.cs.gold index 1988bf4..f1cbdbd 100644 --- a/test/data/Analyzers/ContextualLoggerSerilogFactory/SerilogWrongContextType.cs.gold +++ b/test/data/Analyzers/ContextualLoggerSerilogFactory/SerilogWrongContextType.cs.gold @@ -8,4 +8,4 @@ class A class B {} --------------------------------------------------------- -(0): ReSharper Warning: Duplicate properties in message template +(0): ReSharper Warning: Incorrect type is used for contextual logger diff --git a/test/src/ReSharper.Structured.Logging.Rider.Tests.csproj b/test/src/ReSharper.Structured.Logging.Rider.Tests.csproj index 9274a23..9aef324 100644 --- a/test/src/ReSharper.Structured.Logging.Rider.Tests.csproj +++ b/test/src/ReSharper.Structured.Logging.Rider.Tests.csproj @@ -14,7 +14,8 @@ true ReSharper.Structured.Logging.Tests - + RIDER + bin\$(MSBuildProjectName)\$(Configuration)\ diff --git a/test/src/ReSharper.Structured.Logging.Tests.csproj b/test/src/ReSharper.Structured.Logging.Tests.csproj index e4af471..80611e5 100644 --- a/test/src/ReSharper.Structured.Logging.Tests.csproj +++ b/test/src/ReSharper.Structured.Logging.Tests.csproj @@ -9,4 +9,7 @@ + + bin\$(MSBuildProjectName)\$(Configuration)\ +