|
33 | 33 | with: |
34 | 34 | dotnet-version: '8.x' |
35 | 35 |
|
36 | | - - name: Set up JDK 17 |
37 | | - uses: actions/setup-java@v4 |
38 | | - with: |
39 | | - java-version: 17 |
40 | | - distribution: 'zulu' |
41 | | - |
42 | | - - name: Cache SonarQube Cloud packages |
43 | | - uses: actions/cache@v4 |
44 | | - with: |
45 | | - path: ~\sonar\cache |
46 | | - key: ${{ runner.os }}-sonar |
47 | | - restore-keys: ${{ runner.os }}-sonar |
48 | | - |
49 | | - - name: Cache SonarQube Cloud scanner |
50 | | - id: cache-sonar-scanner |
51 | | - uses: actions/cache@v4 |
52 | | - with: |
53 | | - path: .\.sonar\scanner |
54 | | - key: ${{ runner.os }}-sonar-scanner |
55 | | - restore-keys: ${{ runner.os }}-sonar-scanner |
56 | | - |
57 | | - - name: Install SonarQube Cloud scanner |
58 | | - if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' |
59 | | - shell: powershell |
60 | | - run: | |
61 | | - New-Item -Path .\.sonar\scanner -ItemType Directory |
62 | | - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner |
63 | | -
|
64 | | - - name: Start SonarQube Analysis |
65 | | - shell: powershell |
66 | | - env: |
67 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
68 | | - run: | |
69 | | - $sonarArgs = @( |
70 | | - "/k:`"CloudFlare.Client`"" |
71 | | - "/d:sonar.login=`"${{ secrets.SONAR_TOKEN }}`"" |
72 | | - "/d:sonar.host.url=`"${{ secrets.SONAR_HOST_URL }}`"" |
73 | | - "/d:sonar.scanner.scanAll=`"false`"" |
74 | | - "/d:sonar.scanner.metadataFilePath=`"${{ github.workspace }}/.sonar/report-task.txt`"" |
75 | | - "/d:sonar.exclusions=`"CloudFlare.Client/bin/**/*,CloudFlare.Client/obj/**/*,CloudFlare.Client.Test/bin/**/*,CloudFlare.Client.Test/obj/**/*`"" |
76 | | - "/d:sonar.cs.vstest.reportsPaths=`"**/*.trx`"" |
77 | | - "/d:sonar.cs.opencover.reportsPaths=`"**/coverage.opencover.xml`"" |
78 | | - ) |
79 | | -
|
80 | | - if ("${{ github.event_name }}" -eq "pull_request_target") { |
81 | | - $sonarArgs += "/d:sonar.pullrequest.key=`"${{ github.event.pull_request.number }}`"" |
82 | | - $sonarArgs += "/d:sonar.pullrequest.branch=`"${{ github.event.pull_request.head.ref }}`"" |
83 | | - $sonarArgs += "/d:sonar.pullrequest.base=`"${{ github.event.pull_request.base.ref }}`"" |
84 | | - } |
85 | | - else { |
86 | | - $sonarArgs += "/d:sonar.branch.name=`"${{ github.ref_name }}`"" |
87 | | - } |
88 | | -
|
89 | | - & .\.sonar\scanner\dotnet-sonarscanner begin @sonarArgs |
90 | | -
|
91 | 36 | - name: Build |
92 | 37 | run: dotnet build -restore --configuration ${{ env.buildConfiguration }} |
93 | 38 |
|
94 | 39 | - name: Run Tests |
95 | | - run: | |
96 | | - dotnet test --logger "trx;logfilename=TestResults.trx" --no-build --configuration ${{ env.buildConfiguration }} --collect "XPlat Code Coverage;Format=opencover,cobertura" |
| 40 | + run: dotnet test --logger "trx;logfilename=TestResults.trx" --no-build --configuration ${{ env.buildConfiguration }} --collect "XPlat Code Coverage;Format=opencover,cobertura" |
97 | 41 | continue-on-error: false |
98 | | - |
99 | | - - name: Finish SonarQube Analysis |
100 | | - shell: powershell |
101 | | - env: |
102 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
103 | | - run: | |
104 | | - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" |
105 | | -
|
106 | | - - name: SonarQube Server Quality Gate check |
107 | | - uses: sonarsource/sonarqube-quality-gate-action@master |
108 | | - with: |
109 | | - scanMetadataReportFile: ${{ github.workspace }}/.sonar/report-task.txt |
110 | | - env: |
111 | | - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
112 | | - |
113 | | - - name: "Example show SonarQube Server Quality Gate Status value" |
114 | | - run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" |
115 | | - |
0 commit comments