Skip to content

Commit

Permalink
Merge pull request #10 from Encamina/@rliberoff/remove_build_and_test…
Browse files Browse the repository at this point in the history
…_from_sonar_analysis

@rliberoff/remove build and test from sonar analysis
  • Loading branch information
rliberoff authored Nov 27, 2023
2 parents dd8d065 + cce76bf commit 57472e3
Show file tree
Hide file tree
Showing 78 changed files with 1,030 additions and 141 deletions.
105 changes: 52 additions & 53 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: GitHubAction
name: ENMARCHA NuGet

on:
push:
branches:
- releases/*
workflow_call:
secrets:
SONAR_TOKEN:
required: true
workflow_dispatch:

env:
BuildConfiguration: ${{ startsWith(github.ref, 'refs/heads/releases') && 'Release' || 'Debug' }}
Expand All @@ -19,62 +16,56 @@ jobs:
release_version: ${{ steps.PassOutputReleaseVersion.releaseVersion }}
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Using .NET from 'global.json'
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json

- name: Restore Nuget Packages
run: |
config=$(find . -name 'NuGet.config')
for csproj in $(find . -name '*.csproj'); do
dotnet restore $csproj --configfile $config --verbosity minimal
done
shell: bash

- name: Build
run: dotnet build --nologo --no-restore --configuration ${{env.BuildConfiguration}}
- name: Restore NuGet Packages
run: dotnet restore --configfile NuGet.config --verbosity Minimal

- name: Test
run: dotnet test --nologo --no-restore --configuration ${{env.BuildConfiguration}}

- name: Pack
run: dotnet pack --no-build --configuration ${{env.BuildConfiguration}} --output nupkg
run: dotnet test --nologo --no-restore --collect:"XPlat Code Coverage" --configuration ${{env.BuildConfiguration}} --settings coverlet.runsettings

- name: Install Report Generator Tool
run: dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools --ignore-failed-sources

- name: Generate Coverage Report
run: |
./tools/reportgenerator -reports:coverage/*/coverage.cobertura.xml -targetdir:CodeCoverage -reporttypes:MarkdownSummaryGithub
./tools/reportgenerator -reports:coverage/*/coverage.cobertura.xml -targetdir:CodeCoverage -reporttypes:Cobertura
continue-on-error: true
run: ./tools/reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:coverage/Cobertura -reporttypes:'MarkdownSummaryGithub;Cobertura'

- name: Publish Coverage Report
uses: actions/upload-artifact@v2
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: ${{ github.workspace }}/CodeCoverage/SummaryGithub.md
#- name: SonarCloud Scan
# uses: sonarsource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# with:
# projectBaseDir: ${{ github.workspace }}
# args: >
# -Dsonar.organization=encamina
# -Dsonar.projectKey=${{secrets.SONAR_TOKEN}}
# -Dsonar.python.coverage.reportPaths=CodeCoverage/Cobertura.xml
# -Dsonar.tests=tst/
# -Dsonar.verbose=true

# The folder on which nugets are located is zipped, then it is moved to the workspace.
- name: Zip Artifact for deployment
path: coverage/Cobertura/

- name: Write Coverage Report to Job Summary
run: cat coverage/Cobertura/SummaryGithub.md >> $GITHUB_STEP_SUMMARY

- name: Build & Pack Libraries
run: dotnet pack --nologo --no-restore --configuration ${{env.BuildConfiguration}} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:SourceLinkCreate=true -p:DebugType=full --output nupkg

- name: Sonar - Install SonarCloud scanners
run: |
dotnet tool install --global dotnet-sonarscanner
- name: Sonar - Analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /o:"${{ secrets.SONAR_ORGANIZATION }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.exclusions="**/tst/**/*" /d:sonar.cs.opencover.reportsPaths="**/tst/**/coverage.opencover.xml"
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Zip Libraries
run: |
cd ${{ github.workspace }}/nupkg
zip -r nupkg.zip *
mv ./nupkg.zip ${{ github.workspace }}
- name: Upload Artifact for Continuous Deployment
- name: Upload Libraries for Continuous Deployment
uses: actions/upload-artifact@v3
with:
name: enmarcha-libraries-${{ github.run_number }}
Expand All @@ -86,7 +77,7 @@ jobs:
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/releases')
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Read and Store Version
id: PassOutputReleaseVersion
Expand All @@ -98,18 +89,26 @@ jobs:
$release_version = ($prefix, $suffix) | ? { $_ } | Join-String -Separator "-"
echo "RELEASE_VERSION=$release_version" >> $env:GITHUB_OUTPUT
- name: Create Tag
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git tag -a "Release-${{ steps.PassOutputReleaseVersion.outputs.RELEASE_VERSION }}" -m "Version from build ${{ github.run_number }}"
- name: Download Libraries for Continuous Deployment
uses: actions/download-artifact@v3
with:
name: enmarcha-libraries-${{ github.run_number }}
path: ./

- name: Unzip Libraries
run: |
cd ${{ github.workspace }}
unzip nupkg.zip -d nupkg
- name: Push Libraries to NuGet.org
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

- name: Create Tag
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git tag -a "Release-${{ steps.PassOutputReleaseVersion.outputs.RELEASE_VERSION }}" -m "Version from build ${{ github.run_number }}"
- name: Create Release
id: create_release
uses: actions/[email protected]
Expand All @@ -128,5 +127,5 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./nupkg.zip
asset_name: enmarcha-libraries-${{ github.run_number }}.zip
asset_name: enmarcha-libraries-${{ steps.PassOutputReleaseVersion.outputs.RELEASE_VERSION }}.zip
asset_content_type: application/zip
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

This project adheres to Azure [API Versioning](https://docs.microsoft.com/en-us/azure/api-management/api-management-versions) with [Revisions](https://docs.microsoft.com/en-us/azure/api-management/api-management-revisions) enabled.

Each version and revision is followed by a date of change, specially for under development versions. Each entry provides the following information (when applicable):

- **Breaking Changes**: changes that may certainty affect consumers of the API or how it is expected to be used.
- **Major Changes**: big improvements in the code, like adding or enabling features, or bug fixes.
- **Minor Changes**: small changes that have little impact, like spell checks in an API's documentation, adding or removing comments, etc.

Also, any bug fix must start with the prefix «Bug fix:» followed by the description of the changes _per se_.

Previous classification is not required if changes are simple or all belong to the same category.

## [6.0.3.20]

### **Major Changes**

- Added this `CHANGELOG.md`
- In `Encamina.Enmarcha.SemanticKernel.Abstractions`, method `ValidateAndThrowIfErrorOccurred` is now obsolete, and will be removed in a future version of this library.
- In `Encamina.Enmarcha.SemanticKernel.Plugins.Chat`, property `ChatRequestSettings` is now obsolete due to future changes in Semantic Kernel library its type `ChatRequestSettings` will change to `OpenAIRequestSettings `. Therefore, the signature of this property will change in future versions of this library.
- In `Encamina.Enmarcha.SemanticKernel.Connectors.Memory`, the constructor of `MemoryQueryPlugin` is now obsolete due to future changes in Semantic Kernel library, where the semantic memory will be a dependency outside the `IKernel`. The `IKernel` dependency will be replaced with `ISemanticTextMemory`. The signature of this constructor will change in future versions of this library.
- In `Encamina.Enmarcha.SemanticKernel.Connectors.Memory`, the extension method `ImportMemoryPlugin` is now obsolete due to future changes in Semantic Kernel library, where the semantic memory will be a dependency outside the `IKernel`. An additional dependency with `ISemanticTextMemory` will be added to this extension method. The signature of this method will change in future versions of this library.

## [6.0.3.18] and [6.0.3.19]

- First Open Source versions of ENMARCHA.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<PropertyGroup>
<VersionPrefix>6.0.3.18</VersionPrefix>
<VersionPrefix>6.0.3.20</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>

Expand Down
35 changes: 34 additions & 1 deletion Enmarcha.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32421.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solution Items", "{B124CEEF-2F1A-4AEC-9234-CA9B08BACB11}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "[Solution Items]", "[Solution Items]", "{B124CEEF-2F1A-4AEC-9234-CA9B08BACB11}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
.runsettings = .runsettings
CHANGELOG.md = CHANGELOG.md
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
CONTRIBUTING.md = CONTRIBUTING.md
coverlet.runsettings = coverlet.runsettings
Expand Down Expand Up @@ -122,6 +123,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.SemanticK
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.SemanticKernel.Abstractions", "src\Encamina.Enmarcha.SemanticKernel.Abstractions\Encamina.Enmarcha.SemanticKernel.Abstractions.csproj", "{04DA11A3-937C-4D0A-ABDA-65AE9E0FCA5C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{C082F40D-38BE-4283-829E-29346AF71EAE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{B9E33951-E387-4A80-A652-A908FCBB34F3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample_Data_CosmosDB", "samples\Data\Sample_Data_CosmosDB\Sample_Data_CosmosDB.csproj", "{264A9DAA-2556-479A-A0F0-20A1DE14AC44}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample_Data_EntityFramework", "samples\Data\Sample_Data_EntityFramework\Sample_Data_EntityFramework.csproj", "{68E17F14-A683-450C-A557-F27F4DF4DFD9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SemanticKernel", "SemanticKernel", "{43252034-27E2-4981-AC2D-EA986B287863}"
ProjectSection(SolutionItems) = preProject
samples\SemanticKernel\Sample_SemanticKernel_Text\Sample_SemanticKernel_Text.csproj = samples\SemanticKernel\Sample_SemanticKernel_Text\Sample_SemanticKernel_Text.csproj
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample_SemanticKernel_QuestionAnswering", "samples\SemanticKernel\Sample_SemanticKernel_QuestionAnswering\Sample_SemanticKernel_QuestionAnswering.csproj", "{661506FB-E0A7-4D6E-997F-A5CA12315424}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -312,6 +328,18 @@ Global
{04DA11A3-937C-4D0A-ABDA-65AE9E0FCA5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04DA11A3-937C-4D0A-ABDA-65AE9E0FCA5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04DA11A3-937C-4D0A-ABDA-65AE9E0FCA5C}.Release|Any CPU.Build.0 = Release|Any CPU
{264A9DAA-2556-479A-A0F0-20A1DE14AC44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{264A9DAA-2556-479A-A0F0-20A1DE14AC44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{264A9DAA-2556-479A-A0F0-20A1DE14AC44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{264A9DAA-2556-479A-A0F0-20A1DE14AC44}.Release|Any CPU.Build.0 = Release|Any CPU
{68E17F14-A683-450C-A557-F27F4DF4DFD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68E17F14-A683-450C-A557-F27F4DF4DFD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68E17F14-A683-450C-A557-F27F4DF4DFD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68E17F14-A683-450C-A557-F27F4DF4DFD9}.Release|Any CPU.Build.0 = Release|Any CPU
{661506FB-E0A7-4D6E-997F-A5CA12315424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{661506FB-E0A7-4D6E-997F-A5CA12315424}.Debug|Any CPU.Build.0 = Debug|Any CPU
{661506FB-E0A7-4D6E-997F-A5CA12315424}.Release|Any CPU.ActiveCfg = Release|Any CPU
{661506FB-E0A7-4D6E-997F-A5CA12315424}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -321,6 +349,11 @@ Global
{3D07ED6E-FB91-428B-83E2-5797D790DD54} = {CBD50B5F-AFB8-4DA1-9FD7-17D98EB3ED78}
{E8152699-CECB-4BF5-884F-0A760554286E} = {CBD50B5F-AFB8-4DA1-9FD7-17D98EB3ED78}
{60C7833C-1E40-4725-8561-D86B424D78A5} = {CBD50B5F-AFB8-4DA1-9FD7-17D98EB3ED78}
{B9E33951-E387-4A80-A652-A908FCBB34F3} = {C082F40D-38BE-4283-829E-29346AF71EAE}
{264A9DAA-2556-479A-A0F0-20A1DE14AC44} = {B9E33951-E387-4A80-A652-A908FCBB34F3}
{68E17F14-A683-450C-A557-F27F4DF4DFD9} = {B9E33951-E387-4A80-A652-A908FCBB34F3}
{43252034-27E2-4981-AC2D-EA986B287863} = {C082F40D-38BE-4283-829E-29346AF71EAE}
{661506FB-E0A7-4D6E-997F-A5CA12315424} = {43252034-27E2-4981-AC2D-EA986B287863}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F30DF47A-541C-4383-BCEB-E4108D06A70E}
Expand Down
7 changes: 7 additions & 0 deletions samples/Data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Samples and How-To Guides

In this folder, you will find different examples of the implementation of ENMARCHA nuggets related to data storage. These nuggets are meant to send the information to databases, such as CosmosDB or SQLServer.

## Getting started

Each folder contains an example of the implementation of ENMARCHA nugets. These are small projects in C#. Each example contains a `README.md` file.
14 changes: 14 additions & 0 deletions samples/Data/Sample_Data_CosmosDB/Bill.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Newtonsoft.Json;

namespace Sample_Data_CosmosDB;
public class Bill
{
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("concept")]
public string Concept { get; set; }

[JsonProperty("amount")]
public double Amount { get; set; }
}
19 changes: 19 additions & 0 deletions samples/Data/Sample_Data_CosmosDB/Bills.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Encamina.Enmarcha.Data.Abstractions;

namespace Sample_Data_CosmosDB;

public class Bills
{
private readonly IAsyncRepository<Bill> billsRepository;

public Bills(IAsyncRepository<Bill> billsRepository)
{
this.billsRepository = billsRepository;
}

public async Task AddBillAsync(Bill bill, CancellationToken cancellationToken)
{
await billsRepository.AddAsync(bill, cancellationToken);
Console.WriteLine("Bill added");
}
}
62 changes: 62 additions & 0 deletions samples/Data/Sample_Data_CosmosDB/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Encamina.Enmarcha.Data.Abstractions;
using Encamina.Enmarcha.Data.Cosmos;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using Sample_Data_CosmosDB;

internal sealed class Program
{
private static async Task Main(string[] args)
{
var hostBuilder = new HostBuilder().ConfigureAppConfiguration((configuration) =>
{
configuration.AddJsonFile(path: @"appsettings.json", optional: false, reloadOnChange: true);
configuration.AddEnvironmentVariables();
});

hostBuilder.ConfigureServices((hostContext, services) =>
{
services.AddCosmos(hostContext.Configuration);
services.AddScoped<IAsyncRepository<Bill>>(sp => sp.GetRequiredService<ICosmosRepositoryFactory>()
.Create<Bill>(hostContext.Configuration.GetValue<string>("CosmosDBContainerName")));
});

var host = hostBuilder.Build();

while (true)
{
Console.WriteLine("Select an option:\n0 - Exit\n1 - Add bill\n2 - Watch bills\n");
var input = Console.ReadLine();
var repository = host.Services.GetRequiredService<IAsyncRepository<Bill>>();

switch (input)
{
case "1":
Console.WriteLine("Concept:");
var concept = Console.ReadLine();
Console.WriteLine("Amount:");
var amount = double.Parse(Console.ReadLine());
var bill = new Bill() { Id = Guid.NewGuid().ToString(), Concept = concept, Amount = amount };
await repository.AddAsync(bill, CancellationToken.None);
var bills = new Bills(host.Services.GetRequiredService<IAsyncRepository<Bill>>());
await bills.AddBillAsync(bill, CancellationToken.None);
break;
case "2":
var values = await repository.GetAllAsync(CancellationToken.None);
foreach (var value in values)
{
Console.WriteLine($"{value.Concept}: {value.Amount}");
}

break;
case "0":
return;
}

Console.WriteLine("\n");
}
}
}
Loading

0 comments on commit 57472e3

Please sign in to comment.