Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Squidex/libs into flows
Browse files Browse the repository at this point in the history
# Conflicts:
#	Squidex.Libs.sln
  • Loading branch information
SebastianStehle committed Dec 11, 2024
2 parents 07389c7 + c1361e8 commit 78e198d
Show file tree
Hide file tree
Showing 24 changed files with 152 additions and 89 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/check-updates.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: Check Update
concurrency: check

on:
workflow_dispatch:
schedule:
# Automatically run on every Sunday
- cron: '0 0 * * 0'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4.1.6
with:
token: ${{ secrets.WORKFLOW_SECRET }}

- name: Check for Update
uses: saadmk11/github-actions-version-updater@v0.8.1
with:
token: ${{ secrets.WORKFLOW_SECRET }}
name: Check Update
concurrency: check

on:
workflow_dispatch:
schedule:
# Automatically run on every Sunday
- cron: '0 0 * * 0'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4.2.2
with:
token: ${{ secrets.WORKFLOW_SECRET }}

- name: Check for Update
uses: saadmk11/github-actions-version-updater@v0.8.1
with:
token: ${{ secrets.WORKFLOW_SECRET }}
54 changes: 27 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: Nuget Build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4.1.6

- name: setup dotnet
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 8.0.x

- name: test
run: |
dotnet test --filter Category!=Dependencies
- name: pack
run: |
dotnet pack -c Release
- name: publish
run: |
dotnet nuget push **/*.nupkg --source 'https://api.nuget.org/v3/index.json' --skip-duplicate -k ${{ secrets.nuget }}
name: Nuget Build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4.2.2

- name: setup dotnet
uses: actions/setup-dotnet@v4.1.0
with:
dotnet-version: 8.0.x

- name: test
run: |
dotnet test --filter Category!=Dependencies
- name: pack
run: |
dotnet pack -c Release
- name: publish
run: |
dotnet nuget push **/*.nupkg --source 'https://api.nuget.org/v3/index.json' --skip-duplicate -k ${{ secrets.nuget }}
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageProjectUrl>https://github.com/squidex/squidex</PackageProjectUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>6.22.0</Version>
<Version>6.24.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
Expand Down
6 changes: 6 additions & 0 deletions Squidex.Libs.sln
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Flows.Tests", "flows\Squidex.Flows.Tests\Squidex.Flows.Tests.csproj", "{CC9096C3-1FAD-42CD-AA50-622BE68BC78D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Flows.Mongo", "flows\Squidex.Flows.Mongo\Squidex.Flows.Mongo.csproj", "{559B7D03-755C-4233-A055-670ABF8D4D58}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.AI.Mongo", "ai\Squidex.AI.Mongo\Squidex.AI.Mongo.csproj", "{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -253,6 +254,10 @@ Global
{559B7D03-755C-4233-A055-670ABF8D4D58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{559B7D03-755C-4233-A055-670ABF8D4D58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{559B7D03-755C-4233-A055-670ABF8D4D58}.Release|Any CPU.Build.0 = Release|Any CPU
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -296,6 +301,7 @@ Global
{A11B0218-3FCB-46F4-B3B6-B56A36BA02BC} = {67DB170D-E43B-431F-AE3A-2730FC631D12}
{CC9096C3-1FAD-42CD-AA50-622BE68BC78D} = {67DB170D-E43B-431F-AE3A-2730FC631D12}
{559B7D03-755C-4233-A055-670ABF8D4D58} = {67DB170D-E43B-431F-AE3A-2730FC631D12}
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3} = {F18E275B-4805-4DCB-BE31-ACC314FB508E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {060512DD-34DA-4929-A67F-2E473577FBF5}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================

namespace Squidex.AI.Implementation.Mongo;
namespace Squidex.AI.Mongo;

public sealed class MongoChatEntity
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using Microsoft.Extensions.Configuration;
using Squidex.AI.Implementation;
using Squidex.AI.Implementation.Mongo;
using Squidex.AI.Mongo;

namespace Microsoft.Extensions.DependencyInjection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
using System.Text.Json;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using Squidex.AI.Implementation;
using Squidex.Hosting;

namespace Squidex.AI.Implementation.Mongo;
namespace Squidex.AI.Mongo;

public sealed class MongoChatStore(IMongoDatabase database, IOptions<MongoChatStoreOptions> options) : IChatStore, IInitializable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using Squidex.Hosting.Configuration;

namespace Squidex.AI.Implementation.Mongo;
namespace Squidex.AI.Mongo;

public sealed class MongoChatStoreOptions : IValidatableOptions
{
Expand Down
36 changes: 36 additions & 0 deletions ai/Squidex.AI.Mongo/Squidex.AI.Mongo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<None Include="logo-squared.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.179">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MongoDB.Driver" Version="2.30.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Squidex.AI\Squidex.AI.csproj" />
</ItemGroup>

</Project>
Binary file added ai/Squidex.AI.Mongo/logo-squared.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ai/Squidex.AI.Tests/Squidex.AI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

<ItemGroup>
<ProjectReference Include="..\..\assets\Squidex.Assets.ImageSharp\Squidex.Assets.ImageSharp.csproj" />
<ProjectReference Include="..\Squidex.AI.Mongo\Squidex.AI.Mongo.csproj" />
<ProjectReference Include="..\Squidex.AI\Squidex.AI.csproj" />
</ItemGroup>

Expand Down
2 changes: 0 additions & 2 deletions ai/Squidex.AI/Squidex.AI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.11" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MongoDB.Driver" Version="2.30.0" />
<PackageReference Include="Pinecone.NET" Version="3.0.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
Expand Down
12 changes: 6 additions & 6 deletions flows/Squidex.Flows.Mongo/MongoFlowStateStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Task EnqueueAsync(Guid instanceId, Instant nextAttempt,
cancellationToken: ct);
}

public async Task<ExecutionState<TContext>?> FindAsync(Guid id,
public async Task<FlowExecutionState<TContext>?> FindAsync(Guid id,
CancellationToken ct = default)
{
var entity = await collection.Find(x => x.Id == id).FirstOrDefaultAsync(ct);
Expand All @@ -63,7 +63,7 @@ public Task EnqueueAsync(Guid instanceId, Instant nextAttempt,
return ParseState(entity);
}

public async Task<(List<ExecutionState<TContext>> Items, long Total)> QueryByOwnerAsync(string ownerId, string? definitionId = null, int skip = 0, int take = 20,
public async Task<(List<FlowExecutionState<TContext>> Items, long Total)> QueryByOwnerAsync(string ownerId, string? definitionId = null, int skip = 0, int take = 20,
CancellationToken ct = default)
{
var filters = new List<FilterDefinition<MongoFlowStateEntity>>
Expand All @@ -86,7 +86,7 @@ public Task EnqueueAsync(Guid instanceId, Instant nextAttempt,
return (items, entitiesTotal);
}

public async IAsyncEnumerable<ExecutionState<TContext>> QueryPendingAsync(Instant now,
public async IAsyncEnumerable<FlowExecutionState<TContext>> QueryPendingAsync(Instant now,
[EnumeratorCancellation] CancellationToken ct = default)
{
var entitiesLimit = now.ToDateTimeOffset();
Expand All @@ -101,7 +101,7 @@ public async IAsyncEnumerable<ExecutionState<TContext>> QueryPendingAsync(Instan
}
}

public async Task StoreAsync(List<ExecutionState<TContext>> states,
public async Task StoreAsync(List<FlowExecutionState<TContext>> states,
CancellationToken ct)
{
if (states.Count == 0)
Expand Down Expand Up @@ -131,8 +131,8 @@ public async Task StoreAsync(List<ExecutionState<TContext>> states,
await collection.BulkWriteAsync(batch, cancellationToken: ct);
}

private ExecutionState<TContext> ParseState(MongoFlowStateEntity entity)
private FlowExecutionState<TContext> ParseState(MongoFlowStateEntity entity)
{
return JsonSerializer.Deserialize<ExecutionState<TContext>>(entity.State, jsonSerializerOptions)!;
return JsonSerializer.Deserialize<FlowExecutionState<TContext>>(entity.State, jsonSerializerOptions)!;
}
}
12 changes: 6 additions & 6 deletions flows/Squidex.Flows/Execution/DefaultFlowExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static void ValidateProperties(AddError addError, Guid stepId, IFlowStep
}
}

public Task<ExecutionState<TContext>> CreateInstanceAsync(
public Task<FlowExecutionState<TContext>> CreateInstanceAsync(
string ownerId,
string definitionId,
string description,
Expand All @@ -92,7 +92,7 @@ public Task<ExecutionState<TContext>> CreateInstanceAsync(
throw new InvalidOperationException($"Flow definition has no step with ID '{definition.InitialStep}'.");
}

var state = new ExecutionState<TContext>
var state = new FlowExecutionState<TContext>
{
Context = context,
Definition = definition,
Expand All @@ -112,7 +112,7 @@ public async Task SimulateAsync(FlowDefinition definition, TContext context,
{
var options = new ExecutionOptions { IsSimulation = true };

var state = new ExecutionState<TContext>
var state = new FlowExecutionState<TContext>
{
Context = context,
Definition = definition,
Expand All @@ -135,7 +135,7 @@ public async Task SimulateAsync(FlowDefinition definition, TContext context,
}
}

public async Task ExecuteAsync(ExecutionState<TContext> state, ExecutionOptions options,
public async Task ExecuteAsync(FlowExecutionState<TContext> state, ExecutionOptions options,
CancellationToken ct)
{
while (true)
Expand All @@ -155,7 +155,7 @@ public async Task ExecuteAsync(ExecutionState<TContext> state, ExecutionOptions
}
}

private async Task ExecuteCoreAsync(ExecutionState<TContext> state, ExecutionOptions options, IClock clock,
private async Task ExecuteCoreAsync(FlowExecutionState<TContext> state, ExecutionOptions options, IClock clock,
CancellationToken ct)
{
var definition = state.Definition;
Expand Down Expand Up @@ -268,7 +268,7 @@ void Log(string message)
}
}

private static Guid? GetNextStep(ExecutionState<TContext> state, FlowStepDefinition currentStep, FlowStepResult result)
private static Guid? GetNextStep(FlowExecutionState<TContext> state, FlowStepDefinition currentStep, FlowStepResult result)
{
var nextId = result.StepId ?? currentStep.NextStepId;
if (!state.Definition.Steps.ContainsKey(nextId))
Expand Down
2 changes: 1 addition & 1 deletion flows/Squidex.Flows/Execution/DefaultRetryErrorPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Squidex.Flows.Execution;

public sealed class DefaultRetryErrorPolicy<TContext> : IErrorPolicy<TContext> where TContext : FlowContext
{
public Instant? ShouldRetry(ExecutionState<TContext> state, ExecutionStepState stepState, IFlowStep step)
public Instant? ShouldRetry(FlowExecutionState<TContext> state, ExecutionStepState stepState, IFlowStep step)
{
if (step.GetType().GetCustomAttribute<RetryAttribute>() == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Squidex.Flows.Execution;

public sealed class ExecutionState<TContext> where TContext : FlowContext
public sealed class FlowExecutionState<TContext> where TContext : FlowContext
{
required public Guid InstanceId { get; set; }

Expand Down
9 changes: 4 additions & 5 deletions flows/Squidex.Flows/Execution/FlowExecutionWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
using Microsoft.Extensions.Logging;
using NodaTime;
using Squidex.Flows.Execution.Utils;
using Squidex.Hosting;

namespace Squidex.Flows.Execution;

public sealed class FlowExecutionWorker<TContext> : BackgroundService, IBackgroundProcess where TContext : FlowContext
public sealed class FlowExecutionWorker<TContext> : BackgroundService where TContext : FlowContext
{
private readonly ConcurrentDictionary<Guid, bool> executing = new ConcurrentDictionary<Guid, bool>();
private readonly PartitionedScheduler<ExecutionState<TContext>> requestScheduler;
private readonly PartitionedScheduler<FlowExecutionState<TContext>> requestScheduler;
private readonly IFlowExecutor<TContext> executor;
private readonly IFlowStateStore<TContext> store;
private readonly ILogger<FlowExecutionWorker<TContext>> log;
Expand All @@ -33,7 +32,7 @@ public FlowExecutionWorker(
this.store = store;
this.log = log;

requestScheduler = new PartitionedScheduler<ExecutionState<TContext>>(HandleAsync, 32, 2);
requestScheduler = new PartitionedScheduler<FlowExecutionState<TContext>>(HandleAsync, 32, 2);
}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
Expand Down Expand Up @@ -69,7 +68,7 @@ public async Task QueryAsync(
}
}

public async Task HandleAsync(ExecutionState<TContext> state,
public async Task HandleAsync(FlowExecutionState<TContext> state,
CancellationToken ct)
{
if (!executing.TryAdd(state.InstanceId, false))
Expand Down
2 changes: 1 addition & 1 deletion flows/Squidex.Flows/Execution/IErrorPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ namespace Squidex.Flows.Execution;

public interface IErrorPolicy<TContext> where TContext : FlowContext
{
Instant? ShouldRetry(ExecutionState<TContext> state, ExecutionStepState stepStep, IFlowStep step);
Instant? ShouldRetry(FlowExecutionState<TContext> state, ExecutionStepState stepStep, IFlowStep step);
}
Loading

0 comments on commit 78e198d

Please sign in to comment.