Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Add Sonar PR decoration #4

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
16 changes: 5 additions & 11 deletions .github/workflows/template-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ on:
required: false
type: string
default: 'ga'
publish-coverage:
description: 'publish coverage to codecov'
required: false
type: boolean
default: true
check-eslint:
description: 'path to script folder you want to check for ES6 compliance'
required: false
Expand Down Expand Up @@ -86,12 +81,11 @@ jobs:
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test -c Release --no-build --no-restore --blame-hang --blame-hang-timeout 60s /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:ExcludeByAttribute='ExcludeFromCodeCoverageAttribute' /p:ExcludeByAttribute='CompilerGeneratedAttribute' /p:ExcludeByFile='**/*.g.cs' /p:Include='[MudBlazor]*' /p:SkipAutoProps=true /p:CoverletOutput='./TestResults/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why you removed the include. Doesnt this now show code coverage outside the library

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think this is required for the Source Generator and the Analyser. Both have tests but the coverage was not included.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the coverage excluded from the other projects are they annotated?

run: dotnet test -c Release --no-build --no-restore --blame-hang --blame-hang-timeout 60s /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:ExcludeByAttribute='ExcludeFromCodeCoverageAttribute' /p:ExcludeByAttribute='CompilerGeneratedAttribute' /p:ExcludeByFile='**/*.g.cs' /p:SkipAutoProps=true /p:CoverletOutput='./TestResults/'

- name: Publish coverage
if: ${{ inputs.publish-coverage == true }}
uses: codecov/codecov-action@v4
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.cobertura.xml
name: coverage-report
path: ./**/TestResults/coverage.opencover.xml

10 changes: 8 additions & 2 deletions .github/workflows/template-sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0

- name: Install sonar scanner
run: dotnet tool install -g dotnet-sonarscanner
run: dotnet tool install -g dotnet-sonarscanner --version 8.0.1

- name: Cache sonar
uses: actions/cache@v4
Expand All @@ -29,11 +29,17 @@ jobs:
- name: Restore
working-directory: './src'
run: dotnet restore

- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-report
path: ./src/TestResults

- name: Analyze
working-directory: './src'
run: |
dotnet sonarscanner begin /k:"${{ env.PROJECT_KEY }}" /o:"${{ env.ORGANIZATION }}" /d:sonar.token="${{ env.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.dotnet.excludeTestProjects=true
dotnet sonarscanner begin /k:"${{ env.PROJECT_KEY }}" /o:"${{ env.ORGANIZATION }}" /d:sonar.token="${{ env.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.dotnet.excludeTestProjects=true /d:sonar.scanner.scanAll=true /d:sonar.cs.opencover.reportsPaths="**/TestResults/coverage.opencover.xml"
dotnet build MudBlazor/MudBlazor.csproj -c Release --no-restore --no-incremental
dotnet sonarscanner end /d:sonar.token="${{ env.SONAR_TOKEN }}"
env:
Expand Down