diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 009401d8e..fbcf533d1 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -64,25 +64,25 @@ jobs: else echo "VERSION=3.2.0-${PACKAGE_PREFIX}.${{github.run_number}}" >> $GITHUB_ENV fi - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'adopt' - - name: Install SonarScanner for .NET - run: dotnet tool install --global dotnet-sonarscanner - - name: Install Coverlet for code coverage - run: dotnet tool install --global coverlet.console - - name: Begin SonarCloud analysis - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: dotnet sonarscanner begin /k:"elsa-workflows_elsa-core" /o:"elsa-workflows" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.exclusions=**/obj/**,**/*.dll,build/**,samples/**,src/bundles/** /d:"sonar.verbose=true" /d:sonar.cs.opencover.reportsPaths=**/testresults/**/coverage.opencover.xml +# - name: Set up JDK 17 +# uses: actions/setup-java@v2 +# with: +# java-version: '17' +# distribution: 'adopt' +# - name: Install SonarScanner for .NET +# run: dotnet tool install --global dotnet-sonarscanner +# - name: Install Coverlet for code coverage +# run: dotnet tool install --global coverlet.console +# - name: Begin SonarCloud analysis +# env: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# run: dotnet sonarscanner begin /k:"elsa-workflows_elsa-core" /o:"elsa-workflows" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.exclusions=**/obj/**,**/*.dll,build/**,samples/**,src/bundles/** /d:"sonar.verbose=true" /d:sonar.cs.opencover.reportsPaths=**/testresults/**/coverage.opencover.xml - name: Compile+Test+Pack run: ./build.sh Compile+Test+Pack --version ${VERSION} --analyseCode true - - name: End SonarCloud analysis - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" +# - name: End SonarCloud analysis +# env: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - name: Upload artifact uses: actions/upload-artifact@v3 with: diff --git a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs index 3e53cc97f..aa9b402de 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs @@ -141,7 +141,8 @@ public class Flowchart : Container var logger = context.GetRequiredService>(); var loggerScopeState = new Dictionary { - ["ThreadId"] = Thread.CurrentThread.ManagedThreadId, + ["ThreadId"] = Environment.CurrentManagedThreadId, + ["TaskId"] = Task.CurrentId?.ToString() ?? "N/A", ["ActivityId"] = Id, ["ActivityInstanceId"] = context.TargetContext.Id }; @@ -174,11 +175,12 @@ public class Flowchart : Container { if (children.Any()) { - scope.AddActivities(children); - // Schedule each child, but only if all of its left inbound activities have already executed. foreach (var activity in children) { + var existingActivity = scope.ContainsActivity(activity); + scope.AddActivity(activity); + var inboundActivities = Connections.LeftInboundActivities(activity).ToList(); // If the completed activity is not part of the left inbound path, always allow its children to be scheduled. @@ -212,8 +214,13 @@ public class Flowchart : Container if (joinContext != null) logger.LogDebug("Next activity {ChildActivityId} is a join activity. Attaching to existing join context {JoinContext}", activity.Id, joinContext.Id); - else + else if(!existingActivity) logger.LogDebug("Next activity {ChildActivityId} is a join activity. Creating new join context", activity.Id); + else + { + logger.LogDebug("Next activity {ChildActivityId} is a join activity. Join context was not found, but activity is already being created.", activity.Id); + continue; + } await flowchartContext.ScheduleActivityAsync(activity, scheduleWorkOptions); } @@ -231,7 +238,6 @@ public class Flowchart : Container private async Task CompleteIfNoPendingWorkAsync(ActivityExecutionContext context) { - var logger = context.GetRequiredService>(); var hasPendingWork = HasPendingWork(context); if (!hasPendingWork) diff --git a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowScope.cs b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowScope.cs index 0f5cb75ab..b1d0fd82d 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowScope.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowScope.cs @@ -45,6 +45,11 @@ internal class FlowScope return state; } + + public bool ContainsActivity(IActivity activity) + { + return Activities.ContainsKey(activity.Id); + } public void RegisterActivityExecution(IActivity activity) { diff --git a/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs b/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs index 4b158b717..266d2f8e6 100644 --- a/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs +++ b/src/modules/Elsa.Workflows.Core/Services/WorkflowRunner.cs @@ -56,9 +56,7 @@ public class WorkflowRunner( } /// - public async Task RunAsync( - RunWorkflowOptions? options = default, - CancellationToken cancellationToken = default) where T : WorkflowBase, new() + public async Task RunAsync(RunWorkflowOptions? options = default, CancellationToken cancellationToken = default) where T : WorkflowBase, new() { var builder = workflowBuilderFactory.CreateBuilder(); var workflow = await builder.BuildWorkflowAsync(cancellationToken); diff --git a/test/component/Elsa.Workflows.ComponentTests/Helpers/Contracts/ISignalManager.cs b/test/component/Elsa.Workflows.ComponentTests/Helpers/Contracts/ISignalManager.cs index f169b4423..f5b24e653 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Helpers/Contracts/ISignalManager.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Helpers/Contracts/ISignalManager.cs @@ -2,7 +2,7 @@ namespace Elsa.Workflows.ComponentTests; public interface ISignalManager { - Task WaitAsync(object signal, int millisecondsTimeout = 1000); - Task WaitAsync(object signal, int millisecondsTimeout = 1000); + Task WaitAsync(object signal, int millisecondsTimeout = 2000); + Task WaitAsync(object signal, int millisecondsTimeout = 2000); void Trigger(object signal, object? result = null); } \ No newline at end of file