Skip to content

Commit

Permalink
Updated pipeline to include test results and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jhartmann123 authored and davidroth committed Mar 29, 2021
1 parent 098e97a commit 4e1776d
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 41 deletions.
93 changes: 66 additions & 27 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,73 @@
image: mcr.microsoft.com/dotnet/sdk:5.0
stages:
- test
- build
- publish
- build
- test
- publish

test:
stage: test
script:
- dotnet test Extensions.sln
default:
interruptible: true

build:
stage: build
before_script:
# Workaround for SourceLink: See: https://github.com/dotnet/sourcelink/issues/689
- git config url."https://github.com/fusonic/dotnet-extensions".insteadOf https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/fusonic/devops/dotnet/extensions
script:
- dotnet pack -c Release
artifacts:
when: on_success
paths:
- ./src/*/src/bin/Release/*.nupkg
- ./src/*/src/bin/Release/*.snupkg
stage: build
before_script:
# Workaround for SourceLink: See: https://github.com/dotnet/sourcelink/issues/689
- git config url."https://github.com/fusonic/dotnet-extensions".insteadOf https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/fusonic/devops/dotnet/extensions
script:
- dotnet pack -c Release
artifacts:
when: on_success
paths:
- ./src/*/src/bin/Release/*.nupkg
- ./src/*/src/bin/Release/*.snupkg

test:
stage: test
needs: []
script:
- set +e
- dotnet test -l 'trx;LogFileName=TestOutput.trx' -l 'console;verbosity=detailed' --collect:"XPlat Code Coverage" Extensions.sln
- export DOTNET_TEST_EXIT_CODE=$?
- set -e
# Install tools required for reports
- export PATH="$PATH:/root/.dotnet/tools"
- dotnet tool install -g dotnet-reportgenerator-globaltool
- dotnet tool install -g trx2junit
# Generate code coverage report
- reportgenerator "-reports:src/**/TestResults/*/coverage.cobertura.xml" "-targetdir:reports/dotnetcoverage"
- cat reports/dotnetcoverage/index.htm | grep "Line coverage" | head -1
# Convert trx to the JUnit format. This is used for the test results in the MR.
- mkdir testresults
- find . -iname "TestOutput*.trx" -exec sh -c 'echo ${} | rev | cut -d / -f3 | rev | sed -e s/$/.trx/ | { read OUTPUT; echo "{} -> $OUTPUT"; mv {} testresults/$OUTPUT; } ' \;
- cd testresults
- trx2junit *.trx
- exit $DOTNET_TEST_EXIT_CODE
artifacts:
when: always
paths:
- reports/dotnetcoverage
reports:
junit: testresults/*.xml
cobertura: src/**/TestResults/*/coverage.cobertura.xml
coverage: /.*Line coverage.*?(\d{1,3}\.?\d*)%.*/

pages:
stage: publish
needs: [ test ]
script:
- mv reports/dotnetcoverage public
artifacts:
paths:
- public
only:
- master

publish:
variables:
GIT_STRATEGY: none
stage: publish
script:
- dotnet nuget push "src/**/src/bin/Release/*.nupkg" -k $Nuget_Key -s https://api.nuget.org/v3/index.json --skip-duplicate
when: manual
only:
- /^release\/.*$/
- master
variables:
GIT_STRATEGY: none
stage: publish
script:
- dotnet nuget push "src/**/src/bin/Release/*.nupkg" -k $Nuget_Key -s https://api.nuget.org/v3/index.json --skip-duplicate
when: manual
only:
- /^release\/.*$/
- master
6 changes: 5 additions & 1 deletion src/AspNetCore/test/AspNetCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
6 changes: 5 additions & 1 deletion src/Common/test/Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
14 changes: 9 additions & 5 deletions src/Email/test/Email.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="netDumbster" Version="2.0.0.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="netDumbster" Version="2.0.0.8" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand All @@ -18,9 +22,9 @@
</PackageReference>
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="SimpleInjector" Version="5.2.0" />
<PackageReference Include="SimpleInjector.Integration.AspNetCore" Version="5.2.0" />
<PackageReference Include="SimpleInjector.Integration.AspNetCore.Mvc.Core" Version="5.2.0" />
<PackageReference Include="SimpleInjector" Version="5.3.0" />
<PackageReference Include="SimpleInjector.Integration.AspNetCore" Version="5.3.0" />
<PackageReference Include="SimpleInjector.Integration.AspNetCore.Mvc.Core" Version="5.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 6 additions & 2 deletions src/Hangfire/test/Hangfire.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand All @@ -15,7 +19,7 @@
</PackageReference>
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="SimpleInjector" Version="5.2.0" />
<PackageReference Include="SimpleInjector" Version="5.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Hosting/test/Hosting.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PackageReference Include="coverlet.collector" Version="3.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
8 changes: 6 additions & 2 deletions src/UnitTests/test/UnitTests.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand All @@ -15,7 +19,7 @@
</PackageReference>
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="SimpleInjector" Version="5.2.0" />
<PackageReference Include="SimpleInjector" Version="5.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 5 additions & 1 deletion src/Validation/test/Validation.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down

0 comments on commit 4e1776d

Please sign in to comment.