Skip to content

Commit

Permalink
[v2] Improve sonarcloud scanner configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikfroehling committed Aug 24, 2024
1 parent 1d08c09 commit 3c49de7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 104 deletions.
60 changes: 36 additions & 24 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,41 @@ on:
- 'src/**'

jobs:
stable:
uses: ./.github/workflows/sonarcloudworkflow.yml
secrets: inherit
with:
working_directory: 'Source'
project_name: 'Source/Lib/Trakt.NET/Trakt.NET.csproj'
build_configuration: Release
source_exclusions: 'Source/Tests/**'
sonarcloud:
name: SonarCloud
if: ${{ github.actor == 'henrikfroehling' }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

v2-alpha:
uses: ./.github/workflows/sonarcloudworkflow.yml
secrets: inherit
with:
working_directory: 'src'
project_name: 'src/libs/Trakt.NET/Trakt.NET.csproj'
build_configuration: Release
source_exclusions: 'src/tests/**'
- name: Setup environment variables
uses: cardinalby/export-env-action@v2
with:
envFile: './.github/constants.env'

v2-alpha-httpclientfactory:
uses: ./.github/workflows/sonarcloudworkflow.yml
secrets: inherit
with:
working_directory: 'src'
project_name: 'src/libs/Trakt.NET.HttpClientFactory/Trakt.NET.HttpClientFactory.csproj'
build_configuration: Release
source_exclusions: 'src/tests/**'
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-quality: ${{ env.DOTNET_QUALITY }}

- 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
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"henrikfroehling_Trakt.NET" /o:"henrikfroehling-github" /n:"Trakt.NET" /d:sonar.sources="Source/,src/" /d:sonar.test.inclusions="Source/Tests/,src/tests/" /d:sonar.exclusions="docs/" /d:sonar.sourceEncoding="UTF-8" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build 'Source/Trakt.NET.sln' --configuration Release
dotnet build 'src/Trakt.NET.sln' --configuration Release
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
80 changes: 0 additions & 80 deletions .github/workflows/sonarcloudworkflow.yml

This file was deleted.

0 comments on commit 3c49de7

Please sign in to comment.