diff --git a/.github/workflows/dotnetcore-build.yml b/.github/workflows/dotnetcore-build.yml index a66a7b0d..f8c3c93f 100644 --- a/.github/workflows/dotnetcore-build.yml +++ b/.github/workflows/dotnetcore-build.yml @@ -23,4 +23,21 @@ jobs: run: dotnet build RulesEngine.sln --configuration Debug --no-restore - name: Test - run: dotnet test RulesEngine.sln --collect:"XPlat Code Coverage" --no-build --configuration Debug --verbosity m \ No newline at end of file + run: dotnet test RulesEngine.sln --collect:"XPlat Code Coverage" --no-build --configuration Debug --verbosity m + + - name: Install Report Tool + run: dotnet tool install --tool-path tools dotnet-reportgenerator-globaltool + + - name: Generate Report + run: ./tools/reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" + + - name: Check Coverage + shell: pwsh + run: ./scripts/check-coverage.ps1 -reportPath coveragereport/Cobertura.xml -threshold 96 + + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2.2.1 + if: ${{ github.event_name == 'push' }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ./coveragereport/lcov.info diff --git a/.gitignore b/.gitignore index b0f8b54f..80d0fe28 100644 --- a/.gitignore +++ b/.gitignore @@ -91,7 +91,9 @@ publish/ *.ldf *.ndf +coveragereport/ nuget-packages/ nuget-push.ps1 /src/RulesEngine/build-signed.ps1 /src/RulesEngine/sgKey.snk +/tests/**/TestResults/ \ No newline at end of file diff --git a/ROADMAP.md b/ROADMAP.md index 035e4789..af600606 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,8 +1,7 @@ ### Roadmap for RulesEngineEx, formerlly known as [RulesEngine}(https://github.com/microsoft/RulesEngine). -- WorkflowName and RuleName will be changed to Name +- WorkflowName and RuleName properties changed to Name - seems redundant to say Workflow.WorkflowName or Rule.RuleName - [X]Add CancellationToken Token for Async [[/microsoft/RulesEngine/issues/609](https://github.com/microsoft/RulesEngine/issues/609)] - [X]Refactor Code and add comments for readability -- [X]Fix Issues from the original project -- Go From Moq to NSubstitute +- [X]Fix oustanding Issues from the original project \ No newline at end of file diff --git a/scripts/check-coverage.ps1 b/scripts/check-coverage.ps1 new file mode 100644 index 00000000..4f1fe368 --- /dev/null +++ b/scripts/check-coverage.ps1 @@ -0,0 +1,16 @@ +param( + [Parameter(Mandatory=$true)][string] $reportPath, + [Parameter(Mandatory=$true)][decimal] $threshold +) + + +[XML]$report = Get-Content $reportPath; +[decimal]$coverage = [decimal]$report.coverage.'line-rate' * 100; + +if ($coverage -lt $threshold) { + Write-Error "Coverage ($coverage) < $threshold percent" + exit 1 +} +else{ + Write-Host "Coverage ($coverage) > $threshold percent" +} \ No newline at end of file diff --git a/scripts/generate-coverage-report.ps1 b/scripts/generate-coverage-report.ps1 new file mode 100644 index 00000000..5ea54407 --- /dev/null +++ b/scripts/generate-coverage-report.ps1 @@ -0,0 +1,2 @@ +dotnet tool install --tool-path tools dotnet-reportgenerator-globaltool +./tools/reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" \ No newline at end of file diff --git a/src/RulesEngine/Exceptions/ExpressionParserException.cs b/src/RulesEngine/Exceptions/ExpressionParserException.cs index e9fb8f76..35ce73a5 100644 --- a/src/RulesEngine/Exceptions/ExpressionParserException.cs +++ b/src/RulesEngine/Exceptions/ExpressionParserException.cs @@ -2,8 +2,6 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; -using System.Text; namespace RulesEngine.Exceptions { diff --git a/src/RulesEngine/Exceptions/RuleException.cs b/src/RulesEngine/Exceptions/RuleException.cs index 68484978..15155ba5 100644 --- a/src/RulesEngine/Exceptions/RuleException.cs +++ b/src/RulesEngine/Exceptions/RuleException.cs @@ -2,11 +2,11 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; -using System.Text; +using System.Diagnostics.CodeAnalysis; namespace RulesEngine.Exceptions { + [ExcludeFromCodeCoverage] public class RuleException : Exception { public RuleException(string message) : base(message) diff --git a/src/RulesEngine/Exceptions/ScopedParamException.cs b/src/RulesEngine/Exceptions/ScopedParamException.cs index c38bf4ca..ca636dd3 100644 --- a/src/RulesEngine/Exceptions/ScopedParamException.cs +++ b/src/RulesEngine/Exceptions/ScopedParamException.cs @@ -2,11 +2,11 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; -using System.Text; +using System.Diagnostics.CodeAnalysis; namespace RulesEngine.Exceptions { + [ExcludeFromCodeCoverage] public class ScopedParamException: Exception { public ScopedParamException(string message, Exception innerException, string scopedParamName): base(message,innerException) diff --git a/tests/RulesEngine.UnitTest/RulesEngine.UnitTest.csproj b/tests/RulesEngine.UnitTest/RulesEngine.UnitTest.csproj index 3051411d..7e1baff8 100644 --- a/tests/RulesEngine.UnitTest/RulesEngine.UnitTest.csproj +++ b/tests/RulesEngine.UnitTest/RulesEngine.UnitTest.csproj @@ -7,6 +7,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +