Skip to content

Commit de66c5b

Browse files
Merge pull request #9 from IowaComputerGurus/feature/build-validation
Initial commit of SonarCloud
2 parents b5582fa + d5e7da9 commit de66c5b

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

.github/workflows/ci-build.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,60 @@ jobs:
3636
run: dotnet restore "${{ env.solution-path }}"
3737
- name: Build
3838
run: dotnet build "${{ env.solution-path }}" --no-restore --configuration Release -p:version=${{ steps.gitversion.outputs.majorMinorPatch }}
39+
- name: Test
40+
run: dotnet test "${{ env.solution-path }}" --no-build --configuration Release
41+
42+
43+
code-quality:
44+
runs-on: windows-latest
45+
name: Analyze Code Quality
46+
env:
47+
solution-path: './src/NetCore.Utilities.Email.SendGrid.sln'
48+
steps:
49+
- name: Set up JDK 11
50+
uses: actions/setup-java@v1
51+
with:
52+
java-version: 1.11
53+
- uses: actions/checkout@v2
54+
with:
55+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
56+
- name: Cache SonarCloud packages
57+
uses: actions/cache@v1
58+
with:
59+
path: ~\sonar\cache
60+
key: ${{ runner.os }}-sonar
61+
restore-keys: ${{ runner.os }}-sonar
62+
- name: Cache SonarCloud scanner
63+
id: cache-sonar-scanner
64+
uses: actions/cache@v1
65+
with:
66+
path: .\.sonar\scanner
67+
key: ${{ runner.os }}-sonar-scanner
68+
restore-keys: ${{ runner.os }}-sonar-scanner
69+
- name: Install SonarCloud scanner
70+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
71+
shell: powershell
72+
run: |
73+
New-Item -Path .\.sonar\scanner -ItemType Directory
74+
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
75+
76+
- name: Install GitVersion
77+
run: dotnet tool install --global GitVersion.Tool
78+
79+
- name: Determine Version
80+
id: gitversion
81+
uses: gittools/actions/gitversion/[email protected]
82+
with:
83+
useConfigFile: true
3984

85+
- name: Build and analyze
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
88+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
89+
shell: powershell
90+
run: |
91+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"IowaComputerGurus_netcore.utilities.email.sendgrid" /o:"iowacomputergurus-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
92+
dotnet restore "${{ env.solution-path }}"
93+
dotnet build "${{ env.solution-path }}" --no-restore --configuration Release -p:version=${{ steps.gitversion.outputs.majorMinorPatch }}
94+
dotnet test "${{ env.solution-path }}" --no-build --configuration Release --collect "XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover --logger "trx;LogFileName=unittests.trx"
95+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="coverlet.collector" Version="3.1.2">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
</PackageReference>
1014
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
1115
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
1216
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1418
<PackageReference Include="Moq" Version="4.16.1" />
1519
<PackageReference Include="xunit" Version="2.4.1" />
1620
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">

src/NetCore.Utilities.Email.SendGrid.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.30804.86
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCore.Utilities.Email.SendGrid", "NetCore.Utilities.Email.SendGrid\NetCore.Utilities.Email.SendGrid.csproj", "{48F8F9BE-5579-4B92-AF46-194F755ECAB0}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCore.Utilities.Email.SendGrid.Tests", "NetCore.Utilities.Email.SendGrid.Tests\NetCore.Utilities.Email..SendGrid.Tests.csproj", "{5DFA4C47-6FBF-42F7-8179-1A07404CB9DF}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCore.Utilities.Email.SendGrid.Tests", "NetCore.Utilities.Email.SendGrid.Tests\NetCore.Utilities.Email.SendGrid.Tests.csproj", "{5DFA4C47-6FBF-42F7-8179-1A07404CB9DF}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution

0 commit comments

Comments
 (0)