Refactor SonarQube workflow to streamline commands by directly referencing the solution file for restore, build, and test steps, enhancing clarity and efficiency.
Some checks failed
SonarQube Analysis / Build and analyze (push) Failing after 1m26s
Some checks failed
SonarQube Analysis / Build and analyze (push) Failing after 1m26s
This commit is contained in:
17
.github/workflows/sonarqube.yml
vendored
17
.github/workflows/sonarqube.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: SonarQube Analys
|
name: SonarQube Analysis
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -33,8 +33,7 @@ jobs:
|
|||||||
dotnet tool install dotnet-sonarscanner --tool-path ~/.sonar/scanner
|
dotnet tool install dotnet-sonarscanner --tool-path ~/.sonar/scanner
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore --verbosity normal
|
run: dotnet restore AIImages.sln --verbosity normal
|
||||||
working-directory: Source/AIImages
|
|
||||||
|
|
||||||
- name: Build and analyze
|
- name: Build and analyze
|
||||||
env:
|
env:
|
||||||
@@ -50,23 +49,23 @@ jobs:
|
|||||||
/k:"AIImages" \
|
/k:"AIImages" \
|
||||||
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
|
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
|
||||||
/d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" \
|
/d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" \
|
||||||
|
/d:sonar.projectBaseDir="$(pwd)" \
|
||||||
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" \
|
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" \
|
||||||
/d:sonar.coverage.exclusions="**/obj/**,**/bin/**,**/Assemblies/**" \
|
/d:sonar.coverage.exclusions="**/obj/**,**/bin/**,**/Assemblies/**" \
|
||||||
/d:sonar.exclusions="**/obj/**,**/bin/**,**/Assemblies/**,**/Migrations/**" \
|
/d:sonar.exclusions="**/obj/**,**/bin/**,**/Assemblies/**,**/Migrations/**" \
|
||||||
/d:sonar.cpd.exclusions="**/obj/**,**/bin/**" \
|
/d:sonar.cpd.exclusions="**/obj/**,**/bin/**" \
|
||||||
/d:sonar.test.inclusions="**/*Tests.cs,**/*Test.cs" \
|
/d:sonar.test.inclusions="**/*Tests.cs,**/*Test.cs" \
|
||||||
/d:sonar.sources="Source" \
|
/d:sonar.sources="Source" \
|
||||||
/d:sonar.sourceEncoding=UTF-8
|
/d:sonar.sourceEncoding=UTF-8 \
|
||||||
|
/s:"AIImages.sln"
|
||||||
|
|
||||||
echo "Building project..."
|
echo "Building solution..."
|
||||||
cd Source/AIImages
|
dotnet build AIImages.sln --verbosity normal --no-incremental -c Release
|
||||||
dotnet build --verbosity normal --no-incremental -c Release
|
|
||||||
|
|
||||||
echo "Running tests with coverage (if any)..."
|
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..."
|
echo "Ending SonarQube analysis..."
|
||||||
cd ../..
|
|
||||||
~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
||||||
|
|
||||||
- name: Wait for Quality Gate
|
- name: Wait for Quality Gate
|
||||||
|
|||||||
Reference in New Issue
Block a user