Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ib snyk sonar - test PR #39

Closed
wants to merge 15 commits into from
Closed
22 changes: 22 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: .NET build

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [6.x, 7.x, 8.x]
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
33 changes: 33 additions & 0 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Snyk vulenrability scan

on: [push]
jobs:
security:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [6.x, 7.x, 8.x]
steps:
- uses: actions/checkout@master
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/dotnet@master
continue-on-error: true # To make sure that SARIF upload gets called
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args:
--all-projects
--sarif-file-output=snyk.sarif
--severity-threshold=high
- name: List files for debugging
run: ls -R # Lists all files in all directories
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
31 changes: 31 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: SonarCloud analysis

on: [push]

jobs:
sonarcloud:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [6.x, 7.x]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Install SonarScanner for .NET
run: dotnet tool install --global dotnet-sonarscanner
- name: Run SonarCloud Scan
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"infobip_infobip-api-csharp-client" /o:"infobip" /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
dotnet build
dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
23 changes: 23 additions & 0 deletions ApiClient.Tests/ApiClient.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="WireMock.Net" Version="1.4.20" />
<PackageReference Include="RestSharp" Version="106.11.7" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\infobip-api-csharp-client\src\Infobip.Api.Client\Infobip.Api.Client.csproj" />
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions ApiClient.Tests/UnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ApiClient.Tests
{
[TestClass]
public class UnitTest
{

[TestMethod]
public void PassingTest()
{
// Arrange
int expectedValue = 10;
int actualValue = 10;

// Act & Assert
Assert.AreEqual(expectedValue, actualValue);
}
}
}
21 changes: 13 additions & 8 deletions Infobip.Api.Client.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infobip.Api.Client", "src\Infobip.Api.Client\Infobip.Api.Client.csproj", "{CADD32C6-EEAF-4F62-A44B-F6E35AFEAA0F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infobip.Api.Client", "src\Infobip.Api.Client\Infobip.Api.Client.csproj", "{CADD32C6-EEAF-4F62-A44B-F6E35AFEAA0F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiClient.Tests", "ApiClient.Tests\ApiClient.Tests.csproj", "{3AEFA95F-23A8-4BFB-AEC8-C44296C07D3C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -14,12 +16,15 @@ Global
{CADD32C6-EEAF-4F62-A44B-F6E35AFEAA0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CADD32C6-EEAF-4F62-A44B-F6E35AFEAA0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CADD32C6-EEAF-4F62-A44B-F6E35AFEAA0F}.Release|Any CPU.Build.0 = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU
{3AEFA95F-23A8-4BFB-AEC8-C44296C07D3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AEFA95F-23A8-4BFB-AEC8-C44296C07D3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AEFA95F-23A8-4BFB-AEC8-C44296C07D3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AEFA95F-23A8-4BFB-AEC8-C44296C07D3C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CFCD2192-6FEE-48E8-9099-EF750D54B05C}
EndGlobalSection
EndGlobal
Loading