diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25870ca..e3bb411 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/src/AspNetCore/test/AspNetCore.Tests.csproj b/src/AspNetCore/test/AspNetCore.Tests.csproj index ef0100d..5ac8c6c 100644 --- a/src/AspNetCore/test/AspNetCore.Tests.csproj +++ b/src/AspNetCore/test/AspNetCore.Tests.csproj @@ -10,9 +10,13 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + all diff --git a/src/Common/test/Common.Tests.csproj b/src/Common/test/Common.Tests.csproj index 2c3205a..94f0db4 100644 --- a/src/Common/test/Common.Tests.csproj +++ b/src/Common/test/Common.Tests.csproj @@ -6,8 +6,12 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + diff --git a/src/Email/test/Email.Tests.csproj b/src/Email/test/Email.Tests.csproj index a79f608..1ab84f1 100644 --- a/src/Email/test/Email.Tests.csproj +++ b/src/Email/test/Email.Tests.csproj @@ -7,9 +7,13 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - - + + @@ -18,9 +22,9 @@ - - - + + + diff --git a/src/Hangfire/test/Hangfire.Tests.csproj b/src/Hangfire/test/Hangfire.Tests.csproj index 95742e7..75f3243 100644 --- a/src/Hangfire/test/Hangfire.Tests.csproj +++ b/src/Hangfire/test/Hangfire.Tests.csproj @@ -6,7 +6,11 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + @@ -15,7 +19,7 @@ - + diff --git a/src/Hosting/test/Hosting.Tests.csproj b/src/Hosting/test/Hosting.Tests.csproj index 10c44a3..263c664 100644 --- a/src/Hosting/test/Hosting.Tests.csproj +++ b/src/Hosting/test/Hosting.Tests.csproj @@ -8,14 +8,14 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/UnitTests/test/UnitTests.Tests.csproj b/src/UnitTests/test/UnitTests.Tests.csproj index f078076..b93213f 100644 --- a/src/UnitTests/test/UnitTests.Tests.csproj +++ b/src/UnitTests/test/UnitTests.Tests.csproj @@ -6,7 +6,11 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + @@ -15,7 +19,7 @@ - + diff --git a/src/Validation/test/Validation.Tests.csproj b/src/Validation/test/Validation.Tests.csproj index b35c8e8..b2209df 100644 --- a/src/Validation/test/Validation.Tests.csproj +++ b/src/Validation/test/Validation.Tests.csproj @@ -6,8 +6,12 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - +