* Updated dependecies (#394)
* * Updated dependecies * fixed build error * removed obsolete code * fixed coverage threshold * updated changelog * removed key hashing as it can lead to conflicts * updated container imagepull/398/head
parent
a74f73a44e
commit
d0133155d6
|
@ -3,7 +3,7 @@
|
|||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-reportgenerator-globaltool": {
|
||||
"version": "4.7.1",
|
||||
"version": "5.1.10",
|
||||
"commands": [
|
||||
"reportgenerator"
|
||||
]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "RulesEngine Codespace",
|
||||
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:0.201.7-3.1",
|
||||
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:0-6.0",
|
||||
"settings": {
|
||||
"terminal.integrated.defaultProfile.linux": "pwsh"
|
||||
"terminal.integrated.defaultProfile.linux": "bash"
|
||||
},
|
||||
"extensions": [
|
||||
"eamodio.gitlens",
|
||||
|
@ -12,12 +12,15 @@
|
|||
"cschleiden.vscode-github-actions",
|
||||
"redhat.vscode-yaml",
|
||||
"bierner.markdown-preview-github-styles",
|
||||
"ban.spellright",
|
||||
"jmrog.vscode-nuget-package-manager",
|
||||
"coenraads.bracket-pair-colorizer",
|
||||
"vscode-icons-team.vscode-icons",
|
||||
"editorconfig.editorconfig"
|
||||
"editorconfig.editorconfig",
|
||||
"aliasadidev.nugetpackagemanagergui",
|
||||
"formulahendry.dotnet-test-explorer"
|
||||
],
|
||||
"postCreateCommand": "dotnet restore RulesEngine.sln && dotnet build RulesEngine.sln --configuration Release --no-restore && dotnet test RulesEngine.sln --configuration Release --no-build --verbosity minimal",
|
||||
"features": {
|
||||
"powershell": "7.1"
|
||||
},
|
||||
}
|
||||
// Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)
|
||||
|
|
|
@ -8,35 +8,13 @@ on:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# extract branch name
|
||||
- name: Extract branch name
|
||||
if: github.event_name != 'pull_request'
|
||||
shell: bash
|
||||
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
|
||||
id: extract_branch
|
||||
|
||||
# extract branch name on pull request
|
||||
- name: Extract branch name on pull request
|
||||
if: github.event_name == 'pull_request'
|
||||
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV
|
||||
|
||||
# print branch name
|
||||
- name: Get branch name
|
||||
run: echo "The branch name is ${{ env.BRANCH_NAME }}"
|
||||
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v2
|
||||
with:
|
||||
dotnet-version: 6.0.x
|
||||
|
||||
- name: Install minicover
|
||||
run: dotnet tool install --global minicover --version 3.4.4
|
||||
|
||||
- name: Install dependencies
|
||||
run: dotnet restore RulesEngine.sln
|
||||
|
@ -44,19 +22,20 @@ jobs:
|
|||
- name: Build
|
||||
run: dotnet build RulesEngine.sln --configuration Release --no-restore
|
||||
|
||||
- name: Instrument
|
||||
run: minicover instrument
|
||||
|
||||
- name: Test
|
||||
run: dotnet test RulesEngine.sln --no-build --configuration Release --verbosity m
|
||||
run: dotnet test RulesEngine.sln --collect:"XPlat Code Coverage" --no-build --configuration Release --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: Uninstrument
|
||||
run: minicover uninstrument
|
||||
|
||||
- name: Report
|
||||
run: minicover report --threshold 95
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
- name: Report coveralls
|
||||
run: minicover coverallsreport --repo-token ${{ secrets.COVERALLS_TOKEN }} --branch ${{ env.BRANCH_NAME }}
|
||||
- name: Coveralls GitHub Action
|
||||
uses: coverallsapp/github-action@1.1.3
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
with:
|
||||
github-token: ${{ secrets.COVERALLS_TOKEN }}
|
||||
path-to-lcov: ./coveragereport/lcov.info
|
||||
|
|
30
CHANGELOG.md
30
CHANGELOG.md
|
@ -2,6 +2,36 @@
|
|||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [4.0.0]
|
||||
- RulesEngine is now available in both dotnet 6 and netstandard 2.0
|
||||
- Dependency on ILogger, MemoryCache have been removed
|
||||
- Obsolete Properties and Methods have been removed
|
||||
### Breaking Changes
|
||||
- ILogger has been removed from RulesEngine and all its constructors
|
||||
```diff
|
||||
- RulesEngine(string[] jsonConfig, ILogger logger = null, ReSettings reSettings = null)
|
||||
+ RulesEngine(string[] jsonConfig, ReSettings reSettings = null)
|
||||
|
||||
- RulesEngine(Workflow[] Workflows, ILogger logger = null, ReSettings reSettings = null)
|
||||
+ RulesEngine(Workflow[] Workflows, ReSettings reSettings = null)
|
||||
|
||||
- RulesEngine(ILogger logger = null, ReSettings reSettings = null)
|
||||
+ RulesEngine(ReSettings reSettings = null)
|
||||
```
|
||||
- Obsolete methods and properties have been removed, from the follow models:-
|
||||
- RuleResultTree
|
||||
- `ToResultTreeMessages()` has been removed from `RuleResultTree` model
|
||||
- `GetMessages()` has been removed from `RuleResultTree` model
|
||||
- `RuleEvaluatedParams` has been removed from `RuleResultTree` model, Please use `Inputs` instead
|
||||
|
||||
- Workflow
|
||||
- `WorkflowRulesToInject` has been removed, Please use `WorkflowsToInject` instead
|
||||
- `ErrorType` has been removed from `Rule`
|
||||
|
||||
- Resettings
|
||||
- `EnableLocalParams` has been removed from `ReSettings`, Please use `EnableScopedParams` instead
|
||||
|
||||
|
||||
## [3.5.0]
|
||||
- `EvaluateRule` action now support custom inputs and filtered inputs
|
||||
- Added `ContainsWorkflow` method in RulesEngine (by @okolobaxa)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
|
||||
<!--<PackageReference Include="RulesEngine" Version="3.0.2" />-->
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
@ -7,8 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace RulesEngine.Data
|
|||
v => JsonSerializer.Deserialize<RuleActions>(v, serializationOptions));
|
||||
|
||||
entity.Ignore(b => b.WorkflowsToInject);
|
||||
entity.Ignore(b => b.WorkflowRulesToInject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "6.0",
|
||||
"version": "6.0.0",
|
||||
"rollForward": "latestFeature",
|
||||
"allowPrerelease": false
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
dotnet tool restore
|
||||
dotnet reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura"
|
|
@ -74,50 +74,5 @@ namespace RulesEngine.HelperFunctions
|
|||
{
|
||||
return reSettings.IgnoreException ? "" : message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To the result tree error messages
|
||||
/// </summary>
|
||||
/// <param name="ruleResultTree">ruleResultTree</param>
|
||||
/// <param name="ruleResultMessage">ruleResultMessage</param>
|
||||
[Obsolete]
|
||||
internal static void ToResultTreeMessages(RuleResultTree ruleResultTree, ref RuleResultMessage ruleResultMessage)
|
||||
{
|
||||
if (ruleResultTree.ChildResults != null)
|
||||
{
|
||||
GetChildRuleMessages(ruleResultTree.ChildResults, ref ruleResultMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ruleResultTree.IsSuccess)
|
||||
{
|
||||
string errMsg = ruleResultTree.Rule.ErrorMessage;
|
||||
errMsg = string.IsNullOrEmpty(errMsg) ? $"Error message is not configured for {ruleResultTree.Rule.RuleName}" : errMsg;
|
||||
|
||||
if (ruleResultTree.Rule.ErrorType == ErrorType.Error && !ruleResultMessage.ErrorMessages.Contains(errMsg))
|
||||
{
|
||||
ruleResultMessage.ErrorMessages.Add(errMsg);
|
||||
}
|
||||
else if (ruleResultTree.Rule.ErrorType == ErrorType.Warning && !ruleResultMessage.WarningMessages.Contains(errMsg))
|
||||
{
|
||||
ruleResultMessage.WarningMessages.Add(errMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To get the child error message recursively
|
||||
/// </summary>
|
||||
/// <param name="childResultTree">childResultTree</param>
|
||||
/// <param name="ruleResultMessage">ruleResultMessage</param>
|
||||
[Obsolete]
|
||||
private static void GetChildRuleMessages(IEnumerable<RuleResultTree> childResultTree, ref RuleResultMessage ruleResultMessage)
|
||||
{
|
||||
foreach (var item in childResultTree)
|
||||
{
|
||||
ToResultTreeMessages(item, ref ruleResultMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,16 +49,6 @@ namespace RulesEngine.Models
|
|||
/// Sets the mode for Nested rule execution, Default: All
|
||||
/// </summary>
|
||||
public NestedRuleExecutionMode NestedRuleExecutionMode { get; set; } = NestedRuleExecutionMode.All;
|
||||
|
||||
/// <summary>
|
||||
/// Enables Local params for rules
|
||||
/// </summary>
|
||||
[Obsolete("Use 'EnableScopedParams' instead. This will be removed in next major version")]
|
||||
public bool EnableLocalParams {
|
||||
get { return EnableScopedParams; }
|
||||
set { EnableScopedParams = value; }
|
||||
}
|
||||
|
||||
public MemCacheConfig CacheConfig { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
|
@ -34,20 +33,9 @@ namespace RulesEngine.Models
|
|||
/// </summary>
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
[Obsolete("will be removed in next major version")]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ErrorType ErrorType { get; set; } = ErrorType.Warning;
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public RuleExpressionType RuleExpressionType { get; set; } = RuleExpressionType.LambdaExpression;
|
||||
|
||||
[Obsolete("WorkflowRulesToInject is deprecated. Use WorkflowsToInject instead.")]
|
||||
public IEnumerable<string> WorkflowRulesToInject {
|
||||
get { return WorkflowsToInject; }
|
||||
set { WorkflowsToInject = value; }
|
||||
}
|
||||
public IEnumerable<string> WorkflowsToInject { get; set; }
|
||||
|
||||
public IEnumerable<Rule> Rules { get; set; }
|
||||
public IEnumerable<ScopedParam> LocalParams { get; set; }
|
||||
public string Expression { get; set; }
|
||||
|
|
|
@ -50,29 +50,6 @@ namespace RulesEngine.Models
|
|||
/// </summary>
|
||||
public string ExceptionMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the rule evaluated parameters.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The rule evaluated parameters.
|
||||
/// </value>
|
||||
[Obsolete("Use `Inputs` field to get details of all input, localParams and globalParams")]
|
||||
public IEnumerable<RuleParameter> RuleEvaluatedParams { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This method will return all the error and warning messages to caller
|
||||
/// </summary>
|
||||
/// <returns>RuleResultMessage</returns>
|
||||
[ExcludeFromCodeCoverage]
|
||||
[Obsolete("will be removed in next major version")]
|
||||
public RuleResultMessage GetMessages()
|
||||
{
|
||||
var ruleResultMessage = new RuleResultMessage();
|
||||
|
||||
Helpers.ToResultTreeMessages(this, ref ruleResultMessage);
|
||||
|
||||
return ruleResultMessage;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -252,14 +252,6 @@ namespace RulesEngine
|
|||
|
||||
var extendedInputs = ruleParams.Concat(scopedParams);
|
||||
var result = ruleFunc(extendedInputs.ToArray());
|
||||
// To be removed in next major release
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if(result.RuleEvaluatedParams == null)
|
||||
{
|
||||
result.RuleEvaluatedParams = scopedParams;
|
||||
}
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -345,8 +345,8 @@ namespace RulesEngine
|
|||
|
||||
private string GetCompiledRulesKey(string workflowName, RuleParameter[] ruleParams)
|
||||
{
|
||||
var ruleParamsHash = string.Join("-", ruleParams.Select(c => $"{c.Name}_{c.Type.Name}")).GetHashCode();
|
||||
var key = $"{workflowName}-" + ruleParamsHash;
|
||||
var ruleParamsKey = string.Join("-", ruleParams.Select(c => $"{c.Name}_{c.Type.Name}"));
|
||||
var key = $"{workflowName}-" + ruleParamsKey;
|
||||
return key;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Version>4.0.0-preview.1</Version>
|
||||
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
|
||||
<Version>4.0.0</Version>
|
||||
<Copyright>Copyright (c) Microsoft Corporation.</Copyright>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageProjectUrl>https://github.com/microsoft/RulesEngine</PackageProjectUrl>
|
||||
|
@ -31,8 +31,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FastExpressionCompiler" Version="3.2.2" />
|
||||
<PackageReference Include="FluentValidation" Version="11.0.1" />
|
||||
<PackageReference Include="FastExpressionCompiler" Version="3.3.3" />
|
||||
<PackageReference Include="FluentValidation" Version="11.2.2" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="System.Linq" Version="4.3.0" />
|
||||
|
|
|
@ -238,22 +238,6 @@ namespace RulesEngine.UnitTest
|
|||
Assert.False(string.IsNullOrEmpty(result[0].ExceptionMessage) || string.IsNullOrWhiteSpace(result[0].ExceptionMessage));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("rules2.json")]
|
||||
[Obsolete]
|
||||
public async Task ExecuteRule_ReturnsListOfRuleResultTree_ResultMessage(string ruleFileName)
|
||||
{
|
||||
var re = GetRulesEngine(ruleFileName);
|
||||
|
||||
dynamic input1 = GetInput1();
|
||||
dynamic input2 = GetInput2();
|
||||
dynamic input3 = GetInput3();
|
||||
|
||||
List<RuleResultTree> result = await re.ExecuteAllRulesAsync("inputWorkflow", input1, input2, input3);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.First().GetMessages());
|
||||
Assert.NotNull(result.First().GetMessages().WarningMessages);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RulesEngine_New_IncorrectJSON_ThrowsException()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<SignAssembly>True</SignAssembly>
|
||||
|
@ -7,10 +7,10 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoFixture" Version="4.17.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="Moq" Version="4.17.2" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.4" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
||||
<PackageReference Include="Moq" Version="4.18.2" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.6" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
|
@ -162,10 +162,6 @@ namespace RulesEngine.UnitTest
|
|||
var localParamNames = resultTree.Rule.LocalParams?.Select(c => c.Name) ?? new List<string>();
|
||||
Assert.All(localParamNames, input => Assert.True(resultTree.Inputs.ContainsKey(input)));
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
Assert.All(localParamNames, lp => Assert.Contains(resultTree.RuleEvaluatedParams, c => c.Name == lp));
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
if (resultTree.ChildResults?.Any() == true)
|
||||
{
|
||||
foreach (var childResultTree in resultTree.ChildResults)
|
||||
|
|
Loading…
Reference in New Issue