Skip to content

Commit

Permalink
Merge pull request #12 from asulwer/Code-Coverage
Browse files Browse the repository at this point in the history
adding back code-coverage
  • Loading branch information
asulwer authored Jun 28, 2024
2 parents bbab93e + d33a7f3 commit 0c72cff
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 10 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/dotnetcore-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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/[email protected]
if: ${{ github.event_name == 'push' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coveragereport/lcov.info
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ publish/
*.ldf
*.ndf

coveragereport/
nuget-packages/
nuget-push.ps1
/src/RulesEngine/build-signed.ps1
/src/RulesEngine/sgKey.snk
/tests/**/TestResults/
5 changes: 2 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions scripts/check-coverage.ps1
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 2 additions & 0 deletions scripts/generate-coverage-report.ps1
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 0 additions & 2 deletions src/RulesEngine/Exceptions/ExpressionParserException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text;

namespace RulesEngine.Exceptions
{
Expand Down
4 changes: 2 additions & 2 deletions src/RulesEngine/Exceptions/RuleException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/RulesEngine/Exceptions/ScopedParamException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tests/RulesEngine.UnitTest/RulesEngine.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
Expand Down

0 comments on commit 0c72cff

Please sign in to comment.