1- # This workflow uses actions that are not certified by GitHub.
2- # They are provided by a third-party and are governed by
3- # separate terms of service, privacy policy, and support
4- # documentation.
5-
6- # This workflow helps you trigger a SonarCloud analysis of your code and populates
7- # GitHub Code Scanning alerts with the vulnerabilities found.
8- # Free for open source project.
9-
10- # 1. Login to SonarCloud.io using your GitHub account
11-
12- # 2. Import your project on SonarCloud
13- # * Add your GitHub organization first, then add your repository as a new project.
14- # * Please note that many languages are eligible for automatic analysis,
15- # which means that the analysis will start automatically without the need to set up GitHub Actions.
16- # * This behavior can be changed in Administration > Analysis Method.
17- #
18- # 3. Follow the SonarCloud in-product tutorial
19- # * a. Copy/paste the Project Key and the Organization Key into the args parameter below
20- # (You'll find this information in SonarCloud. Click on "Information" at the bottom left)
21- #
22- # * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN
23- # (On SonarCloud, click on your avatar on top-right > My account > Security
24- # or go directly to https://sonarcloud.io/account/security/)
25-
26- # Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/)
27- # or reach out to our community forum if you need some help (https://community.sonarsource.com/c/help/sc/9)
28-
291name : SonarCloud analysis
302
313on :
@@ -51,34 +23,28 @@ jobs:
5123 dotnet-version : ' 8.0.x'
5224
5325 # 1) BEGIN: SonarScanner for .NET
26+ # FIX: Змінено шлях reportsPaths, щоб шукати ВСІ файли coverage.opencover.xml у підпапках TestResults
5427 - name : SonarScanner Begin
5528 run : |
5629 dotnet tool install --global dotnet-sonarscanner
57- echo "$env:USERPROFILE\.dotnet\tools" >> $env:GITHUB_PATH
58- dotnet sonarscanner begin `
59- /k:"0neDistruktion_REengineering" `
60- /o:"0nedistruktion" `
61- /d:sonar.token="${{ secrets.SONAR_TOKEN }}" `
62- /d:sonar.cs.opencover.reportsPaths="**/coverage.xml" `
63- /d:sonar.cpd.cs.minimumTokens=40 `
64- /d:sonar.cpd.cs.minimumLines=5 `
65- /d:sonar.exclusions=**/bin/**,**/obj/**,**/sonarcloud.yml `
66- /d:sonar.qualitygate.wait=true
30+ dotnet sonarscanner begin /k:"0neDistruktion_REengineering" /o:"0nedistruktion" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml" /d:sonar.coverage.exclusions="**/Program.cs" /d:sonar.cpd.cs.minimumTokens=40 /d:sonar.cpd.cs.minimumLines=5 /d:sonar.exclusions="**/bin/**,**/obj/**,**/sonarcloud.yml,**/Program.cs" /d:sonar.qualitygate.wait=true
6731 shell : pwsh
68- # 2) BUILD & TEST
32+
33+ # 2) BUILD
6934 - name : Restore
7035 run : dotnet restore NetSdrClient.sln
7136 - name : Build
7237 run : dotnet build NetSdrClient.sln -c Release --no-restore
73- - name : Tests with coverage (OpenCover)
38+
39+ # 3) TESTS with Correct Coverage Collection
40+ # FIX: Використовуємо "XPlat Code Coverage". Це створює окремі папки для кожного тесту,
41+ # щоб результати не перезаписували один одного.
42+ - name : Tests with coverage
7443 run : |
75- dotnet test NetSdrClient.sln -c Release --no-build `
76- /p:CollectCoverage=true `
77- /p:CoverletOutputFormat=opencover `
78- /p:CoverletOutput="TestResults/coverage.xml" `
79- --logger "junit;LogFilePath=TestResults/junit.xml"
44+ dotnet test NetSdrClient.sln -c Release --no-build --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
8045 shell : pwsh
81- # 3) END: SonarScanner
46+
47+ # 4) END: SonarScanner
8248 - name : SonarScanner End
8349 run : dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
84- shell : pwsh
50+ shell : pwsh
0 commit comments