Skip to content

Commit

Permalink
Merge pull request #193 from samsmithnz/AddedSonarcloudAction
Browse files Browse the repository at this point in the history
Added sonarcloud action
  • Loading branch information
samsmithnz committed Dec 19, 2022
2 parents ccd9849 + 7754d4d commit 9a2305c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 42 deletions.
49 changes: 9 additions & 40 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,51 +77,20 @@ jobs:
name: ${{ matrix.ChannelName }}
path: ${{ github.workspace }}\${{ matrix.ChannelName }}


sonarCloud:
name: Run SonarCloud analysis
runs-on: windows-latest
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install .NET 7 SDK
uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: 7.0.x
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
- name: Run Sonarcloud test
uses: samsmithnz/SamsDotNetSonarCloudAction@1.1.1
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
projects: 'src/DCB/DCB.csproj,src/DCB.Tests/DCB.Tests.csproj '
dotnet-version: '7.0.x'
sonarcloud-organization: samsmithnz-github
sonarcloud-project: samsmithnz_Dependabot-Configuration-Builder
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"samsmithnz_Dependabot-Configuration-Builder" /o:"samsmithnz-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build src/DCB/DCB.csproj
dotnet build src/DCB.Tests/DCB.Tests.csproj
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"


Release:
Expand Down
2 changes: 1 addition & 1 deletion src/DCB.Tests/DCB.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/DCB/DCB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="GitHubActionsDotNet" Version="1.0.15" />
<PackageReference Include="GitHubActionsDotNet" Version="1.0.16" />
<PackageReference Include="YamlDotNet" Version="12.2.1" />
</ItemGroup>

Expand Down

0 comments on commit 9a2305c

Please sign in to comment.