diff --git a/.github/dotnet/action.yaml b/.github/dotnet/action.yaml new file mode 100644 index 00000000..03696ad9 --- /dev/null +++ b/.github/dotnet/action.yaml @@ -0,0 +1,12 @@ +name: dotnet setup +description: "base dotnet setup for project" +runs: + using: composite + steps: + - name: setup + id: setup-dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 6.0.x + 8.0.x diff --git a/.github/npm/action.yaml b/.github/npm/action.yaml new file mode 100644 index 00000000..a35897e2 --- /dev/null +++ b/.github/npm/action.yaml @@ -0,0 +1,14 @@ +name: npm setup +description: "base npm setup for project" +runs: + using: composite + steps: + - name: setup dotnet + uses: ./.github/dotnet + - uses: actions/setup-node@v3 + with: + node-version: "lts/*" + - name: Run NPM install + shell: sh + run: npm ci + working-directory: ./src/Saunter.UI diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d262e704..b9ab2a66 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,7 +1,4 @@ -# Note: ci.yaml and release.yaml have some similar steps -# If updating dotnet-version, set in both. - -name: CI +name: ci on: push: @@ -10,32 +7,35 @@ on: pull_request: jobs: - build: + build: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 'lts/*' # latest LTS version - - uses: actions/setup-dotnet@v2 - with: - dotnet-version: | - 6.0.x - 8.0.x + - uses: actions/checkout@v2 + - name: setup build + uses: ./.github/npm + - name: Run dotnet build + run: dotnet build --configuration Debug - - name: Run NPM install - run: npm ci - working-directory: ./src/Saunter.UI - - name: Run dotnet build - run: dotnet build --configuration Debug - - name: Run dotnet test - run: dotnet test --no-build + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: setup dotnet + uses: ./.github/dotnet + - name: dotnet format check + run: dotnet format --verify-no-changes *.sln + env: + PATH: ${{ github.env.PATH }}:/home/runner/.dotnet/tools - # Below steps run only on CI, not release - - uses: actions/upload-artifact@v2 - with: - name: saunter-bin - path: ./src/Saunter/bin + unit-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: setup build + uses: ./.github/npm + - name: unit test + run: dotnet test ./test/Saunter.Tests/Saunter.Tests.csproj + # TODO: why there are 2 of them.... + - name: unit mark test + run: dotnet test ./test/Saunter.Tests.MarkerTypeTests/Saunter.Tests.MarkerTypeTests.csproj diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 836b03d9..c1c33107 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,45 +1,23 @@ -# Note: ci.yaml and release.yaml have some similar steps -# If updating dotnet-version, set in both. - name: Release on: push: tags: - - 'v*.*.*' # e.g. v0.1.0 + - "v*.*.*" # e.g. v0.1.0 jobs: release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 'lts/*' # latest LTS version - - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '6.0.x' # SDK Version to use; x will use the latest version of the channel - - - name: Run NPM install - run: npm ci - working-directory: ./src/Saunter.UI - - name: Run dotnet build - run: dotnet build --configuration Debug - - name: Run dotnet test - run: dotnet test --no-build - - # Below steps are only on release, not CI. - - name: Set version - # Gets the numeric version from a tag (e.g. v1.2.3 -> 1.2.3) - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - - name: Create Nuget package - run: dotnet pack ./src/Saunter/Saunter.csproj --configuration Release -p:Version="$RELEASE_VERSION" --output ./build - - name: Push Nuget package to Nuget.org - env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - run: dotnet nuget push ./build/*.nupkg --api-key $NUGET_API_KEY --source "https://api.nuget.org/v3/index.json" - - + - uses: actions/checkout@v2 + - name: setup build + uses: ./.github/npm + - name: Set version + # Gets the numeric version from a tag (e.g. v1.2.3 -> 1.2.3) + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + - name: Create Nuget package + run: dotnet pack ./src/Saunter/Saunter.csproj --configuration Release -p:Version="$RELEASE_VERSION" --output ./build + - name: Push Nuget package to Nuget.org + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: dotnet nuget push ./build/*.nupkg --api-key $NUGET_API_KEY --source "https://api.nuget.org/v3/index.json" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e35bd6fd..ce12592f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,11 +10,10 @@ Builds and releases managed with github actions. ### Build * Local builds are as simple as `dotnet build && dotnet test` -* CI builds on every push +* CI builds,fmt,unit on every push * [.github/workflows/ci.yaml](./.github/workflows/ci.yaml) * Build and tests MUST pass before merging to master - ### Release * Locally, packages can be created using `dotnet pack ./src/Saunter/Saunter.csproj` diff --git a/Saunter.sln b/Saunter.sln index 43967dd8..10d433bd 100644 --- a/Saunter.sln +++ b/Saunter.sln @@ -15,20 +15,34 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{6A EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetlightsAPI", "examples\StreetlightsAPI\StreetlightsAPI.csproj", "{F188D4A7-BBCB-464F-A370-2BD84D18EA79}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0D34C77-924E-4F6B-9289-5A2F07D125A8}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{E0D34C77-924E-4F6B-9289-5A2F07D125A8}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitattributes = .gitattributes CHANGELOG.md = CHANGELOG.md - .github\workflows\ci.yaml = .github\workflows\ci.yaml README.md = README.md - .github\workflows\release.yaml = .github\workflows\release.yaml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Saunter.IntegrationTests.ReverseProxy", "test\Saunter.IntegrationTests.ReverseProxy\Saunter.IntegrationTests.ReverseProxy.csproj", "{7CD09B89-130A-41AF-ADAE-2166C4ED695B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Saunter.Tests.MarkerTypeTests", "test\Saunter.Tests.MarkerTypeTests\Saunter.Tests.MarkerTypeTests.csproj", "{02284473-6DE7-4EE0-8433-2AC295045549}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "actions", "actions", "{D8CB9C0D-9605-457B-979F-C8994B20A926}" + ProjectSection(SolutionItems) = preProject + .github\workflows\ci.yaml = .github\workflows\ci.yaml + .github\workflows\release.yaml = .github\workflows\release.yaml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dotnet", "dotnet", "{69459F9D-DA73-4E84-8BA7-4CE03E2B7664}" + ProjectSection(SolutionItems) = preProject + .github\dotnet\action.yaml = .github\dotnet\action.yaml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "npm", "npm", "{E8FACA22-CFED-4710-89E4-D55F31BF96B3}" + ProjectSection(SolutionItems) = preProject + .github\npm\action.yaml = .github\npm\action.yaml + EndProjectSection +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AsyncAPI.Saunter.Generator.Cli", "src\AsyncAPI.Saunter.Generator.Cli\AsyncAPI.Saunter.Generator.Cli.csproj", "{6C102D4D-3DA4-4763-B75E-C15E33E7E94A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncAPI.Saunter.Generator.Cli.Tests", "test\AsyncAPI.Saunter.Generator.Cli.Tests\AsyncAPI.Saunter.Generator.Cli.Tests.csproj", "{18AD0249-0436-4A26-9972-B97BA6905A54}" @@ -137,6 +151,8 @@ Global {F188D4A7-BBCB-464F-A370-2BD84D18EA79} = {6ABD4842-47AF-49A5-B057-0EBA64416789} {7CD09B89-130A-41AF-ADAE-2166C4ED695B} = {6491E321-2D02-44AB-9116-D722FE169595} {02284473-6DE7-4EE0-8433-2AC295045549} = {6491E321-2D02-44AB-9116-D722FE169595} + {69459F9D-DA73-4E84-8BA7-4CE03E2B7664} = {D8CB9C0D-9605-457B-979F-C8994B20A926} + {E8FACA22-CFED-4710-89E4-D55F31BF96B3} = {D8CB9C0D-9605-457B-979F-C8994B20A926} {6C102D4D-3DA4-4763-B75E-C15E33E7E94A} = {28D4C365-FDED-49AE-A97D-36202E24A55A} {18AD0249-0436-4A26-9972-B97BA6905A54} = {6491E321-2D02-44AB-9116-D722FE169595} EndGlobalSection diff --git a/test/Saunter.Tests.MarkerTypeTests/.editorconfig b/test/Saunter.Tests.MarkerTypeTests/.editorconfig new file mode 100644 index 00000000..0f18a2dd --- /dev/null +++ b/test/Saunter.Tests.MarkerTypeTests/.editorconfig @@ -0,0 +1,7 @@ +# EditorConfig is awesome: https://EditorConfig.org + +root=false + +[*.{cs,vb}] + +dotnet_code_quality_unused_parameters = non_public diff --git a/test/Saunter.Tests/.editorconfig b/test/Saunter.Tests/.editorconfig new file mode 100644 index 00000000..0f18a2dd --- /dev/null +++ b/test/Saunter.Tests/.editorconfig @@ -0,0 +1,7 @@ +# EditorConfig is awesome: https://EditorConfig.org + +root=false + +[*.{cs,vb}] + +dotnet_code_quality_unused_parameters = non_public diff --git a/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs b/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs index 8fd8d2a3..c384d641 100644 --- a/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs +++ b/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs @@ -243,13 +243,13 @@ public interface IMyMessagePublisher public class TenantMessageConsumer { [Message(typeof(TenantCreated))] - public void SubscribeTenantCreatedEvent(Guid _, TenantCreated __) { } + public void SubscribeTenantCreatedEvent(Guid id, TenantCreated created) { } [Message(typeof(TenantUpdated))] - public void SubscribeTenantUpdatedEvent(Guid _, TenantUpdated __) { } + public void SubscribeTenantUpdatedEvent(Guid id, TenantUpdated updated) { } [Message(typeof(TenantRemoved))] - public void SubscribeTenantRemovedEvent(Guid _, TenantRemoved __) { } + public void SubscribeTenantRemovedEvent(Guid id, TenantRemoved removed) { } } [AsyncApi] @@ -273,13 +273,13 @@ public interface ITenantMessageConsumer public class TenantMessagePublisher { [Message(typeof(TenantCreated))] - public void PublishTenantCreatedEvent(Guid _, TenantCreated __) { } + public void PublishTenantCreatedEvent(Guid id, TenantCreated created) { } [Message(typeof(TenantUpdated))] - public void PublishTenantUpdatedEvent(Guid _, TenantUpdated __) { } + public void PublishTenantUpdatedEvent(Guid id, TenantUpdated updated) { } [Message(typeof(TenantRemoved))] - public void PublishTenantRemovedEvent(Guid _, TenantRemoved __) { } + public void PublishTenantRemovedEvent(Guid id, TenantRemoved removed) { } } [AsyncApi] @@ -305,7 +305,7 @@ public class TenantGenericMessagePublisher [Message(typeof(AnyTenantCreated))] [Message(typeof(AnyTenantUpdated))] [Message(typeof(AnyTenantRemoved))] - public void PublishTenantEvent(Guid _, TEvent __) + public void PublishTenantEvent(Guid id, TEvent @event) where TEvent : IEvent { } @@ -329,7 +329,7 @@ void PublishTenantEvent(Guid _, TEvent __) public class TenantSingleMessagePublisher { [Message(typeof(AnyTenantCreated))] - public void PublishTenantCreated(Guid _, AnyTenantCreated __) + public void PublishTenantCreated(Guid id, AnyTenantCreated created) { } } @@ -351,13 +351,13 @@ public interface ITenantSingleMessagePublisher public class OneTenantMessageConsumer { [Message(typeof(TenantCreated))] - public void SubscribeTenantCreatedEvent(Guid _, TenantCreated __) { } + public void SubscribeTenantCreatedEvent(Guid id, TenantCreated created) { } [Message(typeof(TenantUpdated))] - public void SubscribeTenantUpdatedEvent(Guid _, TenantUpdated __) { } + public void SubscribeTenantUpdatedEvent(Guid id, TenantUpdated updated) { } [Message(typeof(TenantRemoved))] - public void SubscribeTenantRemovedEvent(Guid _, TenantRemoved __) { } + public void SubscribeTenantRemovedEvent(Guid id, TenantRemoved removed) { } } [AsyncApi]