Skip to content

Commit

Permalink
Merge pull request #327 from MangoInstantMessenger/gh-actions-coverage
Browse files Browse the repository at this point in the history
Gh actions coverage
  • Loading branch information
kolosovpetro authored Jan 6, 2023
2 parents 05009fb + 63022e6 commit dfc9f04
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 22 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build-test-coverage-dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build Test Coverage

on:
push:
branches:
- develop
- gh-actions-coverage

pull_request:
branches: [ develop ]

workflow_dispatch:

jobs:
build-and-test-dotnet:
name: Build Test Coverage
runs-on: ubuntu-latest

steps:
- name: Fetch Sources
uses: actions/checkout@v3

- name: Setup .NET 6.0 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

- name: Restore Nuget Packages
run: dotnet restore

- name: Build .NET Project
run: |
dotnet build --no-restore /p:ContinuousIntegrationBuild=true --configuration Release
- name: Install and Run Azurite
run: |
npm install -g azurite
mkdir azurite
azurite --silent --location azurite --debug azurite\debug.log &
- name: Run SQLServer docker container
run: |
docker run -e 'SA_PASSWORD=x2yiJt!Fs' -e ACCEPT_EULA=y --name mango-mssql-db --hostname mango-mssql-db -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
- name: Wait for container
run: pwsh ./scripts/wait_database.ps1

- name: Run Integration Tests
run: |
dotnet test MangoAPI.IntegrationTests/MangoAPI.IntegrationTests.csproj --configuration Release --no-build
env:
CollectCoverage: true
CoverletOutputFormat: lcov
ThresholdStat: total
ThresholdType: Line
CoverletOutput: TestResults/
# dotnet test MangoAPI.IntegrationTests/MangoAPI.IntegrationTests.csproj -p:CollectCoverage=true -p:CoverletOutput=TestResults/ -p:CoverletOutputFormat=lcov

- name: Publish coverage report to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: 'MangoAPI.IntegrationTests/TestResults/coverage.info'

- name: Publish .NET Project
run: |
dotnet publish "MangoAPI.Presentation/MangoAPI.Presentation.csproj" --configuration "Release" --output "publish"
- name: Drop Artifact
uses: actions/upload-artifact@v3
with:
name: 'drop'
path: 'publish'
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<CodeAnalysisRuleSet>..\stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<!-- Exclude the project from coverage report -->
<ItemGroup>
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"/>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>./bin/MangoAPI.DiffieHellmanConsole.xml</DocumentationFile>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<CodeAnalysisRuleSet>..\stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<!-- Exclude the project from coverage report -->
<ItemGroup>
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"/>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>./bin/MangoAPI.DiffieHellmanLibrary.xml</DocumentationFile>
</PropertyGroup>
Expand All @@ -16,13 +21,13 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\MangoAPI.BusinessLogic\MangoAPI.BusinessLogic.csproj" />
<ProjectReference Include="..\MangoAPI.Domain\MangoAPI.Domain.csproj" />
<ProjectReference Include="..\MangoAPI.BusinessLogic\MangoAPI.BusinessLogic.csproj"/>
<ProjectReference Include="..\MangoAPI.Domain\MangoAPI.Domain.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="CliWrap" Version="3.5.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="CliWrap" Version="3.5.0"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
17 changes: 11 additions & 6 deletions MangoAPI.Infrastructure/MangoAPI.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@
<SonarQubeExclude>true</SonarQubeExclude>
</PropertyGroup>

<!-- Exclude the project from coverage report -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.10" />
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MangoAPI.Application\MangoAPI.Application.csproj" />
<ProjectReference Include="..\MangoAPI.Domain\MangoAPI.Domain.csproj" />
<ProjectReference Include="..\MangoAPI.Application\MangoAPI.Application.csproj"/>
<ProjectReference Include="..\MangoAPI.Domain\MangoAPI.Domain.csproj"/>
</ItemGroup>

</Project>
14 changes: 7 additions & 7 deletions MangoAPI.IntegrationTests/MangoAPI.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\MangoAPI.BusinessLogic\MangoAPI.BusinessLogic.csproj" />
<ProjectReference Include="..\MangoAPI.BusinessLogic\MangoAPI.BusinessLogic.csproj"/>
</ItemGroup>

<ItemGroup>
Expand All @@ -30,23 +30,23 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="6.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Respawn" Version="6.0.0" />
<PackageReference Include="FluentAssertions" Version="6.8.0"/>
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="6.0.10"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"/>
<PackageReference Include="Respawn" Version="6.0.0"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Folder Include="Files" />
<Folder Include="Files"/>
</ItemGroup>

</Project>
13 changes: 9 additions & 4 deletions MangoAPI.Presentation/MangoAPI.Presentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<CodeAnalysisRuleSet>..\stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<!-- Exclude the project from coverage report -->
<ItemGroup>
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"/>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>./bin/MangoAPI.Presentation.xml</DocumentationFile>
</PropertyGroup>
Expand All @@ -17,13 +22,13 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\MangoAPI.BusinessLogic\MangoAPI.BusinessLogic.csproj" />
<ProjectReference Include="..\MangoAPI.BusinessLogic\MangoAPI.BusinessLogic.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.10" />
<PackageReference Include="AutoMapper" Version="12.0.0"/>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.10"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions MangoAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
ProjectSection(SolutionItems) = preProject
.github\workflows\run-cng-dh-handshake.yml = .github\workflows\run-cng-dh-handshake.yml
.github\workflows\run-openssl-dh-handshake.yml = .github\workflows\run-openssl-dh-handshake.yml
.github\workflows\build-test-coverage-dotnet.yml = .github\workflows\build-test-coverage-dotnet.yml
EndProjectSection
EndProject
Global
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ Obligatory required software:
- **NodeJS:** `16.13.1`
- **NPM:** `8.1.2`
- **Code Editor or IDE:** Visual studio, Visual studio code, Rider
- **For Visual studio code:** [ESlint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) plugins (also included in the workspace recommendations)
- **For Visual studio code:** [ESlint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) plugins (also included in
the workspace recommendations)

### Run in debug mode

Expand Down Expand Up @@ -166,6 +168,7 @@ Version control to be organized as follows:

- Trello: https://trello.com/b/Z7IlfrRb/mango-messenger-trello
- Database diagram: https://dbdiagram.io/d/60d66a13dd6a597148203e6b
- How to exclude project from coverage: https://codyanhorn.tech/blog/excluding-your-net-test-project-from-code-coverage

## Logo Attribution

Expand Down

0 comments on commit dfc9f04

Please sign in to comment.