11name : ' SonarCloud'
22
3+
4+
35on :
46 push :
57 branches :
1012 - main
1113
1214
15+
16+ env :
17+ SDK_VERSION : ' 6.0.300'
18+
19+
20+
1321jobs :
1422
1523 sonar-scanner :
1624 name : " Sonar scanner"
1725 runs-on : windows-latest
18- steps :
1926
20- - name : Setup .NET
27+ steps :
28+ - name : " Setup .NET"
2129 uses : actions/setup-dotnet@v2
2230 with :
23- dotnet-version : ' 6.0.202 '
31+ dotnet-version : ${{ env.SDK_VERSION }}
2432
25- - name : Set up JDK 11
33+ - name : " Set up JDK 11"
2634 uses : actions/setup-java@v3.3.0
2735 with :
2836 distribution : ' adopt'
2937 java-version : ' 11'
3038
31- - uses : actions/checkout@v2
39+ - name : " Checkout"
40+ uses : actions/checkout@v3
3241 with :
3342 fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
3443
35- - name : Cache SonarCloud packages
36- uses : actions/cache@v3.0.2
44+ - name : " Cache SonarCloud packages"
45+ uses : actions/cache@v3
3746 with :
3847 path : ~\sonar\cache
3948 key : ${{ runner.os }}-sonar
4049 restore-keys : ${{ runner.os }}-sonar
4150
42- - name : Cache SonarCloud scanner
51+ - name : " Cache SonarCloud scanner"
4352 id : cache-sonar-scanner
44- uses : actions/cache@v3.0.2
53+ uses : actions/cache@v3
4554 with :
4655 path : .\.sonar\scanner
4756 key : ${{ runner.os }}-sonar-scanner
4857 restore-keys : ${{ runner.os }}-sonar-scanner
4958
50- - name : Install SonarCloud scanner
59+ - name : " Install SonarCloud scanner"
5160 if : steps.cache-sonar-scanner.outputs.cache-hit != 'true'
5261 shell : pwsh
5362 run : |
5463 New-Item -Path .\.sonar\scanner -ItemType Directory
5564 dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
5665
57- - name : Build and analyze
66+ - name : " Build and analyze"
5867 env :
5968 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
6069 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
6170 shell : pwsh
6271 run : |
6372 .\.sonar\scanner\dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /o:"${{ secrets.SONAR_ORGANIZATION }}" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
64- dotnet build --configuration Release
65- dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
66- .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
73+ dotnet build
74+ dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --no-build
75+ .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
0 commit comments