-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Encamina/@rliberoff/remove_build_and_test…
…_from_sonar_analysis @rliberoff/remove build and test from sonar analysis
- Loading branch information
Showing
78 changed files
with
1,030 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }} | ||
|
@@ -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 }} | ||
|
@@ -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 | ||
|
@@ -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] | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
Oops, something went wrong.