Skip to content

Commit

Permalink
Complete and finalize.
Browse files Browse the repository at this point in the history
Update the CI.
  • Loading branch information
chullybun committed Feb 26, 2024
1 parent fd142fd commit b7a34c2
Show file tree
Hide file tree
Showing 41 changed files with 283 additions and 221 deletions.
43 changes: 36 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jobs:
My_Hr_ConnectionStrings__Database: Data Source=localhost,1433;Initial Catalog=My.Hr;User id=sa;Password=sAPWD23.^0;TrustServerCertificate=true
MyEf_Hr_ConnectionStrings__Database: Data Source=localhost,1433;Initial Catalog=MyEf.Hr;User id=sa;Password=sAPWD23.^0;TrustServerCertificate=true
Bar_ConnectionStrings__Database: Data Source=localhost,1433;Initial Catalog=Foo.Bar;User id=sa;Password=sAPWD23.^0;TrustServerCertificate=true
Baz_ConnectionStrings__Database: Server=localhost;Port=3306;Database=Foo.Baz;Uid=ciuser;Pwd=ciStrong#!Password;AllowUserVariables=true;UseAffectedRows=false;
Bam_ConnectionStrings__Database: Server=localhost;Port=3306;Database=Foo.Bam;Uid=ciuser;Pwd=ciStrong#!Password;AllowUserVariables=true;UseAffectedRows=false;
Bap_ConnectionStrings__Database: Server=localhost;Port=5432;Database=Foo.Bap;User Id=postgres;Pwd=ciStrong#!Password;
Cdr_CosmosConnectionString: ${{ secrets.COSMOS_CONNECTION_STRING }}

services:
Expand All @@ -42,11 +43,19 @@ jobs:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: yourStrong#!Password
MYSQL_DATABASE: Foo.Baz
MYSQL_DATABASE: Foo.Bam
MYSQL_USER: ciuser
MYSQL_PASSWORD: ciStrong#!Password
options: --name mysql

postgres:
image: postgres:latest
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: ciStrong#!Password
options: --name postgres

steps:
- uses: actions/checkout@v4

Expand All @@ -66,6 +75,7 @@ jobs:
dotnet restore ./tools/Beef.Database.Core
dotnet restore ./tools/Beef.Database.SqlServer
dotnet restore ./tools/Beef.Database.MySql
dotnet restore ./tools/Beef.Database.Postgres
dotnet restore ./tools/Beef.Test.NUnit
dotnet restore ./templates/Beef.Template.Solution
Expand All @@ -75,6 +85,7 @@ jobs:
dotnet build ./tools/Beef.Database.Core --no-restore
dotnet build ./tools/Beef.Database.SqlServer --no-restore
dotnet build ./tools/Beef.Database.MySql --no-restore
dotnet build ./tools/Beef.Database.Postgres --no-restore
dotnet build ./tools/Beef.Test.NUnit --no-restore
dotnet build ./templates/Beef.Template.Solution --no-restore
Expand All @@ -85,6 +96,7 @@ jobs:
dotnet pack ./tools/Beef.Database.Core --output ./packages --configuration Debug --no-build
dotnet pack ./tools/Beef.Database.SqlServer --output ./packages --configuration Debug --no-build
dotnet pack ./tools/Beef.Database.MySql --output ./packages --configuration Debug --no-build
dotnet pack ./tools/Beef.Database.Postgres --output ./packages --configuration Debug --no-build
dotnet pack ./tools/Beef.Test.NUnit --output ./packages --configuration Debug --no-build
dotnet pack ./templates/Beef.Template.Solution --output ./packages --configuration Debug --no-build
dotnet new nugetconfig
Expand Down Expand Up @@ -254,18 +266,35 @@ jobs:
# Template - MySQL with Entity Framework

- name: Template/MySQL/Ef create
run: dotnet new beef --company Foo.My --appname Baz --datasource MySQL --output Foo.My.Baz
run: dotnet new beef --company Foo.My --appname Bam --datasource MySQL --output Foo.My.Bam

