Skip to content

Commit 4ef19b0

Browse files
authored
Merge pull request #739 from samsmithnz/UpdateToSonarAction
Updating to Sonar Action
2 parents da937c1 + 6918f68 commit 4ef19b0

File tree

3 files changed

+11
-46
lines changed

3 files changed

+11
-46
lines changed

.github/workflows/dotnetcore.yml

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -128,53 +128,18 @@ jobs:
128128

129129
sonarCloud:
130130
name: Run SonarCloud analysis
131-
runs-on: windows-latest
131+
runs-on: ubuntu-latest
132+
if: github.ref == 'refs/heads/main'
132133
steps:
133-
- name: Set up JDK 11
134-
uses: actions/setup-java@v1
135-
with:
136-
java-version: 1.11
137-
- uses: actions/checkout@v3
138-
with:
139-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
140-
- name: Install .NET 7 SDK
141-
uses: actions/[email protected]
134+
- name: Run Sonarcloud test
135+
uses: samsmithnz/[email protected]
142136
with:
143-
dotnet-version: 7.0.x
144-
- name: Cache SonarCloud packages
145-
uses: actions/cache@v3
146-
with:
147-
path: ~\sonar\cache
148-
key: ${{ runner.os }}-sonar
149-
restore-keys: ${{ runner.os }}-sonar
150-
- name: Cache SonarCloud scanner
151-
id: cache-sonar-scanner
152-
uses: actions/cache@v3
153-
with:
154-
path: .\.sonar\scanner
155-
key: ${{ runner.os }}-sonar-scanner
156-
restore-keys: ${{ runner.os }}-sonar-scanner
157-
- name: Install SonarCloud scanner
158-
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
159-
shell: powershell
160-
run: |
161-
New-Item -Path .\.sonar\scanner -ItemType Directory
162-
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
163-
- name: Build and analyze
164-
env:
165-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
137+
projects: 'src/DevOpsMetrics.Core/DevOpsMetrics.Core.csproj,src/DevOpsMetrics.Function/DevOpsMetrics.Function.csproj,src/DevOpsMetrics.FunctionalTests/DevOpsMetrics.FunctionalTests.csproj,src/DevOpsMetrics.Service/DevOpsMetrics.Service.csproj,src/DevOpsMetrics.Tests/DevOpsMetrics.Tests.csproj,src/DevOpsMetrics.Web/DevOpsMetrics.Web.csproj'
138+
dotnet-version: '7.0.x'
139+
sonarcloud-organization: samsmithnz-github
140+
sonarcloud-project: samsmithnz_DevOpsMetrics
166141
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
167-
shell: powershell
168-
run: |
169-
.\.sonar\scanner\dotnet-sonarscanner begin /k:"samsmithnz_DevOpsMetrics" /o:"samsmithnz-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
170-
dotnet build src/DevOpsMetrics.Core/DevOpsMetrics.Core.csproj
171-
dotnet build src/DevOpsMetrics.Function/DevOpsMetrics.Function.csproj
172-
dotnet build src/DevOpsMetrics.FunctionalTests/DevOpsMetrics.FunctionalTests.csproj
173-
dotnet build src/DevOpsMetrics.Service/DevOpsMetrics.Service.csproj
174-
dotnet build src/DevOpsMetrics.Tests/DevOpsMetrics.Tests.csproj
175-
dotnet build src/DevOpsMetrics.Web/DevOpsMetrics.Web.csproj
176-
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
177-
142+
178143

179144
#Disabling PROBOT for 2021 reboot to focus on website
180145
#Deploy the probot artifacts to Azure

src/DevOpsMetrics.FunctionalTests/DevOpsMetrics.FunctionalTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
1111
<PackageReference Include="MSTest.TestAdapter" Version="3.0.0" />
1212
<PackageReference Include="MSTest.TestFramework" Version="3.0.0" />
1313
<PackageReference Include="coverlet.collector" Version="3.2.0">

src/DevOpsMetrics.Tests/DevOpsMetrics.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
2828
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.24" />
2929
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
30-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
30+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
3131
<PackageReference Include="Moq" Version="4.18.3" />
3232
<PackageReference Include="MSTest.TestAdapter" Version="3.0.0" />
3333
<PackageReference Include="MSTest.TestFramework" Version="3.0.0" />

0 commit comments

Comments
 (0)