From 714969cfb9de83a71bd0d7d6dfc567f6607d8638 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Fri, 31 Oct 2025 18:43:04 +0300 Subject: [PATCH] Refactor SonarQube workflow to streamline commands by directly referencing the solution file for restore, build, and test steps, enhancing clarity and efficiency. --- .github/workflows/sonarqube.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 4764977..7a71aed 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -1,4 +1,4 @@ -name: SonarQube Analys +name: SonarQube Analysis on: push: @@ -33,8 +33,7 @@ jobs: dotnet tool install dotnet-sonarscanner --tool-path ~/.sonar/scanner - name: Restore dependencies - run: dotnet restore --verbosity normal - working-directory: Source/AIImages + run: dotnet restore AIImages.sln --verbosity normal - name: Build and analyze env: @@ -50,23 +49,23 @@ jobs: /k:"AIImages" \ /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" \ + /d:sonar.projectBaseDir="$(pwd)" \ /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" \ /d:sonar.coverage.exclusions="**/obj/**,**/bin/**,**/Assemblies/**" \ /d:sonar.exclusions="**/obj/**,**/bin/**,**/Assemblies/**,**/Migrations/**" \ /d:sonar.cpd.exclusions="**/obj/**,**/bin/**" \ /d:sonar.test.inclusions="**/*Tests.cs,**/*Test.cs" \ /d:sonar.sources="Source" \ - /d:sonar.sourceEncoding=UTF-8 + /d:sonar.sourceEncoding=UTF-8 \ + /s:"AIImages.sln" - echo "Building project..." - cd Source/AIImages - dotnet build --verbosity normal --no-incremental -c Release + echo "Building solution..." + dotnet build AIImages.sln --verbosity normal --no-incremental -c Release echo "Running tests with coverage (if any)..." - dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage/ /p:Exclude="[*.Tests]*" || echo "No tests found, skipping test execution" + dotnet test AIImages.sln /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage/ /p:Exclude="[*.Tests]*" || echo "No tests found, skipping test execution" echo "Ending SonarQube analysis..." - cd ../.. ~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - name: Wait for Quality Gate