From 0b39af1b42ab3cafcee4c96ff36db7db563de162 Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Sun, 8 Nov 2020 18:27:41 +0100 Subject: [PATCH 1/3] another sample of use to README file --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 32d8805..11a04de 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,41 @@ Also includes test results. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` +## Include code coverage with [Coverlet](https://github.com/coverlet-coverage/coverlet) + +To `MyProject.Test` add a Nuget packages `coverlet.msbuild` and `coverlet.collector`. + +Here is a full example of Github Action yml file where code coverage report is generated and uploaded to SonarQube.io. + +``` yaml +name: Sonarqube Analyze +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: SonarScanner for .NET Core with pull request decoration support + uses: highbyte/sonarscan-dotnet@1.0 + with: + sonarProjectKey: your_projectkey + sonarProjectName: your_projectname + sonarOrganization: your_organization + dotnetBuildArguments: ./src/MyProject/MyProject.csproj + dotnetTestArguments: ./src/MyProject.Test/MyProject.Test.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover + sonarBeginArguments: /d:sonar.verbose="true" /d:sonar.language="cs" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +``` + ## Build subfolder src, and include code coverage Also includes test results. From 88f14cf7870821923aedaea5e2fbfd14a53528ed Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Thu, 12 Nov 2020 21:37:06 +0100 Subject: [PATCH 2/3] Install 3.1 and 5.0 runtime with 3.1 LTS dotnet --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5002a1b..f641462 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.1.403 +FROM mcr.microsoft.com/dotnet/sdk:3.1 LABEL "com.github.actions.name"="sonarscan-dotnet" LABEL "com.github.actions.description"="Sonarscanner for .NET Core with pull request decoration support." @@ -11,7 +11,8 @@ LABEL "maintainer"="Highbyte" # Version numbers of used software ENV SONAR_SCANNER_DOTNET_TOOL_VERSION=4.10.0 \ - DOTNETCORE_RUNTIME_VERSION=3.1 \ + DOTNETCORE_RUNTIME_VERSION_3=3.1 \ + DOTNETCORE_RUNTIME_VERSION_5=5.0 \ JRE_VERSION=11 # Add Microsoft Debian apt-get feed @@ -24,7 +25,8 @@ RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod RUN apt-get update -y \ && apt-get install --no-install-recommends -y apt-transport-https \ && apt-get update -y \ - && apt-get install --no-install-recommends -y aspnetcore-runtime-$DOTNETCORE_RUNTIME_VERSION + && apt-get install --no-install-recommends -y aspnetcore-runtime-$DOTNETCORE_RUNTIME_VERSION_3 \ + && apt-get install --no-install-recommends -y aspnetcore-runtime-$DOTNETCORE_RUNTIME_VERSION_5 # Install Java Runtime for SonarScanner RUN apt-get install --no-install-recommends -y openjdk-$JRE_VERSION-jre From 6d96fab719b2b43b58068231216c9368c925093c Mon Sep 17 00:00:00 2001 From: Miha Jakovac Date: Fri, 13 Nov 2020 07:07:59 +0100 Subject: [PATCH 3/3] removed changes, the other PR will cover that --- Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index f641462..5002a1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:3.1 +FROM mcr.microsoft.com/dotnet/core/sdk:3.1.403 LABEL "com.github.actions.name"="sonarscan-dotnet" LABEL "com.github.actions.description"="Sonarscanner for .NET Core with pull request decoration support." @@ -11,8 +11,7 @@ LABEL "maintainer"="Highbyte" # Version numbers of used software ENV SONAR_SCANNER_DOTNET_TOOL_VERSION=4.10.0 \ - DOTNETCORE_RUNTIME_VERSION_3=3.1 \ - DOTNETCORE_RUNTIME_VERSION_5=5.0 \ + DOTNETCORE_RUNTIME_VERSION=3.1 \ JRE_VERSION=11 # Add Microsoft Debian apt-get feed @@ -25,8 +24,7 @@ RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod RUN apt-get update -y \ && apt-get install --no-install-recommends -y apt-transport-https \ && apt-get update -y \ - && apt-get install --no-install-recommends -y aspnetcore-runtime-$DOTNETCORE_RUNTIME_VERSION_3 \ - && apt-get install --no-install-recommends -y aspnetcore-runtime-$DOTNETCORE_RUNTIME_VERSION_5 + && apt-get install --no-install-recommends -y aspnetcore-runtime-$DOTNETCORE_RUNTIME_VERSION # Install Java Runtime for SonarScanner RUN apt-get install --no-install-recommends -y openjdk-$JRE_VERSION-jre