- name: Template/MySQL/Ef database
working-directory: ./Foo.My.Baz/Foo.My.Baz.Database
run: dotnet run dropandall --connection-varname Baz_ConnectionStrings__Database --accept-prompts
working-directory: ./Foo.My.Bam/Foo.My.Bam.Database
run: dotnet run dropandall --connection-varname Bam_ConnectionStrings__Database --accept-prompts

- name: Template/MySQL/Ef code-gen
working-directory: ./Foo.My.Baz/Foo.My.Baz.CodeGen
working-directory: ./Foo.My.Bam/Foo.My.Bam.CodeGen
run: dotnet run all

- name: Template/MySQL/Ef test
working-directory: ./Foo.My.Baz
working-directory: ./Foo.My.Bam
run: dotnet test

# Template - Postgres with Entity Framework

- name: Template/Postgres/Ef create
run: dotnet new beef --company Foo.Ps --appname Bap --datasource Postgres --output Foo.Ps.Bap

- name: Template/Postgres/Ef database
working-directory: ./Foo.Ps.Bap/Foo.Ps.Bap.Database
run: dotnet run dropandall --connection-varname Bap_ConnectionStrings__Database --accept-prompts

- name: Template/Postgres/Ef code-gen
working-directory: ./Foo.Ps.Bap/Foo.Ps.Bap.CodeGen
run: dotnet run all

- name: Template/Postgres/Ef test
working-directory: ./Foo.Ps.Bap
run: dotnet test

# Template - HttpAgent
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Represents the **NuGet** versions.
- Leverages both `CoreEx.Database.Postgres` (runtime) and `DbEx.Postgres` (migration) packages; encapsulates the `Npgsql` package.
- The `Npgsql.EntityFrameworkCore.PostgreSQL` packages is used for the entity framework provider.
- The `dotnet new beef` template updated to support new `datasource` option of `postgres`.
- *Enhancement:* Additional improvements for data migration and code-generation, including `SqlServer` and `MySql`, as a result of `DbEx` (`v2.5.0`) enhancements.

## v5.9.1
- *Fixed:* Simplified YAML specification where _only_ a custom manager is required to be implemented. For an `operation` set `type: CustomManagerOnly`, this is a shorthand for `type: Custom, managerCustom: true, excludeIDataSvc: true, excludeDataSvc: true, excludeIData: true, excludeData: true` (i.e. these other properties will no longer need to be set explicitly).
Expand Down
2 changes: 1 addition & 1 deletion samples/MyEf.Hr/MyEf.Hr.Business/HrSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class HrSettings : SettingsBase
/// <summary>
/// Gets the setting prefixes in order of precedence.
/// </summary>
public static string[] Prefixes { get; } = { "Hr/", "Common/" };
public static string[] Prefixes { get; } = ["Hr/", "Common/"];

/// <summary>
/// Initializes a new instance of the <see cref="HrSettings"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SecuritySettings : SettingsBase
/// <summary>
/// Gets the setting prefixes in order of precedence.
/// </summary>
public static string[] Prefixes { get; } = { "Security/", "Common/" };
public static string[] Prefixes { get; } = ["Security/", "Common/"];

/// <summary>
/// Initializes a new instance of the <see cref="SecuritySettings"/> class.
Expand Down
4 changes: 2 additions & 2 deletions samples/MyEf.Hr/MyEf.Hr.Test/Apis/EmployeeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void A160_Get_IncludeFields()
{
Agent<EmployeeAgent>()
.ExpectStatusCode(HttpStatusCode.OK)
.Run(a => a.GetAsync(1.ToGuid(), new HttpRequestOptions().Include(new string[] { "firstName", "lastName" })))
.Run(a => a.GetAsync(1.ToGuid(), new HttpRequestOptions().Include(["firstName", "lastName"])))
.AssertJson("{\"firstName\":\"Wendy\",\"lastName\":\"Jones\"}");
}

