Skip to content

Commit

Permalink
Merge pull request #9 from delegateas/pks/fixjobnames
Browse files Browse the repository at this point in the history
Fixing JobNames
  • Loading branch information
pksorensen authored Feb 15, 2022
2 parents 0002d89 + a6c9a7b commit a37d7ad
Show file tree
Hide file tree
Showing 16 changed files with 188 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/.releaserc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
branches:
- name: master
- name: 'releases/+([0-9])?(.{+([0-9]),x}).x'
prerelease: true
- name: dev
prerelease: dev

Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: PreRelease

on:
push:
branches:
- releases/**

jobs:
release:
name: Pre Releasing
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 16

- name: Add plugin for conventional commits
run: npm install conventional-changelog-conventionalcommits
working-directory: ./.github/workflows

- name: Add plugin for executing bash commands
run: npm install @semantic-release/exec -D
working-directory: ./.github/workflows

- name: Dry Run Semantic to get next Version nummber
working-directory: ./.github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_NAME: thygesteffensen
GIT_AUTHOR_EMAIL: [email protected]
run: |
echo "$(npx semantic-release --dry-run)"
- name: Dry Run Semantic to get next Version nummber
working-directory: ./.github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_NAME: thygesteffensen
GIT_AUTHOR_EMAIL: [email protected]
run: |
echo "RELEASE_VERSION=$((npx semantic-release --dry-run).Where({ $_ -like '*Release note*' }) | Out-String | Select-String '[0-9]+\.[0-9]+\.[0-9]+([-][a-zA-z]+[.][0-9]*)?' | % { $_.Matches } | % { $_.Value })" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Print release verison
run: echo ${env:RELEASE_VERSION}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 13
node-version: 16

- name: Add plugin for conventional commits
run: npm install conventional-changelog-conventionalcommits
Expand Down
9 changes: 7 additions & 2 deletions WorkflowEngine.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31320.298
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowEngine.Core", "src\WorkflowEngine.Core\WorkflowEngine.Core.csproj", "{44ED38AB-742A-455D-8451-BB0947E76E43}"
EndProject
Expand All @@ -10,7 +10,12 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0749C5E8-52D4-4B3A-89EA-891DD156A056}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.github\workflows\.releaserc = .github\workflows\.releaserc
.github\workflows\build.yml = .github\workflows\build.yml
.github\workflows\prerelease.yml = .github\workflows\prerelease.yml
README.md = README.md
.github\workflows\release.yml = .github\workflows\release.yml
.github\workflows\todo.yml = .github\workflows\todo.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowEngine.Hangfire", "src\WorkflowEngine.Hangfire\WorkflowEngine.Hangfire.csproj", "{7A50D90B-98AE-4B7F-9B39-8828D9ACED5B}"
Expand Down
10 changes: 9 additions & 1 deletion src/WorkflowEngine.Core/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

namespace WorkflowEngine.Core
{
public class Action : IAction
public class Action : IAction, IFormattable
{
public DateTimeOffset ScheduledTime { get; set; }

public string Type { get; set; }
public string Key { get; set; }

public string ToString(string format, IFormatProvider formatProvider)
{
if (format == "Type")
return Type;

return string.Empty;
}
}


Expand Down
27 changes: 0 additions & 27 deletions src/WorkflowEngine.Core/ActionExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,6 @@

namespace WorkflowEngine.Core
{
public interface IActionImplementationMetadata{
string Type { get; }
Type Implementation { get; }
}
public class ActionImplementationMetadata<T> : IActionImplementationMetadata
where T: IActionImplementation
{
public string Type { get; set; }
public Type Implementation => typeof(T);
}
public static class IActionImplementationExtenssions
{
public static IServiceCollection AddAction<T>(this IServiceCollection services, string type)
where T: class, IActionImplementation
{
return services.AddTransient<T>()
.AddSingleton< IActionImplementationMetadata>(new ActionImplementationMetadata<T> { Type = type });
}
}
public interface IActionImplementation
{


ValueTask<object> ExecuteAsync(IWorkflow workflow, IAction action);


}
public class ActionExecutor : IActionExecutor
{
private readonly IServiceProvider serviceProvider;
Expand Down
14 changes: 14 additions & 0 deletions src/WorkflowEngine.Core/ActionImplementationMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace WorkflowEngine.Core
{
public class ActionImplementationMetadata<T> : IActionImplementationMetadata
where T: IActionImplementation
{
public string Type { get; set; }
public Type Implementation => typeof(T);
}



}
6 changes: 4 additions & 2 deletions src/WorkflowEngine.Core/ActionMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

namespace WorkflowEngine.Core
{
/// <summary>
/// Represent the metadata for a action
/// </summary>
public class ActionMetadata
{
public WorkflowRunAfterActions RunAfter { get; set; } = new WorkflowRunAfterActions();
public string Type { get; set; }
public IDictionary<string, string> Inputs { get; set; } = new Dictionary<string, string>();
public IDictionary<string, object> Inputs { get; set; } = new Dictionary<string, object>();

}


}
16 changes: 16 additions & 0 deletions src/WorkflowEngine.Core/IActionImplementation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Threading.Tasks;

namespace WorkflowEngine.Core
{
public interface IActionImplementation
{


ValueTask<object> ExecuteAsync(IWorkflow workflow, IAction action);


}



}
17 changes: 17 additions & 0 deletions src/WorkflowEngine.Core/IActionImplementationExtenssions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Extensions.DependencyInjection;

namespace WorkflowEngine.Core
{
public static class IActionImplementationExtenssions
{
public static IServiceCollection AddAction<T>(this IServiceCollection services, string type)
where T: class, IActionImplementation
{
return services.AddTransient<T>()
.AddSingleton< IActionImplementationMetadata>(new ActionImplementationMetadata<T> { Type = type });
}
}



}
12 changes: 12 additions & 0 deletions src/WorkflowEngine.Core/IActionImplementationMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace WorkflowEngine.Core
{
public interface IActionImplementationMetadata{
string Type { get; }
Type Implementation { get; }
}



}
15 changes: 13 additions & 2 deletions src/WorkflowEngine.Core/TriggerContext.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
namespace WorkflowEngine.Core
using System;

namespace WorkflowEngine.Core
{
public class TriggerContext : ITriggerContext
public class TriggerContext : ITriggerContext, IFormattable
{
public IWorkflow Workflow { get; set; }

public string ToString(string format, IFormatProvider formatProvider)
{
if(format =="WorkFlow")
{
return Workflow?.GetType().Name.ToString();
}
return string.Empty;
}
}


Expand Down
17 changes: 16 additions & 1 deletion src/WorkflowEngine.Core/Workflow.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
using System;
using System.Linq;

namespace WorkflowEngine.Core
{
public class Workflow : IWorkflow
public class Workflow : IWorkflow, IFormattable
{
public Guid Id { get; set; }
public string Version { get; set; }
public WorkflowManifest Manifest { get; set; }

public string ToString(string format, IFormatProvider formatProvider)
{
if (format == "Id")
return Id.ToString();

if (format == "Version")
return Version;

if (format == "Trigger")
return Manifest.Triggers.FirstOrDefault().Value?.Type;

return string.Empty;
}
}


Expand Down
11 changes: 0 additions & 11 deletions src/WorkflowEngine.Hangfire/Class1.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
using System;
using System.ComponentModel;
using System.Threading.Tasks;
using WorkflowEngine.Core;

namespace WorkflowEngine
{
public interface IHangfireActionExecutor
{
[DisplayName("Action: {0}")]
public ValueTask<object> ExecuteAsync(string type, IWorkflow workflow, IAction action);
}
public interface IHangfireWorkflowExecutor
{
[DisplayName("Trigger: {0}")]
public ValueTask<object> TriggerAsync(ITriggerContext context);
}

public class HangfireWorkflowExecutor : IHangfireWorkflowExecutor, IHangfireActionExecutor
{
Expand Down
14 changes: 14 additions & 0 deletions src/WorkflowEngine.Hangfire/IHangfireActionExecutor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Hangfire;
using System.ComponentModel;
using System.Threading.Tasks;
using WorkflowEngine.Core;

namespace WorkflowEngine
{
public interface IHangfireActionExecutor
{
[JobDisplayName("Action: {0}, workflow={1:Id}")]
public ValueTask<object> ExecuteAsync(string type, IWorkflow workflow, IAction action);
}

}
14 changes: 14 additions & 0 deletions src/WorkflowEngine.Hangfire/IHangfireWorkflowExecutor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Hangfire;
using System.ComponentModel;
using System.Threading.Tasks;
using WorkflowEngine.Core;

namespace WorkflowEngine
{
public interface IHangfireWorkflowExecutor
{
[JobDisplayName("Trigger: {0:WorkFlow}")]
public ValueTask<object> TriggerAsync(ITriggerContext context);
}

}

0 comments on commit a37d7ad

Please sign in to comment.