Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 33 additions & 28 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,40 @@ jobs:
- name: Check formatting
run: dotnet csharpier . --check
- name: Build
run: dotnet build --no-restore
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet msbuild -t:RunTests -p:Configuration=Release -p:LogFileName="$PWD/../TestResults/tests.trx"
working-directory: ./backend/tests
run: dotnet test --project ./tests/LeanCode.AppRating.Tests/LeanCode.AppRating.Tests.csproj --no-build --configuration Release
- name: Integration Test SqlServer
run: |
dotnet test \
./tests/LeanCode.AppRating.IntegrationTests/LeanCode.AppRating.IntegrationTests.csproj \
--no-build \
--logger "trx;LogFileName=LeanCode.AppRating.IntegrationTests.trx" \
--results-directory TestResults
run: >
dotnet test
--project ./tests/LeanCode.AppRating.IntegrationTests/LeanCode.AppRating.IntegrationTests.csproj
--no-build
--configuration Release
env:
AppReviewIntegrationTests__Database: sqlserver
SqlServer__ConnectionStringBase: Server=localhost,1433;User Id=sa;Password=Passw12#;Encrypt=false
- name: Integration Test Postgres
run: |
dotnet test \
./tests/LeanCode.AppRating.IntegrationTests/LeanCode.AppRating.IntegrationTests.csproj \
--no-build \
--logger "trx;LogFileName=LeanCode.AppRating.IntegrationTests.Postgres.trx" \
--results-directory TestResults
run: >
dotnet test
--project ./tests/LeanCode.AppRating.IntegrationTests/LeanCode.AppRating.IntegrationTests.csproj
--no-build
--configuration Release
env:
AppReviewIntegrationTests__Database: postgres
Postgres__ConnectionStringBase: Host=localhost;Username=postgres;Password=Passw12#
- name: Process test results
if: always()
run: |
# Strip BOM from JSON files
find TestResults -name '*.json' | xargs -n 1 sed -i "$(printf '1s/^\357\273\277//')"
# Merge coverage XML files
dotnet coverage merge TestResults/*.xml -o TestResults/cobertura.xml -f cobertura
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test_results.zip
path: backend/TestResults/*.trx
name: test_results
path: backend/TestResults/*.json
- name: Pack AppRating Contracts
if: ${{ steps.version.outputs.publish_artifacts == '1' }}
env:
Expand Down Expand Up @@ -165,16 +169,17 @@ jobs:
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Extract Artifacts
run: |
for file in artifacts/*.zip; do
if [[ -f "$file" ]]; then
dir="${file%.zip}"
mkdir -p "$dir"
unzip -d "$dir" "$file"
fi
done
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
uses: ctrf-io/github-test-reporter@v1
if: always()
with:
trx_files: "artifacts/*/**/*.trx"
report-path: 'artifacts/**/*.json'
summary-report: true
failed-folded-report: true
skipped-report: true
annotate: true
pull-request: true
overwrite-comment: true
comment-tag: '${{ github.workflow }}-${{ github.job }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions backend/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"commands": [
"dotnet-csharpier"
]
},
"dotnet-coverage": {
"version": "18.1.0",
"commands": [
"dotnet-coverage"
],
"rollForward": false
}
}
}
107 changes: 50 additions & 57 deletions backend/AppRating.sln
Original file line number Diff line number Diff line change
@@ -1,57 +1,50 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B064771B-94C3-4381-A71A-7A87430A4944}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.AppRating.Contracts", "src\LeanCode.AppRating.Contracts\LeanCode.AppRating.Contracts.csproj", "{1D2F7D13-C795-442D-BA47-9B39C5600A4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.AppRating", "src\LeanCode.AppRating\LeanCode.AppRating.csproj", "{40981EB9-9E59-4343-80B8-6018756292F9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{97A2C575-49D9-43DF-90EE-8C8CCF5501E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.AppRating.IntegrationTests", "tests\LeanCode.AppRating.IntegrationTests\LeanCode.AppRating.IntegrationTests.csproj", "{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.AppRating.Tests", "tests\LeanCode.AppRating.Tests\LeanCode.AppRating.Tests.csproj", "{D87B5D62-C854-4173-8C16-4440A33272CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "tests\Tests.csproj", "{45468519-C690-4AA1-AE99-4DC9445DBF79}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1D2F7D13-C795-442D-BA47-9B39C5600A4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D2F7D13-C795-442D-BA47-9B39C5600A4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D2F7D13-C795-442D-BA47-9B39C5600A4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D2F7D13-C795-442D-BA47-9B39C5600A4C}.Release|Any CPU.Build.0 = Release|Any CPU
{40981EB9-9E59-4343-80B8-6018756292F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40981EB9-9E59-4343-80B8-6018756292F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40981EB9-9E59-4343-80B8-6018756292F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40981EB9-9E59-4343-80B8-6018756292F9}.Release|Any CPU.Build.0 = Release|Any CPU
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}.Release|Any CPU.Build.0 = Release|Any CPU
{D87B5D62-C854-4173-8C16-4440A33272CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D87B5D62-C854-4173-8C16-4440A33272CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D87B5D62-C854-4173-8C16-4440A33272CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D87B5D62-C854-4173-8C16-4440A33272CA}.Release|Any CPU.Build.0 = Release|Any CPU
{45468519-C690-4AA1-AE99-4DC9445DBF79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45468519-C690-4AA1-AE99-4DC9445DBF79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45468519-C690-4AA1-AE99-4DC9445DBF79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45468519-C690-4AA1-AE99-4DC9445DBF79}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1D2F7D13-C795-442D-BA47-9B39C5600A4C} = {B064771B-94C3-4381-A71A-7A87430A4944}
{40981EB9-9E59-4343-80B8-6018756292F9} = {B064771B-94C3-4381-A71A-7A87430A4944}
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4} = {97A2C575-49D9-43DF-90EE-8C8CCF5501E6}
{D87B5D62-C854-4173-8C16-4440A33272CA} = {97A2C575-49D9-43DF-90EE-8C8CCF5501E6}
{45468519-C690-4AA1-AE99-4DC9445DBF79} = {97A2C575-49D9-43DF-90EE-8C8CCF5501E6}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B064771B-94C3-4381-A71A-7A87430A4944}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.AppRating.Contracts", "src\LeanCode.AppRating.Contracts\LeanCode.AppRating.Contracts.csproj", "{1D2F7D13-C795-442D-BA47-9B39C5600A4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.AppRating", "src\LeanCode.AppRating\LeanCode.AppRating.csproj", "{40981EB9-9E59-4343-80B8-6018756292F9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{97A2C575-49D9-43DF-90EE-8C8CCF5501E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.AppRating.IntegrationTests", "tests\LeanCode.AppRating.IntegrationTests\LeanCode.AppRating.IntegrationTests.csproj", "{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeanCode.AppRating.Tests", "tests\LeanCode.AppRating.Tests\LeanCode.AppRating.Tests.csproj", "{D87B5D62-C854-4173-8C16-4440A33272CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1D2F7D13-C795-442D-BA47-9B39C5600A4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D2F7D13-C795-442D-BA47-9B39C5600A4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D2F7D13-C795-442D-BA47-9B39C5600A4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D2F7D13-C795-442D-BA47-9B39C5600A4C}.Release|Any CPU.Build.0 = Release|Any CPU
{40981EB9-9E59-4343-80B8-6018756292F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40981EB9-9E59-4343-80B8-6018756292F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40981EB9-9E59-4343-80B8-6018756292F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40981EB9-9E59-4343-80B8-6018756292F9}.Release|Any CPU.Build.0 = Release|Any CPU
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4}.Release|Any CPU.Build.0 = Release|Any CPU
{D87B5D62-C854-4173-8C16-4440A33272CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D87B5D62-C854-4173-8C16-4440A33272CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D87B5D62-C854-4173-8C16-4440A33272CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D87B5D62-C854-4173-8C16-4440A33272CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1D2F7D13-C795-442D-BA47-9B39C5600A4C} = {B064771B-94C3-4381-A71A-7A87430A4944}
{40981EB9-9E59-4343-80B8-6018756292F9} = {B064771B-94C3-4381-A71A-7A87430A4944}
{223CAEBC-F4DD-424B-91EB-8DF38F8E71A4} = {97A2C575-49D9-43DF-90EE-8C8CCF5501E6}
{D87B5D62-C854-4173-8C16-4440A33272CA} = {97A2C575-49D9-43DF-90EE-8C8CCF5501E6}
EndGlobalSection
EndGlobal
6 changes: 3 additions & 3 deletions backend/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
<PackageReference Update="LeanCode.IntegrationTestHelpers" Version="$(CoreLibVersion)" />
<PackageReference Update="LeanCode.Startup.MicrosoftDI" Version="$(CoreLibVersion)" />
<PackageReference Update="Microsoft.EntityFrameworkCore.SqlServer" Version="$(EFCoreVersion)" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="18.0.1"/>
<PackageReference Update="Microsoft.Testing.Extensions.CodeCoverage" Version="18.1.0" />
<PackageReference Update="NSubstitute" Version="5.3.0" />
<PackageReference Update="xunit" Version="2.9.3" />
<PackageReference Update="xunit.runner.visualstudio" Version="3.1.5" />
<PackageReference Update="coverlet.collector" Version="6.0.4" />
<PackageReference Update="xunit.analyzers" Version="1.25.0" />
<PackageReference Update="xunit.v3.mtp-v2" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 10 additions & 0 deletions backend/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"sdk": {
"version": "10.0.100",
"allowPrerelease": false,
"rollForward": "latestMinor"
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
26 changes: 26 additions & 0 deletions backend/tests/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project>
<Import
Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"
Condition="Exists($([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../')))"
/>

<PropertyGroup>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<NoWarn>$(NoWarn);xUnit1051</NoWarn>
</PropertyGroup>

<PropertyGroup>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<!-- All arguments must be on a single line to avoid parsing issues with newlines -->
<!-- csharpier-ignore -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-ctrf --coverage --ignore-exit-code 8 --results-directory $(MSBuildThisFileDirectory)/../TestResults --coverage-output-format cobertura --coverage-settings $(MSBuildThisFileDirectory)/coverage.xml --report-ctrf-filename $(MSBuildProjectName)-$([System.DateTime]::Now.ToString("HH-mm-ss")).json --coverage-output $(MSBuildProjectName)-$([System.DateTime]::Now.ToString("HH-mm-ss")).xml</TestingPlatformCommandLineArguments>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="xunit.analyzers" />
<PackageReference Include="xunit.v3.mtp-v2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
Expand All @@ -12,16 +11,11 @@
<PackageReference Include="LeanCode.IntegrationTestHelpers" />
<PackageReference Include="LeanCode.Startup.MicrosoftDI" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="coverlet.collector" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../src/LeanCode.AppRating/LeanCode.AppRating.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public TestsBase()
App = new();
}

Task IAsyncLifetime.InitializeAsync() => App.InitializeAsync().AsTask();
ValueTask IAsyncLifetime.InitializeAsync() => App.InitializeAsync();

Task IAsyncLifetime.DisposeAsync() => App.DisposeAsync().AsTask();
ValueTask IAsyncDisposable.DisposeAsync() => App.DisposeAsync();

void IDisposable.Dispose() => App.Dispose();
}
Expand Down Expand Up @@ -55,7 +55,7 @@ private static ClaimsPrincipal GetClaimsPrincipal(Guid userId)
{
return new ClaimsPrincipal(
new ClaimsIdentity(
new Claim[] { new(KnownClaims.UserId, userId.ToString()), new(KnownClaims.Role, Roles.User), },
new Claim[] { new(KnownClaims.UserId, userId.ToString()), new(KnownClaims.Role, Roles.User) },
TestAuthenticationHandler.SchemeName,
KnownClaims.UserId,
KnownClaims.Role
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="../../src/LeanCode.AppRating/LeanCode.AppRating.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>

</Project>
29 changes: 0 additions & 29 deletions backend/tests/Tests.csproj

This file was deleted.

11 changes: 11 additions & 0 deletions backend/tests/coverage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*Tests\.dll$</ModulePath>
<ModulePath>.*\.IntegrationTests\.dll$</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>