Skip to content

Commit 7af615e

Browse files
jaybarden1jbarden
andauthored
Not sure why SonarQube isn't getting the test coverage... (#5)
* Not sure why SonarQube isn't getting the test coverage... I am sure the separation worked, but let's see if this works... * Update main_astar-dev.yml Copied from SonarQube but do not believe it will make a difference as, bar emojis etc., the previous one was too (allbeit originally from another project) * Found a better / different approach - in desc https://docs.sonarsource.com/sonarqube-cloud/enriching/test-coverage/dotnet-test-coverage/#examples-using-the-net-tool-scanner-variant * Put back the permissions limit lost in the earlier copy from SonarQube example (really SQ? you don't have in the template...) * Oh, c'mon! * Need to see how to contribute to SQ docs... add .\.sonar\scanner\dotnet-sonarscanner as that is where the SQ docs actually install it... * Update the filter to exclude Integration Tests too * Silly boy... FullyQualifiedName can't work if the project doesn't use... * it helps if a) actually fully qualified n b) remember to escape ! * OK, let's try including Tests.Unit rather than excluding others * ignore the 2 tests failing on GitHub but passing locally... * Hopefully, this is the last issue * Yet another difference between SQ examples and apparent requirements --------- Co-authored-by: Jason Barden <[email protected]>
1 parent e847204 commit 7af615e

36 files changed

+70
-115
lines changed
Lines changed: 15 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,51 @@
1-
name: Build and analyse the DatabaseTesting Solution
1+
name: SonarQube
2+
permissions:
3+
contents: read
24
on:
3-
pull_request:
4-
types: [ opened, synchronize, reopened ]
55
push:
66
branches:
77
- main
8-
env:
9-
AZURE_WEBAPP_NAME: astar-dev
10-
AZURE_WEBAPP_PACKAGE_PATH: src/uis/AStar.Dev.Web/published
11-
CONFIGURATION: Release
12-
DOTNET_CORE_VERSION: 9.0.x
13-
WORKING_DIRECTORY: src/uis/AStar.Dev.Web
8+
pull_request:
9+
types: [ opened, synchronize, reopened ]
1410
jobs:
1511
build:
12+
name: Build and analyze
1613
runs-on: windows-latest
17-
permissions:
18-
contents: read #This is required for actions/checkout
19-
2014
steps:
2115
- name: Set up JDK 17
2216
uses: actions/setup-java@v4
2317
with:
2418
java-version: 17
25-
distribution: 'zulu'
26-
19+
distribution: 'zulu' # Alternative distribution options are available.
2720
- uses: actions/checkout@v4
2821
with:
2922
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
30-
31-
- name: 🛠 Cache SonarQube Cloud packages
23+
- name: Cache SonarQube Cloud packages
3224
uses: actions/cache@v4
3325
with:
3426
path: ~\sonar\cache
3527
key: ${{ runner.os }}-sonar
3628
restore-keys: ${{ runner.os }}-sonar
37-
38-
- name: 🛠 Cache SonarQube Cloud scanner
29+
- name: Cache SonarQube Cloud scanner
3930
id: cache-sonar-scanner
4031
uses: actions/cache@v4
4132
with:
4233
path: .\.sonar\scanner
4334
key: ${{ runner.os }}-sonar-scanner
4435
restore-keys: ${{ runner.os }}-sonar-scanner
45-
46-
- name: 🛠 Install SonarQube Cloud scanner
36+
- name: Install SonarQube Cloud scanner
4737
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
4838
shell: powershell
4939
run: |
50-
New-Item -Path .\.sonar\scanner -ItemType Directory
40+
New-Item -Path .\.sonar\scanner -ItemType Directory
5141
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
52-
53-
- name: 🔍 Restore,
54-
shell: powershell
55-
run: |
56-
dotnet restore
57-
58-
- name: 🛠 Build
59-
shell: powershell
60-
run: |
61-
dotnet build --no-restore
62-
63-
- name: 🧪 Test and analyse with ☁️ SonarCloud / Qube
42+
- name: Build and analyze
6443
env:
6544
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6645
shell: powershell
6746
run: |
6847
dotnet tool install --global dotnet-coverage
69-
.\.sonar\scanner\dotnet-sonarscanner begin /k:"astar-development_astar-dev-database-testing" /o:"astar-development" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.scanner.scanAll=false /d:sonar.scanner.skipJreProvisioning=true
70-
dotnet-coverage collect 'dotnet test --filter "FullyQualifiedName!~Tests.EndToEnd"' -f xml -o 'coverage.xml'
48+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"astar-development_astar-dev-database-testing" /o:"astar-development" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.host.url="https://sonarcloud.io" /d:sonar.scanner.scanAll=false /d:sonar.scanner.skipJreProvisioning=true
49+
dotnet build --no-incremental
50+
dotnet-coverage collect 'dotnet test --filter "FullyQualifiedName~Tests.Unit"' -f xml -o 'coverage.xml'
7151
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
72-
#
73-
# - name: 🚀 Publish App
74-
# run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}"
75-
#
76-
# - name: 🚀 Publish Artifacts
77-
# uses: actions/upload-artifact@v4
78-
# with:
79-
# name: webapp
80-
# path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
81-
82-
# deploy:
83-
# runs-on: ubuntu-latest
84-
# needs: build
85-
# environment:
86-
# name: 'Production'
87-
# url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
88-
# permissions:
89-
# id-token: write #This is required for requesting the JWT
90-
# contents: read #This is required for actions/checkout
91-
#
92-
# steps:
93-
# - name: Download artifact from build job
94-
# uses: actions/download-artifact@v4
95-
# with:
96-
# name: webapp
97-
# path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
98-
#
99-
# - name: Login to Azure
100-
# uses: azure/login@v2
101-
# with:
102-
# client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_E8497C9E217E4655814D0F7761AAE04F }}
103-
# tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_085200BD39F041C4999EEB0851E8D6A2 }}
104-
# subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_3FEB324333C140D8A0FA99AC083AEB82 }}
105-
#
106-
# - name: Deploy to Azure WebApp
107-
# uses: azure/webapps-deploy@v3
108-
# with:
109-
# app-name: ${{ env.AZURE_WEBAPP_NAME }}
110-
# package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

