From 094d111cd51f275dbac0999f06a9bcfe70e1e2ee Mon Sep 17 00:00:00 2001 From: Max Ewing Date: Fri, 8 Mar 2024 08:35:51 +0000 Subject: [PATCH] ci: create dotnet-build.yml (#1) +semver: none --- .editorconfig | 6 +- .github/workflows/ci.yml | 79 +++++++++++++++++++ ScenarioBuilder.sln | 2 +- src/ScenarioBuilder/Event.cs | 1 - src/ScenarioBuilder/ScenarioBuilder.csproj | 4 + .../ScenarioBuilder.IntegrationTests.csproj | 2 +- .../ScenarioBuilderTests.cs | 4 +- .../ApplicationScenario.cs | 10 +-- .../CaseworkerAssignsApplicationEvent.cs | 6 +- .../Caseworker/CaseworkerSetsApprovalEvent.cs | 8 +- .../CaseworkerProcessesApplicationEvent.cs | 2 +- .../PortalUserSubmitsApplicationEvent.cs | 4 +- .../Persona.cs | 2 +- ...ScenarioBuilder.TestImplementation.csproj} | 1 + .../ScenarioContextExtensions.cs | 2 +- .../Services/IServiceClientFactory.cs | 2 +- .../ComposeUsingAttributeTests.cs | 2 +- .../ScenarioBuilder.UnitTests.csproj | 2 +- 18 files changed, 113 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/ci.yml rename test/{ScenarioBuilder.TestHarness => ScenarioBuilder.TestImplementation}/ApplicationScenario.cs (91%) rename test/{ScenarioBuilder.TestHarness => ScenarioBuilder.TestImplementation}/Events/Caseworker/CaseworkerAssignsApplicationEvent.cs (95%) rename test/{ScenarioBuilder.TestHarness => ScenarioBuilder.TestImplementation}/Events/Caseworker/CaseworkerSetsApprovalEvent.cs (93%) rename test/{ScenarioBuilder.TestHarness => ScenarioBuilder.TestImplementation}/Events/Caseworker/Composites/CaseworkerProcessesApplicationEvent.cs (97%) rename test/{ScenarioBuilder.TestHarness => ScenarioBuilder.TestImplementation}/Events/PortalUser/PortalUserSubmitsApplicationEvent.cs (96%) rename test/{ScenarioBuilder.TestHarness => ScenarioBuilder.TestImplementation}/Persona.cs (86%) rename test/{ScenarioBuilder.TestHarness/ScenarioBuilder.TestHarness.csproj => ScenarioBuilder.TestImplementation/ScenarioBuilder.TestImplementation.csproj} (96%) rename test/{ScenarioBuilder.TestHarness => ScenarioBuilder.TestImplementation}/ScenarioContextExtensions.cs (95%) rename test/{ScenarioBuilder.TestHarness => ScenarioBuilder.TestImplementation}/Services/IServiceClientFactory.cs (92%) diff --git a/.editorconfig b/.editorconfig index 17e465b..3795f62 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,4 +4,8 @@ dotnet_diagnostic.SA1633.severity = silent [**/GlobalUsings.cs] -csharp_using_directive_placement = outside_namespace:silent \ No newline at end of file +csharp_using_directive_placement = outside_namespace:silent + + +[**/*Event.cs] +dotnet_diagnostic.cs0649.severity = none \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..022447f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +name: ci + +on: + push: + branches: [ "main" ] + paths: [ "src/**/*.cs" ] + +defaults: + run: + shell: pwsh + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + BUILD_NUGET_OUTPUTDIRECTORY: ${{ github.workspace}}/nuget + +jobs: + build: + runs-on: ubuntu-latest + outputs: + fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0 + with: + versionSpec: '5.x' + - name: Run GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v0 + with: + useConfigFile: true + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration Release --no-restore + - name: Test + run: dotnet test --configuration Release --no-build --verbosity normal + - name: Pack + run: dotnet pack --configuration Release --no-restore --output ${{ env.BUILD_NUGET_OUTPUTDIRECTORY }} + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: package + if-no-files-found: error + retention-days: 0 + path: ${{ env.BUILD_NUGET_OUTPUTDIRECTORY }}/**.*nupkg + deploy: + runs-on: ubuntu-latest + permissions: + contents: write + needs: [ build ] + steps: + - uses: actions/download-artifact@v4 + with: + name: package + path: ${{ env.BUILD_NUGET_OUTPUTDIRECTORY }} + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 6.0.x + - name: Publish + run: | + Get-ChildItem "${{ env.BUILD_NUGET_OUTPUTDIRECTORY }}" -Recurse -Include *.nupkg | ForEach-Object { + dotnet nuget push $_ --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + } + - name: Create release + env: + CREATERELEASE_FULLSEMVER: ${{ needs.build.outputs.fullSemVer }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "v$env:CREATERELEASE_FULLSEMVER" --generate-notes --repo="$env:GITHUB_REPOSITORY" diff --git a/ScenarioBuilder.sln b/ScenarioBuilder.sln index a9a88f5..fe7e9a2 100644 --- a/ScenarioBuilder.sln +++ b/ScenarioBuilder.sln @@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScenarioBuilder.UnitTests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScenarioBuilder.IntegrationTests", "test\ScenarioBuilder.IntegrationTests\ScenarioBuilder.IntegrationTests.csproj", "{FF4899F1-1AE8-43B6-8B94-23BDFF5E2913}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScenarioBuilder.TestHarness", "test\ScenarioBuilder.TestHarness\ScenarioBuilder.TestHarness.csproj", "{37AC9876-7FC2-408E-ADB3-43D9F2FD21A1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScenarioBuilder.TestImplementation", "test\ScenarioBuilder.TestImplementation\ScenarioBuilder.TestImplementation.csproj", "{37AC9876-7FC2-408E-ADB3-43D9F2FD21A1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FCC7B6D7-531D-442C-A7E9-E87FEDB9AC4A}" ProjectSection(SolutionItems) = preProject diff --git a/src/ScenarioBuilder/Event.cs b/src/ScenarioBuilder/Event.cs index be1dd23..6e6382d 100644 --- a/src/ScenarioBuilder/Event.cs +++ b/src/ScenarioBuilder/Event.cs @@ -1,7 +1,6 @@ namespace ScenarioBuilder { using System.Threading.Tasks; - using System.Xml.Serialization; using AutoMapper; /// diff --git a/src/ScenarioBuilder/ScenarioBuilder.csproj b/src/ScenarioBuilder/ScenarioBuilder.csproj index 65f54fd..10399f1 100644 --- a/src/ScenarioBuilder/ScenarioBuilder.csproj +++ b/src/ScenarioBuilder/ScenarioBuilder.csproj @@ -24,6 +24,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + all diff --git a/test/ScenarioBuilder.IntegrationTests/ScenarioBuilder.IntegrationTests.csproj b/test/ScenarioBuilder.IntegrationTests/ScenarioBuilder.IntegrationTests.csproj index c0907dd..831226f 100644 --- a/test/ScenarioBuilder.IntegrationTests/ScenarioBuilder.IntegrationTests.csproj +++ b/test/ScenarioBuilder.IntegrationTests/ScenarioBuilder.IntegrationTests.csproj @@ -25,7 +25,7 @@ - + diff --git a/test/ScenarioBuilder.IntegrationTests/ScenarioBuilderTests.cs b/test/ScenarioBuilder.IntegrationTests/ScenarioBuilderTests.cs index 0f81b0f..77dabdf 100644 --- a/test/ScenarioBuilder.IntegrationTests/ScenarioBuilderTests.cs +++ b/test/ScenarioBuilder.IntegrationTests/ScenarioBuilderTests.cs @@ -5,8 +5,8 @@ using Microsoft.PowerPlatform.Dataverse.Client; using Microsoft.Xrm.Sdk; using Moq; -using ScenarioBuilder.TestHarness; -using ScenarioBuilder.TestHarness.Services; +using ScenarioBuilder.TestImplementation; +using ScenarioBuilder.TestImplementation.Services; /// /// Integration tests for the class. diff --git a/test/ScenarioBuilder.TestHarness/ApplicationScenario.cs b/test/ScenarioBuilder.TestImplementation/ApplicationScenario.cs similarity index 91% rename from test/ScenarioBuilder.TestHarness/ApplicationScenario.cs rename to test/ScenarioBuilder.TestImplementation/ApplicationScenario.cs index de9f457..8013bf8 100644 --- a/test/ScenarioBuilder.TestHarness/ApplicationScenario.cs +++ b/test/ScenarioBuilder.TestImplementation/ApplicationScenario.cs @@ -1,11 +1,11 @@ -namespace ScenarioBuilder.TestHarness; +namespace ScenarioBuilder.TestImplementation; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using ScenarioBuilder.TestHarness.Events.Caseworker; -using ScenarioBuilder.TestHarness.Events.Caseworker.Composites; -using ScenarioBuilder.TestHarness.Events.PortalUser; -using ScenarioBuilder.TestHarness.Services; +using ScenarioBuilder.TestImplementation.Events.Caseworker; +using ScenarioBuilder.TestImplementation.Events.Caseworker.Composites; +using ScenarioBuilder.TestImplementation.Events.PortalUser; +using ScenarioBuilder.TestImplementation.Services; /// /// An example scenario for an application. diff --git a/test/ScenarioBuilder.TestHarness/Events/Caseworker/CaseworkerAssignsApplicationEvent.cs b/test/ScenarioBuilder.TestImplementation/Events/Caseworker/CaseworkerAssignsApplicationEvent.cs similarity index 95% rename from test/ScenarioBuilder.TestHarness/Events/Caseworker/CaseworkerAssignsApplicationEvent.cs rename to test/ScenarioBuilder.TestImplementation/Events/Caseworker/CaseworkerAssignsApplicationEvent.cs index f0748ca..cd65b53 100644 --- a/test/ScenarioBuilder.TestHarness/Events/Caseworker/CaseworkerAssignsApplicationEvent.cs +++ b/test/ScenarioBuilder.TestImplementation/Events/Caseworker/CaseworkerAssignsApplicationEvent.cs @@ -1,11 +1,11 @@ -namespace ScenarioBuilder.TestHarness.Events.Caseworker +namespace ScenarioBuilder.TestImplementation.Events.Caseworker { using Microsoft.Crm.Sdk.Messages; using Microsoft.Extensions.Logging; using Microsoft.PowerPlatform.Dataverse.Client; using Microsoft.Xrm.Sdk; - using ScenarioBuilder.TestHarness.Events.PortalUser; - using ScenarioBuilder.TestHarness.Services; + using ScenarioBuilder.TestImplementation.Events.PortalUser; + using ScenarioBuilder.TestImplementation.Services; /// /// An event for a caseworker assigning an application. diff --git a/test/ScenarioBuilder.TestHarness/Events/Caseworker/CaseworkerSetsApprovalEvent.cs b/test/ScenarioBuilder.TestImplementation/Events/Caseworker/CaseworkerSetsApprovalEvent.cs similarity index 93% rename from test/ScenarioBuilder.TestHarness/Events/Caseworker/CaseworkerSetsApprovalEvent.cs rename to test/ScenarioBuilder.TestImplementation/Events/Caseworker/CaseworkerSetsApprovalEvent.cs index 0705baa..4c6bad9 100644 --- a/test/ScenarioBuilder.TestHarness/Events/Caseworker/CaseworkerSetsApprovalEvent.cs +++ b/test/ScenarioBuilder.TestImplementation/Events/Caseworker/CaseworkerSetsApprovalEvent.cs @@ -1,10 +1,10 @@ -namespace ScenarioBuilder.TestHarness.Events.Caseworker +namespace ScenarioBuilder.TestImplementation.Events.Caseworker { using Microsoft.Extensions.Logging; using Microsoft.Xrm.Sdk; - using ScenarioBuilder.TestHarness.Events.Caseworker.Composites; - using ScenarioBuilder.TestHarness.Events.PortalUser; - using ScenarioBuilder.TestHarness.Services; + using ScenarioBuilder.TestImplementation.Events.Caseworker.Composites; + using ScenarioBuilder.TestImplementation.Events.PortalUser; + using ScenarioBuilder.TestImplementation.Services; /// /// An event for a caseworker approving an application. diff --git a/test/ScenarioBuilder.TestHarness/Events/Caseworker/Composites/CaseworkerProcessesApplicationEvent.cs b/test/ScenarioBuilder.TestImplementation/Events/Caseworker/Composites/CaseworkerProcessesApplicationEvent.cs similarity index 97% rename from test/ScenarioBuilder.TestHarness/Events/Caseworker/Composites/CaseworkerProcessesApplicationEvent.cs rename to test/ScenarioBuilder.TestImplementation/Events/Caseworker/Composites/CaseworkerProcessesApplicationEvent.cs index 8572cc6..a405a29 100644 --- a/test/ScenarioBuilder.TestHarness/Events/Caseworker/Composites/CaseworkerProcessesApplicationEvent.cs +++ b/test/ScenarioBuilder.TestImplementation/Events/Caseworker/Composites/CaseworkerProcessesApplicationEvent.cs @@ -1,4 +1,4 @@ -namespace ScenarioBuilder.TestHarness.Events.Caseworker.Composites +namespace ScenarioBuilder.TestImplementation.Events.Caseworker.Composites { /// /// A composite event for a caseworker processing an application. diff --git a/test/ScenarioBuilder.TestHarness/Events/PortalUser/PortalUserSubmitsApplicationEvent.cs b/test/ScenarioBuilder.TestImplementation/Events/PortalUser/PortalUserSubmitsApplicationEvent.cs similarity index 96% rename from test/ScenarioBuilder.TestHarness/Events/PortalUser/PortalUserSubmitsApplicationEvent.cs rename to test/ScenarioBuilder.TestImplementation/Events/PortalUser/PortalUserSubmitsApplicationEvent.cs index a53f58b..c697e71 100644 --- a/test/ScenarioBuilder.TestHarness/Events/PortalUser/PortalUserSubmitsApplicationEvent.cs +++ b/test/ScenarioBuilder.TestImplementation/Events/PortalUser/PortalUserSubmitsApplicationEvent.cs @@ -1,8 +1,8 @@ -namespace ScenarioBuilder.TestHarness.Events.PortalUser +namespace ScenarioBuilder.TestImplementation.Events.PortalUser { using Microsoft.Extensions.Logging; using Microsoft.Xrm.Sdk; - using ScenarioBuilder.TestHarness.Services; + using ScenarioBuilder.TestImplementation.Services; /// /// An event for a portal user submitting an application. diff --git a/test/ScenarioBuilder.TestHarness/Persona.cs b/test/ScenarioBuilder.TestImplementation/Persona.cs similarity index 86% rename from test/ScenarioBuilder.TestHarness/Persona.cs rename to test/ScenarioBuilder.TestImplementation/Persona.cs index 72a2f0e..1d801a5 100644 --- a/test/ScenarioBuilder.TestHarness/Persona.cs +++ b/test/ScenarioBuilder.TestImplementation/Persona.cs @@ -1,4 +1,4 @@ -namespace ScenarioBuilder.TestHarness +namespace ScenarioBuilder.TestImplementation { /// /// The personas involved in the scenarios. diff --git a/test/ScenarioBuilder.TestHarness/ScenarioBuilder.TestHarness.csproj b/test/ScenarioBuilder.TestImplementation/ScenarioBuilder.TestImplementation.csproj similarity index 96% rename from test/ScenarioBuilder.TestHarness/ScenarioBuilder.TestHarness.csproj rename to test/ScenarioBuilder.TestImplementation/ScenarioBuilder.TestImplementation.csproj index 0f35ea4..229afaa 100644 --- a/test/ScenarioBuilder.TestHarness/ScenarioBuilder.TestHarness.csproj +++ b/test/ScenarioBuilder.TestImplementation/ScenarioBuilder.TestImplementation.csproj @@ -17,6 +17,7 @@ net8.0 enable enable + false true true diff --git a/test/ScenarioBuilder.TestHarness/ScenarioContextExtensions.cs b/test/ScenarioBuilder.TestImplementation/ScenarioContextExtensions.cs similarity index 95% rename from test/ScenarioBuilder.TestHarness/ScenarioContextExtensions.cs rename to test/ScenarioBuilder.TestImplementation/ScenarioContextExtensions.cs index 37ce906..347bc4b 100644 --- a/test/ScenarioBuilder.TestHarness/ScenarioContextExtensions.cs +++ b/test/ScenarioBuilder.TestImplementation/ScenarioContextExtensions.cs @@ -1,4 +1,4 @@ -namespace ScenarioBuilder.TestHarness +namespace ScenarioBuilder.TestImplementation { /// /// Extensions to the class. diff --git a/test/ScenarioBuilder.TestHarness/Services/IServiceClientFactory.cs b/test/ScenarioBuilder.TestImplementation/Services/IServiceClientFactory.cs similarity index 92% rename from test/ScenarioBuilder.TestHarness/Services/IServiceClientFactory.cs rename to test/ScenarioBuilder.TestImplementation/Services/IServiceClientFactory.cs index 74943e2..0e84b0e 100644 --- a/test/ScenarioBuilder.TestHarness/Services/IServiceClientFactory.cs +++ b/test/ScenarioBuilder.TestImplementation/Services/IServiceClientFactory.cs @@ -1,4 +1,4 @@ -namespace ScenarioBuilder.TestHarness.Services +namespace ScenarioBuilder.TestImplementation.Services { using Microsoft.PowerPlatform.Dataverse.Client; diff --git a/test/ScenarioBuilder.UnitTests/ComposeUsingAttributeTests.cs b/test/ScenarioBuilder.UnitTests/ComposeUsingAttributeTests.cs index f74f6b7..4e02667 100644 --- a/test/ScenarioBuilder.UnitTests/ComposeUsingAttributeTests.cs +++ b/test/ScenarioBuilder.UnitTests/ComposeUsingAttributeTests.cs @@ -1,7 +1,7 @@ namespace ScenarioBuilder.UnitTests; using ScenarioBuilder; -using ScenarioBuilder.TestHarness.Events.PortalUser; +using ScenarioBuilder.TestImplementation.Events.PortalUser; /// /// Tests for the class. diff --git a/test/ScenarioBuilder.UnitTests/ScenarioBuilder.UnitTests.csproj b/test/ScenarioBuilder.UnitTests/ScenarioBuilder.UnitTests.csproj index 5974254..bd71124 100644 --- a/test/ScenarioBuilder.UnitTests/ScenarioBuilder.UnitTests.csproj +++ b/test/ScenarioBuilder.UnitTests/ScenarioBuilder.UnitTests.csproj @@ -25,7 +25,7 @@ - +