Expand Down Expand Up @@ -473,7 +473,7 @@ public void E110_Delete()
StartDate = DateTime.UtcNow.AddDays(1),
PhoneNo = "(456) 789 0123",
Address = new Address { Street1 = "2732 85 PL NE", City = "Bellevue", State = "WA", PostCode = "98101" },
EmergencyContacts = new EmergencyContactCollection { new EmergencyContact { FirstName = "Danny", LastName = "Keen", PhoneNo = "(234) 297 9834", Relationship = "FRD" } }
EmergencyContacts = [new EmergencyContact { FirstName = "Danny", LastName = "Keen", PhoneNo = "(234) 297 9834", Relationship = "FRD" }]
};

// Create an employee in the future.
Expand Down
10 changes: 5 additions & 5 deletions samples/MyEf.Hr/MyEf.Hr.Test/Validators/EmployeeValidatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void A150_Validate_Address_OK()
public void A160_Validate_Contacts_Empty()
{
var e = CreateValidEmployee();
e.EmergencyContacts = new EmergencyContactCollection { new EmergencyContact() };
e.EmergencyContacts = [new EmergencyContact()];

using var test = GenericTester.Create();

Expand All @@ -161,16 +161,16 @@ public void A160_Validate_Contacts_Empty()
public void A170_Validate_Contacts_Invalid()
{
var e = CreateValidEmployee();
e.EmergencyContacts = new EmergencyContactCollection
{
e.EmergencyContacts =
[
new EmergencyContact
{
FirstName = "Brian",
LastName = "Bellows",
PhoneNo = "425 333 4445",
Relationship = "XX"
}
};
];

using var test = GenericTester.Create();

Expand All @@ -183,7 +183,7 @@ public void A170_Validate_Contacts_Invalid()
public void A180_Validate_Contacts_TooMany()
{
var e = CreateValidEmployee();
e.EmergencyContacts = new EmergencyContactCollection();
e.EmergencyContacts = [];

for (int i = 0; i < 6; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
</ItemGroup>

<ItemGroup>
<None Remove="content\company.appname.services\Company.AppName.Services.csproj" />
<None Remove="content\Company.AppName.Test\appsettings.unittest.json" />
</ItemGroup>

<ItemGroup>
<Folder Include="content\Company.AppName.Services\" />
</ItemGroup>

<Import Project="..\..\Common.targets" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<ImplicitUsings>true</ImplicitUsings>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx.Azure" Version="CoreExVersion" />
<PackageReference Include="CoreEx.Validation" Version="CoreExVersion" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.16.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Company.AppName.Business\Company.AppName.Business.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void B110_Create()
.ExpectETag()
.ExpectIdentifier()
.ExpectValue(_ => v)
.ExpectEvent("Company.AppName.Person".ToLowerInvariant(), "created")
.ExpectEvent("lowercom.lowerapp.person", "created")
.Run(a => a.CreateAsync(v)).Value!;
// Check the value was created properly.
Expand Down Expand Up @@ -318,7 +318,7 @@ public void C130_Update()
.ExpectETag(v.ETag)
.ExpectIdentifier()
.ExpectValue(_ => v)
.ExpectEvent($"Company.AppName.Person".ToLowerInvariant(), "updated")
.ExpectEvent("lowercom.lowerapp.person", "updated")
.Run(a => a.UpdateAsync(v, id)).Value!;
// Check the value was updated properly.
Expand Down Expand Up @@ -409,7 +409,7 @@ public void D130_Patch()
.ExpectETag(v.ETag)
.ExpectIdentifier()
.ExpectValue(_ => v)
.ExpectEvent($"Company.AppName.Person".ToLowerInvariant(), "updated")
.ExpectEvent("lowercom.lowerapp.person", "updated")
.Run(a => a.PatchAsync(HttpPatchOption.MergePatch, $"{{ \"lastName\": \"{v.LastName}\" }}", id, new HttpRequestOptions { ETag = v.ETag })).Value!;
// Check the value was updated properly.
Expand Down Expand Up @@ -444,7 +444,7 @@ public void E110_Delete()
// Delete value.
Agent<PersonAgent>()
.ExpectStatusCode(HttpStatusCode.NoContent)
.ExpectEvent($"Company.AppName.Person".ToLowerInvariant(), "deleted")
.ExpectEvent("lowercom.lowerapp.person", "deleted")
.Run(a => a.DeleteAsync(id));
// Check value no longer exists.
Expand Down
21 changes: 21 additions & 0 deletions templates/Beef.Template.Solution/content/Company.AppName.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Company.AppName.Database", "Company.AppName.Database\Company.AppName.Database.csproj", "{36A5A8B9-0139-4C49-90FB-E521A4B89329}"
EndProject
//#endif
//#if (implement_subscriber)
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Company.AppName.Services", "Company.AppName.Services\Company.AppName.Services.csproj", "{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}"
EndProject
//#endif
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -103,6 +107,20 @@ Global
{36A5A8B9-0139-4C49-90FB-E521A4B89329}.Release|x64.Build.0 = Release|Any CPU
{36A5A8B9-0139-4C49-90FB-E521A4B89329}.Release|x86.ActiveCfg = Release|Any CPU
{36A5A8B9-0139-4C49-90FB-E521A4B89329}.Release|x86.Build.0 = Release|Any CPU
//#endif
//#if (implement_subscriber)
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Debug|x64.ActiveCfg = Debug|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Debug|x64.Build.0 = Debug|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Debug|x86.ActiveCfg = Debug|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Debug|x86.Build.0 = Debug|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Release|Any CPU.Build.0 = Release|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Release|x64.ActiveCfg = Release|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Release|x64.Build.0 = Release|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Release|x86.ActiveCfg = Release|Any CPU
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE}.Release|x86.Build.0 = Release|Any CPU
//#endif
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
Expand All @@ -113,6 +131,9 @@ Global
{A65032E5-F3FC-4963-B135-E462190D0ABC} = {A4E363CD-D0BE-4B43-9C80-18EA6CD2FAA6}
//#if (implement_database || implement_entityframework)
{36A5A8B9-0139-4C49-90FB-E521A4B89329} = {A4E363CD-D0BE-4B43-9C80-18EA6CD2FAA6}
//#endif
//#if (implement_subscriber)
{289B0EC4-5CED-4DE4-B56E-F94A2DE568EE} = {A4E363CD-D0BE-4B43-9C80-18EA6CD2FAA6}
//#endif
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
2 changes: 1 addition & 1 deletion tools/Beef.CodeGen.Core/CodeGenConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class CodeGenConsole : OnRamp.Console.CodeGenConsole
/// <param name="apiName">The Web API name.</param>
/// <param name="outputDirectory">The output path/directory; defaults to the resulting <see cref="OnRamp.Console.CodeGenConsole.GetBaseExeDirectory"/> <see cref="DirectoryInfo.Parent"/>.</param>
/// <returns>The <see cref="CodeGenConsole"/> instance.</returns>
public static CodeGenConsole Create(string company, string appName, string apiName = "Api", string? outputDirectory = null) => Create(new Assembly[] { Assembly.GetCallingAssembly() }, company, appName, apiName, outputDirectory);
public static CodeGenConsole Create(string company, string appName, string apiName = "Api", string? outputDirectory = null) => Create([Assembly.GetCallingAssembly()], company, appName, apiName, outputDirectory);

/// <summary>
/// Creates a new instance of the <see cref="CodeGenConsole"/> class.
Expand Down
2 changes: 1 addition & 1 deletion tools/Beef.CodeGen.Core/CodeGenFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static class CodeGenFileManager
/// <returns>The filename</returns>
public static string GetConfigFilename(string directory, CommandType type, string company, string appName)
{
List<string> files = new();
List<string> files = [];
foreach (var n in GetConfigFilenames(type))
{
var fi = new FileInfo(Path.Combine(directory, n.Replace("{{Company}}", company, StringComparison.OrdinalIgnoreCase).Replace("{{AppName}}", appName, StringComparison.OrdinalIgnoreCase)));
Expand Down
Loading

0 comments on commit b7a34c2

Please sign in to comment.