Skip to content

Add CI build workflow #16

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

Merged
merged 9 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ indent_style = space
tab_width = 4

# New line preferences
end_of_line = crlf
insert_final_newline = true
end_of_line = lf
insert_final_newline = false

#### .NET Coding Conventions ####

Expand Down Expand Up @@ -391,9 +391,6 @@ dotnet_diagnostic.S4136.severity = none
# S6605: Collection-specific "Exists" method should be used instead of the "Any" extension
dotnet_diagnostic.S6605.severity = none
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_null_propagation = true:error
dotnet_style_coalesce_expression = true:error
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
Expand All @@ -411,4 +408,4 @@ dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error
dotnet_style_predefined_type_for_locals_parameters_members = true:error
dotnet_style_predefined_type_for_locals_parameters_members = true:error
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
*.{ics,[iI][cC][sS]} text eol=crlf
*.sh text eol=lf
32 changes: 32 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Restore dependencies
run: dotnet restore KernelMemory.Ecommerce.Sample.sln

- name: Build
run: dotnet build --no-restore KernelMemory.Ecommerce.Sample.sln

- name: Check fomatting
run: dotnet format --verify-no-changes KernelMemory.Ecommerce.Sample.sln

- name: Test
run: dotnet test --no-build --verbosity normal KernelMemory.Ecommerce.Sample.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public class ProductSearchOptions
public required int SearchResultsLimit { get; init; }
[Required]
public required double MinSearchResultsRelevance { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static Error ReadRecordsFailed(Exception ex)
"CsvReader.ReadRecords.Failed",
$"An error occurred while parsing the CSV file. Details: {ex.Message}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public interface ICsvReader<TRecord>
{
Task<Result<IReadOnlyCollection<TRecord>>> ReadRecordsAsync(
Stream stream, CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ public interface IBaseCommand;
public interface ICommand<TResponse> : IRequest<Result<TResponse>>, IBaseCommand;

public interface ICommandHandler<in TCommand, TResponse> : IRequestHandler<TCommand, Result<TResponse>>
where TCommand : ICommand<TResponse>;
where TCommand : ICommand<TResponse>;
3 changes: 1 addition & 2 deletions src/KernelMemory.Ecommerce.Sample.Api/Application/IQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ namespace KernelMemory.Ecommerce.Sample.Api.Application;
public interface IQuery<TResponse> : IRequest<Result<TResponse>>;

public interface IQueryHandler<in TQuery, TResponse> : IRequestHandler<TQuery, Result<TResponse>>
where TQuery : IQuery<TResponse>;

where TQuery : IQuery<TResponse>;
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public async Task<Result<IReadOnlyCollection<string>>> Handle(ProductIngestionCo

return documentIds;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public async Task<Result<ProductSearchResponse>> Handle(
memoryAnswer.RelevantSources.Count,
foundProducts);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public static ProductSearchResponse NoProducts(double minRelevance)
RelevantSourcesCount: 0,
Products: []);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ public async Task<Result<ProductSearchResponse>> Handle(
searchResult.Results.Count,
foundProducts);
}
}
}
2 changes: 1 addition & 1 deletion src/KernelMemory.Ecommerce.Sample.Api/Domain/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public record Error(string Code, string Description)
{
public static readonly Error None = new(string.Empty, string.Empty);
public static readonly Error NullValue = new("General.Null", "Null value was provided");
}
}
2 changes: 1 addition & 1 deletion src/KernelMemory.Ecommerce.Sample.Api/Domain/Product.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public sealed record Product(
decimal Price,
string PriceCurrency,
int SupplyAbility,
int MinimumOrder);
int MinimumOrder);
3 changes: 1 addition & 2 deletions src/KernelMemory.Ecommerce.Sample.Api/Domain/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ public static implicit operator Result<TValue>(TValue? value) =>

public static Result<TValue> ValidationFailure(Error error) =>
new(default, false, error);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ public async Task<Result<IReadOnlyCollection<TRecord>>> ReadRecordsAsync(
return Result.Failure<IReadOnlyCollection<TRecord>>(error);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ public string ReadPrompt(string promptName)
_ => _fallbackProvider.ReadPrompt(promptName) // Fall back to the default
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static IResult Problem(string problemTitle, string problemDetail)
detail: problemDetail,
type: BadRequestRfc,
statusCode: StatusCodes.Status400BadRequest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ public static IApplicationBuilder MapEndpoints(

return app;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
public interface IEndpoint
{
void MapEndpoint(IEndpointRouteBuilder app);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ public void MapEndpoint(IEndpointRouteBuilder app)
})
.DisableAntiforgery();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public void MapEndpoint(IEndpointRouteBuilder app)
return Results.Ok(result.Value);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public void MapEndpoint(IEndpointRouteBuilder app)
return Results.Ok(result.Value);
});
}
}
}
2 changes: 1 addition & 1 deletion src/KernelMemory.Ecommerce.Sample.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ private static WebApplication BuildAsynchronousKernelMemoryApp(WebApplicationBui

return appBuilder.Build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection

return services;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
services.AddSingleton(ProductSearchOptions);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ private async Task<List<string>> ReadProductIdsFromCsv(string filePath)
var records = await csv.GetRecordsAsync<Product>().ToListAsync();
return records.Select(x => x.Id.ToString()).ToList();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ public async Task ProductRagSearch_WithCorrectResponseFromKernel_ReturnsOkResult
Assert.NotEmpty(searchResponse.Products);
Assert.Contains(product, searchResponse.Products);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ public async Task ProductRagSearch_WithCorrectResponseFromKernel_ReturnsOkResult
Assert.NotEmpty(searchResponse.Products);
Assert.Contains(product, searchResponse.Products);
}
}
}
Loading