From 289e36fe333ec55c73bca4fff708ddb3f4e24007 Mon Sep 17 00:00:00 2001 From: glucaci Date: Mon, 2 Oct 2023 09:18:30 +0200 Subject: [PATCH 1/7] Add workflows --- .github/workflows/pull-request.yml | 29 ++++++++++++++++++++ .github/workflows/release.yml | 44 ++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .github/workflows/pull-request.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..5406574 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,29 @@ +name: Pull Request + +on: + pull_request: + branches: ['master'] + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6 + 7 + - name: Build, Test and Sonar + uses: swisslife-oss/actions/pull-request@main + with: + sonar_token: ${{ secrets.SONAR_TOKEN }} + sonar_project_key: 'SwissLife-OSS_Mongo-Extensions' + sonar_project_name: "mongo-extensions" + pr_number: ${{ github.event.pull_request.number }} + pr_source_branch: ${{ github.head_ref }} + pr_target_branch: ${{ github.base_ref }} + github_repository: ${{ github.repository }} + sonar_exclusions: ${{ vars.SONAR_EXCLUSIONS }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..213b9d3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +name: Release + +on: + push: + tags: + - "*" + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Use .NET SDK from global.json + uses: actions/setup-dotnet@v3 + - name: Build, Test and Push + uses: swisslife-oss/actions/release-packages@main + with: + tag: ${{ github.ref_name }} + nuget_api_key: ${{ secrets.NUGET_API_KEY }} + enable_push: 'yes' + + sonar: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6 + 7 + - name: Restore tools + run: dotnet tool restore + - name: Build, Test and Sonar + uses: swisslife-oss/actions/release-sonar@main + with: + tag: ${{ github.ref_name }} + sonar_token: ${{ secrets.SONAR_TOKEN }} + sonar_project_key: 'SwissLife-OSS_Mongo-Extensions' + sonar_project_name: "mongo-extensions" + sonar_exclusions: ${{ vars.SONAR_EXCLUSIONS }} From fd7e6388979ddb6d5262f000fdd938239e55aca8 Mon Sep 17 00:00:00 2001 From: glucaci Date: Mon, 2 Oct 2023 09:30:12 +0200 Subject: [PATCH 2/7] Update sonar-scanner --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 0345240..35006f4 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-sonarscanner": { - "version": "4.8.0", + "version": "5.13.1", "commands": [ "dotnet-sonarscanner" ] From 2f5aa803169e9cc6eb252056d38fd6eed8946985 Mon Sep 17 00:00:00 2001 From: glucaci Date: Mon, 2 Oct 2023 09:40:35 +0200 Subject: [PATCH 3/7] Order dependenties in test --- src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs b/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs index 86d91bf..4519f38 100644 --- a/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs +++ b/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs @@ -13,8 +13,8 @@ public static object GetTypeObjectSerializerContent() AllowedTypes = TypeObjectSerializer.AllowedTypes .Select(pair => new KeyValuePair(pair.Key.FullName, pair.Value)) .OrderBy(pair => pair.Key), - TypeObjectSerializer.AllowedTypesByNamespaces, - TypeObjectSerializer.AllowedTypesByDependencies + AllowedTypesByNamespaces = TypeObjectSerializer.AllowedTypesByNamespaces.OrderBy(x => x), + AllowedTypesByDependencies = TypeObjectSerializer.AllowedTypesByDependencies.OrderBy(x => x) }; } } From e5f08677341fb791887c9b404dd2d37371daa9e2 Mon Sep 17 00:00:00 2001 From: glucaci Date: Mon, 2 Oct 2023 09:42:33 +0200 Subject: [PATCH 4/7] Fix snapshots --- ...AllowedTypesOfAllDependencies_Success.snap | 22 +++++++++---------- ...AllowedTypesOfAllDependencies_Success.snap | 22 +++++++++---------- ...wed_InAllowedTypesInDependencies_True.snap | 22 +++++++++---------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Context.AllowedTypes.Tests/__snapshots__/MongoDatabaseBuilderTests.AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success.snap b/src/Context.AllowedTypes.Tests/__snapshots__/MongoDatabaseBuilderTests.AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success.snap index 86c92ba..00b573e 100644 --- a/src/Context.AllowedTypes.Tests/__snapshots__/MongoDatabaseBuilderTests.AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success.snap +++ b/src/Context.AllowedTypes.Tests/__snapshots__/MongoDatabaseBuilderTests.AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success.snap @@ -2,26 +2,26 @@ "AllowedTypes": [], "AllowedTypesByNamespaces": [], "AllowedTypesByDependencies": [ - "Newtonsoft", - "Internal", - "Xunit", - "NuGet", - "MongoDB", - "Squadron", - "ThirdParty", - "AWSSDK", "Amazon", + "AWSSDK", "Castle", "DnsClient", "Docker", "FluentAssertions", - "SharpCompress", - "TypeNameFormatter", + "ICSharpCode", + "Internal", + "MongoDB", "Moq", + "Newtonsoft", + "NuGet", "Polly", - "ICSharpCode", + "SharpCompress", "Snappier", "Snapshooter", + "Squadron", + "ThirdParty", + "TypeNameFormatter", + "Xunit", "ZstdSharp" ] } diff --git a/src/Context.AllowedTypes.Tests/__snapshots__/TypeObjectSerializerTests.AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success.snap b/src/Context.AllowedTypes.Tests/__snapshots__/TypeObjectSerializerTests.AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success.snap index 86c92ba..00b573e 100644 --- a/src/Context.AllowedTypes.Tests/__snapshots__/TypeObjectSerializerTests.AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success.snap +++ b/src/Context.AllowedTypes.Tests/__snapshots__/TypeObjectSerializerTests.AddAllowedTypes_AddAllowedTypesOfAllDependencies_Success.snap @@ -2,26 +2,26 @@ "AllowedTypes": [], "AllowedTypesByNamespaces": [], "AllowedTypesByDependencies": [ - "Newtonsoft", - "Internal", - "Xunit", - "NuGet", - "MongoDB", - "Squadron", - "ThirdParty", - "AWSSDK", "Amazon", + "AWSSDK", "Castle", "DnsClient", "Docker", "FluentAssertions", - "SharpCompress", - "TypeNameFormatter", + "ICSharpCode", + "Internal", + "MongoDB", "Moq", + "Newtonsoft", + "NuGet", "Polly", - "ICSharpCode", + "SharpCompress", "Snappier", "Snapshooter", + "Squadron", + "ThirdParty", + "TypeNameFormatter", + "Xunit", "ZstdSharp" ] } diff --git a/src/Context.AllowedTypes.Tests/__snapshots__/TypeObjectSerializerTests.IsTypeAllowed_InAllowedTypesInDependencies_True.snap b/src/Context.AllowedTypes.Tests/__snapshots__/TypeObjectSerializerTests.IsTypeAllowed_InAllowedTypesInDependencies_True.snap index 25fdb9b..313d766 100644 --- a/src/Context.AllowedTypes.Tests/__snapshots__/TypeObjectSerializerTests.IsTypeAllowed_InAllowedTypesInDependencies_True.snap +++ b/src/Context.AllowedTypes.Tests/__snapshots__/TypeObjectSerializerTests.IsTypeAllowed_InAllowedTypesInDependencies_True.snap @@ -7,26 +7,26 @@ ], "AllowedTypesByNamespaces": [], "AllowedTypesByDependencies": [ - "Newtonsoft", - "Internal", - "Xunit", - "NuGet", - "MongoDB", - "Squadron", - "ThirdParty", - "AWSSDK", "Amazon", + "AWSSDK", "Castle", "DnsClient", "Docker", "FluentAssertions", - "SharpCompress", - "TypeNameFormatter", + "ICSharpCode", + "Internal", + "MongoDB", "Moq", + "Newtonsoft", + "NuGet", "Polly", - "ICSharpCode", + "SharpCompress", "Snappier", "Snapshooter", + "Squadron", + "ThirdParty", + "TypeNameFormatter", + "Xunit", "ZstdSharp" ] } From 1c0e402a14f34376cec5779bb9fa222efa364d3f Mon Sep 17 00:00:00 2001 From: glucaci Date: Mon, 2 Oct 2023 10:26:30 +0200 Subject: [PATCH 5/7] Try fix tests --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index cb39fc4..fee7b03 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,13 +7,13 @@ - + - + From 1e36d9000027b46d6dd34e1aca809f0183f9964f Mon Sep 17 00:00:00 2001 From: glucaci Date: Mon, 2 Oct 2023 10:32:52 +0200 Subject: [PATCH 6/7] Update packages and exclude Coverlet --- Directory.Packages.props | 4 ++-- src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index fee7b03..a953b83 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,9 +6,9 @@ - + - + diff --git a/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs b/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs index 4519f38..3abf2ba 100644 --- a/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs +++ b/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs @@ -13,8 +13,11 @@ public static object GetTypeObjectSerializerContent() AllowedTypes = TypeObjectSerializer.AllowedTypes .Select(pair => new KeyValuePair(pair.Key.FullName, pair.Value)) .OrderBy(pair => pair.Key), - AllowedTypesByNamespaces = TypeObjectSerializer.AllowedTypesByNamespaces.OrderBy(x => x), - AllowedTypesByDependencies = TypeObjectSerializer.AllowedTypesByDependencies.OrderBy(x => x) + AllowedTypesByNamespaces = TypeObjectSerializer.AllowedTypesByNamespaces + .OrderBy(x => x), + AllowedTypesByDependencies = TypeObjectSerializer.AllowedTypesByDependencies + .OrderBy(x => x) + .Except(new[] { "Coverlet" }) }; } } From 01d1776dee27e5547c56c36e13e574c841251bf9 Mon Sep 17 00:00:00 2001 From: glucaci Date: Mon, 2 Oct 2023 10:38:14 +0200 Subject: [PATCH 7/7] Fix --- src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs | 2 +- .../Internal/DependencyTypesResolverTests.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs b/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs index 3abf2ba..fad2d47 100644 --- a/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs +++ b/src/Context.AllowedTypes.Tests/Helpers/TestHelpers.cs @@ -16,8 +16,8 @@ public static object GetTypeObjectSerializerContent() AllowedTypesByNamespaces = TypeObjectSerializer.AllowedTypesByNamespaces .OrderBy(x => x), AllowedTypesByDependencies = TypeObjectSerializer.AllowedTypesByDependencies - .OrderBy(x => x) .Except(new[] { "Coverlet" }) + .OrderBy(x => x) }; } } diff --git a/src/Context.Tests/Internal/DependencyTypesResolverTests.cs b/src/Context.Tests/Internal/DependencyTypesResolverTests.cs index 4978f80..415eca2 100644 --- a/src/Context.Tests/Internal/DependencyTypesResolverTests.cs +++ b/src/Context.Tests/Internal/DependencyTypesResolverTests.cs @@ -13,10 +13,12 @@ public void GetAllowedTypesByDependencies_All_Successful() // Arrange // Act - IEnumerable knownNamespaces = - DependencyTypesResolver.GetAllowedTypesByDependencies(); + IEnumerable knownNamespaces = DependencyTypesResolver + .GetAllowedTypesByDependencies() + .Except(new[] { "Coverlet" }) + .OrderBy(x => x); // Assert - Snapshot.Match(knownNamespaces.OrderBy(x => x)); + Snapshot.Match(knownNamespaces); } }