From 8f6497711b28e8579670c71490473b0cae982fc0 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 10:08:12 -0700 Subject: [PATCH 1/9] adding back code-coverage --- .github/workflows/dotnetcore-build.yml | 17 ++++++++++++++++- .gitignore | 1 + scripts/check-coverage.ps1 | 16 ++++++++++++++++ scripts/generate-coverage-report.ps1 | 2 ++ .../RulesEngine.UnitTest.csproj | 4 ++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 scripts/check-coverage.ps1 create mode 100644 scripts/generate-coverage-report.ps1 diff --git a/.github/workflows/dotnetcore-build.yml b/.github/workflows/dotnetcore-build.yml index a66a7b0d..21189727 100644 --- a/.github/workflows/dotnetcore-build.yml +++ b/.github/workflows/dotnetcore-build.yml @@ -23,4 +23,19 @@ 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: Generate Report + shell: pwsh + run: ./scripts/generate-coverage-report.ps1 + + - 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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index b0f8b54f..bbc60818 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,4 @@ 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/scripts/check-coverage.ps1 b/scripts/check-coverage.ps1 new file mode 100644 index 00000000..06f74ee1 --- /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) is less than $threshold percent" + exit 1 +} +else{ + Write-Host "Coverage($coverage) is more than $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..8a14cad3 --- /dev/null +++ b/scripts/generate-coverage-report.ps1 @@ -0,0 +1,2 @@ +dotnet tool restore +dotnet reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" \ No newline at end of file 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 + From 2e2b2a6eaf7168299d0b2dc8493de1109fe24080 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 10:19:04 -0700 Subject: [PATCH 2/9] Update dotnetcore-build.yml --- .github/workflows/dotnetcore-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnetcore-build.yml b/.github/workflows/dotnetcore-build.yml index 21189727..30203cbc 100644 --- a/.github/workflows/dotnetcore-build.yml +++ b/.github/workflows/dotnetcore-build.yml @@ -27,15 +27,15 @@ jobs: - name: Generate Report shell: pwsh - run: ./scripts/generate-coverage-report.ps1 + run: ../scripts/generate-coverage-report.ps1 - name: Check Coverage shell: pwsh - run: ./scripts/check-coverage.ps1 -reportPath coveragereport/Cobertura.xml -threshold 96 + 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 \ No newline at end of file + path-to-lcov: ./coveragereport/lcov.info From f154bec082f921af68d170883670bf3292b33350 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 10:45:17 -0700 Subject: [PATCH 3/9] workflow commands were not successfully running --- .github/workflows/dotnetcore-build.yml | 4 ++-- .gitignore | 1 + scripts/check-coverage.ps1 | 4 ++-- scripts/generate-coverage-report.ps1 | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dotnetcore-build.yml b/.github/workflows/dotnetcore-build.yml index 30203cbc..fce15b3c 100644 --- a/.github/workflows/dotnetcore-build.yml +++ b/.github/workflows/dotnetcore-build.yml @@ -27,11 +27,11 @@ jobs: - name: Generate Report shell: pwsh - run: ../scripts/generate-coverage-report.ps1 + run: ./scripts/generate-coverage-report.ps1 - name: Check Coverage shell: pwsh - run: ../scripts/check-coverage.ps1 -reportPath coveragereport/Cobertura.xml -threshold 96 + run: ./scripts/check-coverage.ps1 -reportPath coveragereport/Cobertura.xml -threshold 96 - name: Coveralls GitHub Action uses: coverallsapp/github-action@v2.2.1 diff --git a/.gitignore b/.gitignore index bbc60818..80d0fe28 100644 --- a/.gitignore +++ b/.gitignore @@ -91,6 +91,7 @@ publish/ *.ldf *.ndf +coveragereport/ nuget-packages/ nuget-push.ps1 /src/RulesEngine/build-signed.ps1 diff --git a/scripts/check-coverage.ps1 b/scripts/check-coverage.ps1 index 06f74ee1..4f1fe368 100644 --- a/scripts/check-coverage.ps1 +++ b/scripts/check-coverage.ps1 @@ -8,9 +8,9 @@ param( [decimal]$coverage = [decimal]$report.coverage.'line-rate' * 100; if ($coverage -lt $threshold) { - Write-Error "Coverage($coverage) is less than $threshold percent" + Write-Error "Coverage ($coverage) < $threshold percent" exit 1 } else{ - Write-Host "Coverage($coverage) is more than $threshold percent" + 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 index 8a14cad3..5014b48a 100644 --- a/scripts/generate-coverage-report.ps1 +++ b/scripts/generate-coverage-report.ps1 @@ -1,2 +1,2 @@ dotnet tool restore -dotnet reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" \ No newline at end of file +reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" \ No newline at end of file From cd6beeac4029604352d29a946c0d33529d487837 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 10:58:47 -0700 Subject: [PATCH 4/9] exclude from code coverage --- src/RulesEngine/Exceptions/ExpressionParserException.cs | 2 -- src/RulesEngine/Exceptions/RuleException.cs | 4 ++-- src/RulesEngine/Exceptions/ScopedParamException.cs | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) 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) From 53f2310ef3e55d4f6a0f5862944c108466826a58 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 11:10:59 -0700 Subject: [PATCH 5/9] verbage --- ROADMAP.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 From bea5ab1fb4f1cd95953969db449c88018f0bdbc9 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 11:17:40 -0700 Subject: [PATCH 6/9] missing dotnet command --- scripts/generate-coverage-report.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-coverage-report.ps1 b/scripts/generate-coverage-report.ps1 index 5014b48a..8a14cad3 100644 --- a/scripts/generate-coverage-report.ps1 +++ b/scripts/generate-coverage-report.ps1 @@ -1,2 +1,2 @@ dotnet tool restore -reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" \ No newline at end of file +dotnet reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" \ No newline at end of file From 9e75be8ff58558a10c70a6e3865e0130db292c85 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 11:51:12 -0700 Subject: [PATCH 7/9] missing for reportsgenerator --- config/dotnet-tools.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 config/dotnet-tools.json diff --git a/config/dotnet-tools.json b/config/dotnet-tools.json new file mode 100644 index 00000000..f2d1bd98 --- /dev/null +++ b/config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-reportgenerator-globaltool": { + "version": "5.1.23", + "commands": [ + "reportgenerator" + ] + } + } +} \ No newline at end of file From 9b707104a668235b6f95b568ced163b3af4320f7 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 11:56:27 -0700 Subject: [PATCH 8/9] install tools instead of using config directory --- scripts/generate-coverage-report.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/generate-coverage-report.ps1 b/scripts/generate-coverage-report.ps1 index 8a14cad3..5ea54407 100644 --- a/scripts/generate-coverage-report.ps1 +++ b/scripts/generate-coverage-report.ps1 @@ -1,2 +1,2 @@ -dotnet tool restore -dotnet reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" \ No newline at end of file +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 From d33a7f398d72b7f28520d1b9290be23a68ca7e0a Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Fri, 28 Jun 2024 12:08:30 -0700 Subject: [PATCH 9/9] placed all commands in workflow where possible --- .github/workflows/dotnetcore-build.yml | 8 +++++--- config/dotnet-tools.json | 12 ------------ 2 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 config/dotnet-tools.json diff --git a/.github/workflows/dotnetcore-build.yml b/.github/workflows/dotnetcore-build.yml index fce15b3c..f8c3c93f 100644 --- a/.github/workflows/dotnetcore-build.yml +++ b/.github/workflows/dotnetcore-build.yml @@ -23,11 +23,13 @@ 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 - shell: pwsh - run: ./scripts/generate-coverage-report.ps1 + run: ./tools/reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura" - name: Check Coverage shell: pwsh diff --git a/config/dotnet-tools.json b/config/dotnet-tools.json deleted file mode 100644 index f2d1bd98..00000000 --- a/config/dotnet-tools.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "dotnet-reportgenerator-globaltool": { - "version": "5.1.23", - "commands": [ - "reportgenerator" - ] - } - } -} \ No newline at end of file