From 426b9bcde3d6359e0327d2f0a685ff904dfd6797 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 14 Aug 2024 21:42:46 +0200 Subject: [PATCH] Move build and deployment scripts This commit moves various build scripts, Docker-related files, Kubernetes deployment configurations, and migration scripts. --- .github/workflows/packages.yml | 2 +- .github/workflows/pr.yml | 2 +- Elsa.sln | 37 +++------------- build/_build.csproj | 2 +- .../Controllers/WebhookController.cs | 43 ++++++++++--------- .../build-and-run-all-in-one-web-docker.sh | 0 .../docker/docker-compose.yml | 0 .../docker/docker-run-all-in-one-web.ps1 | 0 .../k8s}/elsa-server/deployment.yaml | 0 .../k8s}/elsa-server/role-binding.yaml | 0 .../k8s}/elsa-server/role.yaml | 0 .../k8s}/elsa-server/service-account.yml | 0 .../k8s}/elsa-server/service.yaml | 0 .../k8s}/plant-uml/deployment.yaml | 0 .../k8s}/postgres/config-map.yaml | 0 .../k8s}/postgres/deployment.yaml | 0 .../k8s}/postgres/service.yml | 0 .../k8s}/trace-lens/deployment.yaml | 0 .../k8s}/trace-lens/service.yaml | 0 {migrations => scripts/migrations}/README.md | 0 .../migrations}/efcore-3.0.sh | 0 .../migrations}/efcore-3.1-sql.sh | 0 .../migrations}/efcore-3.1.sh | 0 .../migrations}/efcore-3.2.sh | 0 .../migrations}/efcore-3.3.sh | 0 build.cmd => scripts/nuke/build.cmd | 0 build.ps1 => scripts/nuke/build.ps1 | 0 build.sh => scripts/nuke/build.sh | 0 28 files changed, 31 insertions(+), 55 deletions(-) rename build-and-run-all-in-one-web-docker.sh => scripts/docker/build-and-run-all-in-one-web-docker.sh (100%) rename docker-compose.yml => scripts/docker/docker-compose.yml (100%) rename docker-run-all-in-one-web.ps1 => scripts/docker/docker-run-all-in-one-web.ps1 (100%) rename {deployment => scripts/k8s}/elsa-server/deployment.yaml (100%) rename {deployment => scripts/k8s}/elsa-server/role-binding.yaml (100%) rename {deployment => scripts/k8s}/elsa-server/role.yaml (100%) rename {deployment => scripts/k8s}/elsa-server/service-account.yml (100%) rename {deployment => scripts/k8s}/elsa-server/service.yaml (100%) rename {deployment => scripts/k8s}/plant-uml/deployment.yaml (100%) rename {deployment => scripts/k8s}/postgres/config-map.yaml (100%) rename {deployment => scripts/k8s}/postgres/deployment.yaml (100%) rename {deployment => scripts/k8s}/postgres/service.yml (100%) rename {deployment => scripts/k8s}/trace-lens/deployment.yaml (100%) rename {deployment => scripts/k8s}/trace-lens/service.yaml (100%) rename {migrations => scripts/migrations}/README.md (100%) rename {migrations => scripts/migrations}/efcore-3.0.sh (100%) rename {migrations => scripts/migrations}/efcore-3.1-sql.sh (100%) rename {migrations => scripts/migrations}/efcore-3.1.sh (100%) rename {migrations => scripts/migrations}/efcore-3.2.sh (100%) rename {migrations => scripts/migrations}/efcore-3.3.sh (100%) rename build.cmd => scripts/nuke/build.cmd (100%) rename build.ps1 => scripts/nuke/build.ps1 (100%) rename build.sh => scripts/nuke/build.sh (100%) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index acf63ed3d..38548711c 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -79,7 +79,7 @@ jobs: 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/apps/** /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 + run: ./scripts/nuke/build.sh Compile+Test+Pack --version ${VERSION} --analyseCode true - name: End SonarCloud analysis env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f2da7a77a..721cef8a7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -30,4 +30,4 @@ jobs: steps: - uses: actions/checkout@v3 - name: 'Run: Compile, Test, Pack' - run: ./build.cmd Compile Test Pack + run: ./scripts/nuke/build.cmd Compile Test Pack diff --git a/Elsa.sln b/Elsa.sln index 69ecf3cad..6a59c236f 100644 --- a/Elsa.sln +++ b/Elsa.sln @@ -15,10 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{7D ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore - build-and-run-all-in-one-web-docker.sh = build-and-run-all-in-one-web-docker.sh Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props - docker-compose.yml = docker-compose.yml icon.png = icon.png NuGet.Config = NuGet.Config README.md = README.md @@ -283,7 +281,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pipelines", "pipelines", "{ .github\workflows\elsa-server.yml = .github\workflows\elsa-server.yml .github\workflows\elsa-studio.yml = .github\workflows\elsa-studio.yml .github\workflows\packages.yml = .github\workflows\packages.yml - build.sh = build.sh .github\workflows\bounty.yml = .github\workflows\bounty.yml .github\workflows\pr.yml = .github\workflows\pr.yml EndProjectSection @@ -298,14 +295,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.AspNet.Heartbe EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.MassTransit.AzureServiceBus", "src\modules\Elsa.MassTransit.AzureServiceBus\Elsa.MassTransit.AzureServiceBus.csproj", "{AFEB799E-82C3-4D02-9D5C-766BB8DEF004}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "migrations", "migrations", "{C80C8231-D35C-4ACC-9ED6-9F3DB221535E}" - ProjectSection(SolutionItems) = preProject - migrations\README.md = migrations\README.md - migrations\efcore-3.1.sh = migrations\efcore-3.1.sh - migrations\efcore-3.2.sh = migrations\efcore-3.2.sh - migrations\efcore-3.0.sh = migrations\efcore-3.0.sh - migrations\efcore-3.3.sh = migrations\efcore-3.3.sh - EndProjectSection +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{C80C8231-D35C-4ACC-9ED6-9F3DB221535E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Alterations.IntegrationTests", "test\integration\Elsa.Alterations.IntegrationTests\Elsa.Alterations.IntegrationTests.csproj", "{F50336DA-42D1-4DD1-A107-67AFEB8A33EE}" EndProject @@ -377,34 +367,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.ProtoActor.Core", "src EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Caching.Distributed.ProtoActor", "src\modules\Elsa.Caching.Distributed.ProtoActor\Elsa.Caching.Distributed.ProtoActor.csproj", "{47FBCB04-0C2D-453C-BE2F-7052CAC22524}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "deployment", "deployment", "{B32DB9B2-AD6C-48A5-8682-4373CB045185}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k8s", "k8s", "{B32DB9B2-AD6C-48A5-8682-4373CB045185}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "elsa-server", "elsa-server", "{454652D5-E1BB-4D4B-9B21-9CEFC900C4FB}" - ProjectSection(SolutionItems) = preProject - deployment\elsa-server\deployment.yaml = deployment\elsa-server\deployment.yaml - deployment\elsa-server\service.yaml = deployment\elsa-server\service.yaml - deployment\elsa-server\service-account.yml = deployment\elsa-server\service-account.yml - deployment\elsa-server\role.yaml = deployment\elsa-server\role.yaml - deployment\elsa-server\role-binding.yaml = deployment\elsa-server\role-binding.yaml - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "postgres", "postgres", "{31089E79-694B-4F45-97AF-86D34A7B231E}" - ProjectSection(SolutionItems) = preProject - deployment\postgres\deployment.yaml = deployment\postgres\deployment.yaml - deployment\postgres\config-map.yaml = deployment\postgres\config-map.yaml - deployment\postgres\service.yml = deployment\postgres\service.yml - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plant-uml", "plant-uml", "{6DDB9ECF-D454-4894-A262-A6BB3026E61E}" - ProjectSection(SolutionItems) = preProject - deployment\plant-uml\deployment.yaml = deployment\plant-uml\deployment.yaml - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "trace-lens", "trace-lens", "{16B570BC-E293-4A19-B20E-5C97BAF8476B}" - ProjectSection(SolutionItems) = preProject - deployment\trace-lens\deployment.yaml = deployment\trace-lens\deployment.yaml - deployment\trace-lens\service.yaml = deployment\trace-lens\service.yaml - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integrations", "integrations", "{EBD0CF78-C5D7-4B4B-94C9-C5D8C20B6F59}" EndProject @@ -424,6 +395,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Agents.Management", "s EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Agents.Persistence", "src\modules\Elsa.Agents.Persistence\Elsa.Agents.Persistence.csproj", "{6FE60BB4-DE6A-485C-A38A-1317C56AF2DA}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuke", "nuke", "{6B921B30-0396-406E-9238-03ED6AC839EC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1145,6 +1118,8 @@ Global {F620D7DC-B58D-4BD0-81A2-E88A2C1E4833} = {50470834-4CD8-479A-8B58-0A1869BA5D37} {9BF476B6-24BA-4312-9DFF-9082B1577046} = {50470834-4CD8-479A-8B58-0A1869BA5D37} {6FE60BB4-DE6A-485C-A38A-1317C56AF2DA} = {50470834-4CD8-479A-8B58-0A1869BA5D37} + {B32DB9B2-AD6C-48A5-8682-4373CB045185} = {C80C8231-D35C-4ACC-9ED6-9F3DB221535E} + {6B921B30-0396-406E-9238-03ED6AC839EC} = {C80C8231-D35C-4ACC-9ED6-9F3DB221535E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D4B5CEAA-7D70-4FCB-A68E-B03FBE5E0E5E} diff --git a/build/_build.csproj b/build/_build.csproj index d3e9cb325..082b20917 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -6,7 +6,7 @@ CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006 .. - .. + ../scripts/nuke/ 1 true true diff --git a/samples/aspnet/Elsa.Samples.AspNet.Onboarding.Web/Controllers/WebhookController.cs b/samples/aspnet/Elsa.Samples.AspNet.Onboarding.Web/Controllers/WebhookController.cs index 7fefcf968..dbd192e99 100644 --- a/samples/aspnet/Elsa.Samples.AspNet.Onboarding.Web/Controllers/WebhookController.cs +++ b/samples/aspnet/Elsa.Samples.AspNet.Onboarding.Web/Controllers/WebhookController.cs @@ -1,41 +1,42 @@ using Elsa.Samples.AspNet.Onboarding.Web.Data; using Elsa.Samples.AspNet.Onboarding.Web.Entities; using Elsa.Samples.AspNet.Onboarding.Web.Models; +using Elsa.Samples.AspNet.Onboarding.Web.Services; using Microsoft.AspNetCore.Mvc; namespace Elsa.Samples.AspNet.Onboarding.Web.Controllers; [ApiController] [Route("api/webhooks")] -public class WebhookController : Controller +public class WebhookController(OnboardingDbContext dbContext, ElsaClient elsaClient) : Controller { - private readonly OnboardingDbContext _dbContext; - - public WebhookController(OnboardingDbContext dbContext) - { - _dbContext = dbContext; - } - [HttpPost("run-task")] - public async Task RunTask(WebhookEvent webhookEvent) + public async Task RunTask(WebhookEvent webhookEvent, CancellationToken cancellationToken) { var payload = webhookEvent.Payload; var taskPayload = payload.TaskPayload; - var employee = taskPayload.Employee; - var task = new OnboardingTask + var result = new { - ProcessId = payload.WorkflowInstanceId, - ExternalId = payload.TaskId, - Name = payload.TaskName, - Description = taskPayload.Description, - EmployeeEmail = employee.Email, - EmployeeName = employee.Name, - CreatedAt = DateTimeOffset.Now + Magic = Random.Shared.NextDouble() }; - - await _dbContext.Tasks.AddAsync(task); - await _dbContext.SaveChangesAsync(); + await elsaClient.ReportTaskCompletedAsync(webhookEvent.Payload.TaskId, result, cancellationToken); + + // var employee = taskPayload.Employee; + // + // var task = new OnboardingTask + // { + // ProcessId = payload.WorkflowInstanceId, + // ExternalId = payload.TaskId, + // Name = payload.TaskName, + // Description = taskPayload.Description, + // EmployeeEmail = employee.Email, + // EmployeeName = employee.Name, + // CreatedAt = DateTimeOffset.Now + // }; + // + // await dbContext.Tasks.AddAsync(task); + // await dbContext.SaveChangesAsync(); return Ok(); } diff --git a/build-and-run-all-in-one-web-docker.sh b/scripts/docker/build-and-run-all-in-one-web-docker.sh similarity index 100% rename from build-and-run-all-in-one-web-docker.sh rename to scripts/docker/build-and-run-all-in-one-web-docker.sh diff --git a/docker-compose.yml b/scripts/docker/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to scripts/docker/docker-compose.yml diff --git a/docker-run-all-in-one-web.ps1 b/scripts/docker/docker-run-all-in-one-web.ps1 similarity index 100% rename from docker-run-all-in-one-web.ps1 rename to scripts/docker/docker-run-all-in-one-web.ps1 diff --git a/deployment/elsa-server/deployment.yaml b/scripts/k8s/elsa-server/deployment.yaml similarity index 100% rename from deployment/elsa-server/deployment.yaml rename to scripts/k8s/elsa-server/deployment.yaml diff --git a/deployment/elsa-server/role-binding.yaml b/scripts/k8s/elsa-server/role-binding.yaml similarity index 100% rename from deployment/elsa-server/role-binding.yaml rename to scripts/k8s/elsa-server/role-binding.yaml diff --git a/deployment/elsa-server/role.yaml b/scripts/k8s/elsa-server/role.yaml similarity index 100% rename from deployment/elsa-server/role.yaml rename to scripts/k8s/elsa-server/role.yaml diff --git a/deployment/elsa-server/service-account.yml b/scripts/k8s/elsa-server/service-account.yml similarity index 100% rename from deployment/elsa-server/service-account.yml rename to scripts/k8s/elsa-server/service-account.yml diff --git a/deployment/elsa-server/service.yaml b/scripts/k8s/elsa-server/service.yaml similarity index 100% rename from deployment/elsa-server/service.yaml rename to scripts/k8s/elsa-server/service.yaml diff --git a/deployment/plant-uml/deployment.yaml b/scripts/k8s/plant-uml/deployment.yaml similarity index 100% rename from deployment/plant-uml/deployment.yaml rename to scripts/k8s/plant-uml/deployment.yaml diff --git a/deployment/postgres/config-map.yaml b/scripts/k8s/postgres/config-map.yaml similarity index 100% rename from deployment/postgres/config-map.yaml rename to scripts/k8s/postgres/config-map.yaml diff --git a/deployment/postgres/deployment.yaml b/scripts/k8s/postgres/deployment.yaml similarity index 100% rename from deployment/postgres/deployment.yaml rename to scripts/k8s/postgres/deployment.yaml diff --git a/deployment/postgres/service.yml b/scripts/k8s/postgres/service.yml similarity index 100% rename from deployment/postgres/service.yml rename to scripts/k8s/postgres/service.yml diff --git a/deployment/trace-lens/deployment.yaml b/scripts/k8s/trace-lens/deployment.yaml similarity index 100% rename from deployment/trace-lens/deployment.yaml rename to scripts/k8s/trace-lens/deployment.yaml diff --git a/deployment/trace-lens/service.yaml b/scripts/k8s/trace-lens/service.yaml similarity index 100% rename from deployment/trace-lens/service.yaml rename to scripts/k8s/trace-lens/service.yaml diff --git a/migrations/README.md b/scripts/migrations/README.md similarity index 100% rename from migrations/README.md rename to scripts/migrations/README.md diff --git a/migrations/efcore-3.0.sh b/scripts/migrations/efcore-3.0.sh similarity index 100% rename from migrations/efcore-3.0.sh rename to scripts/migrations/efcore-3.0.sh diff --git a/migrations/efcore-3.1-sql.sh b/scripts/migrations/efcore-3.1-sql.sh similarity index 100% rename from migrations/efcore-3.1-sql.sh rename to scripts/migrations/efcore-3.1-sql.sh diff --git a/migrations/efcore-3.1.sh b/scripts/migrations/efcore-3.1.sh similarity index 100% rename from migrations/efcore-3.1.sh rename to scripts/migrations/efcore-3.1.sh diff --git a/migrations/efcore-3.2.sh b/scripts/migrations/efcore-3.2.sh similarity index 100% rename from migrations/efcore-3.2.sh rename to scripts/migrations/efcore-3.2.sh diff --git a/migrations/efcore-3.3.sh b/scripts/migrations/efcore-3.3.sh similarity index 100% rename from migrations/efcore-3.3.sh rename to scripts/migrations/efcore-3.3.sh diff --git a/build.cmd b/scripts/nuke/build.cmd similarity index 100% rename from build.cmd rename to scripts/nuke/build.cmd diff --git a/build.ps1 b/scripts/nuke/build.ps1 similarity index 100% rename from build.ps1 rename to scripts/nuke/build.ps1 diff --git a/build.sh b/scripts/nuke/build.sh similarity index 100% rename from build.sh rename to scripts/nuke/build.sh