test/AStar.Dev.Infrastructure.FilesDb.Tests.Integration/AStar.Dev.Infrastructure.FilesDb.Tests.Integration.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<IsPackable>false</IsPackable>
8-
<RootNamespace>AStar.Dev.Infrastructure.FilesDb</RootNamespace>
8+
<RootNamespace>AStar.Dev.Infrastructure.FilesDb.Tests.Integration</RootNamespace>
99
<UserSecretsId>8f6cdef5-4769-401b-a5d6-bf409c7b76d6</UserSecretsId>
1010
</PropertyGroup>
1111

test/AStar.Dev.Infrastructure.FilesDb.Tests.Integration/FileDetailDeletionStatusExtensionsShould.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using DbContextHelpers.Fixtures;
33
using Shouldly;
44

5-
namespace AStar.Dev.Infrastructure.FilesDb;
5+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
66

77
/// <summary>
88
/// </summary>

test/AStar.Dev.Infrastructure.FilesDb.Tests.Integration/FileDetailDirectoryNameExtensionsShould.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using DbContextHelpers.Fixtures;
44
using Shouldly;
55

6-
namespace AStar.Dev.Infrastructure.FilesDb;
6+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
77

88
public class FileDetailDirectoryNameExtensionsShould (FilesContextFixture filesContextFixture) : IClassFixture<FilesContextFixture>
99
{

test/AStar.Dev.Infrastructure.FilesDb.Tests.Integration/FileDetailOrderingExtensionsShould.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using DbContextHelpers.Fixtures;
44
using Shouldly;
55

6-
namespace AStar.Dev.Infrastructure.FilesDb;
6+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
77

88
/// <summary>
99
/// </summary>

test/AStar.Dev.Infrastructure.FilesDb.Tests.Integration/FileDetailPagingExtensionsShould.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using DbContextHelpers.Fixtures;
33
using Shouldly;
44

5-
namespace AStar.Dev.Infrastructure.FilesDb;
5+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
66

77
/// <summary>
88
/// </summary>

test/AStar.Dev.Infrastructure.FilesDb.Tests.Integration/FileDetailSearchTypeExtensionsShould.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using DbContextHelpers.Fixtures;
44
using Shouldly;
55

6-
namespace AStar.Dev.Infrastructure.FilesDb;
6+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
77

88
/// <summary>
99
/// </summary>

test/AStar.Dev.Infrastructure.FilesDb.Tests.Integration/FileDetailTextContainsExtensionsShould.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using DbContextHelpers.Fixtures;
33
using Shouldly;
44

5-
namespace AStar.Dev.Infrastructure.FilesDb;
5+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
66

77
/// <summary>
88
/// </summary>

test/AStar.Dev.Infrastructure.FilesDb.Tests.Integration/FilesContextLastViewedExtensionsShould.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Microsoft.Extensions.Time.Testing;
44
using Shouldly;
55

6-
namespace AStar.Dev.Infrastructure.FilesDb;
6+
namespace AStar.Dev.Infrastructure.FilesDb.Tests.Integration;
77

88
public class FilesContextLastViewedExtensionsShould : IClassFixture<FilesContextFixture>
99
{

test/AStar.Dev.Infrastructure.FilesDb.Tests.Unit/AStar.Dev.Infrastructure.FilesDb.Tests.Unit.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<IsPackable>false</IsPackable>
8-
<RootNamespace>AStar.Dev.Infrastructure.FilesDb</RootNamespace>
98
</PropertyGroup>
109

1110
<ItemGroup>

0 commit comments

Comments
 (0)