Merge pull request #86 from meysamhadeli/ci/add_change_log

ci: Add update-changelog and pr-title-checker
This commit is contained in:
Meysam Hadeli 2023-01-13 23:57:31 +03:30 committed by GitHub
commit 6df1d6cee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 105 additions and 95 deletions

View File

@ -1,23 +1,23 @@
name: Check PR title
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
title-checker:
name: Check PR title
runs-on: [ self-hosted ]
steps:
- uses: aslafy-z/conventional-pr-title-action@v2
env:
name: Check PR title
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
title-checker:
name: Check PR title
runs-on: [ self-hosted ]
steps:
- uses: aslafy-z/conventional-pr-title-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -5,7 +5,6 @@
on:
push:
branches:
- develop
- main
jobs:

View File

@ -1,28 +1,28 @@
name: Update Changelog
on:
release:
types:
- released
jobs:
update:
name: Update Changelog
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.name }}
release-notes: ${{ github.event.release.body }}
- name: Commit updated Changelog
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: 'docs(changelog): update changelog'
name: Update Changelog
on:
release:
types:
- released
jobs:
update:
name: Update Changelog
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.name }}
release-notes: ${{ github.event.release.body }}
- name: Commit updated Changelog
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: 'docs(changelog): update changelog'
file_pattern: CHANGELOG.md

View File

@ -152,6 +152,7 @@
<ItemGroup>
<Folder Include="Contracts" />
<Folder Include="EventStoreDB\BackgroundWorkers" />
<Folder Include="PersistMessageProcessor\Data\Configurations" />
<Folder Include="PersistMessageProcessor\Data\Migrations" />
</ItemGroup>

View File

@ -11,6 +11,9 @@ using Microsoft.Extensions.Hosting;
namespace BuildingBlocks.EFCore;
using Humanizer;
using Microsoft.EntityFrameworkCore.Metadata;
public static class Extensions
{
public static IServiceCollection AddCustomDbContext<TContext>(
@ -71,6 +74,35 @@ public static class Extensions
}
}
//ref: https://andrewlock.net/customising-asp-net-core-identity-ef-core-naming-conventions-for-postgresql/
public static void ToSnakeCaseTables(this ModelBuilder modelBuilder)
{
foreach (var entity in modelBuilder.Model.GetEntityTypes())
{
// Replace table names
entity.SetTableName(entity.GetTableName()?.Underscore());
var tableObjectIdentifier = StoreObjectIdentifier.Table(entity.GetTableName()?.Underscore()!, entity.GetSchema());
// Replace column names
foreach (var property in entity.GetProperties())
{
property.SetColumnName(property.GetColumnName(tableObjectIdentifier)?.Underscore());
}
foreach (var key in entity.GetKeys())
{
key.SetName(key.GetName()?.Underscore());
}
foreach (var key in entity.GetForeignKeys())
{
key.SetConstraintName(key.GetConstraintName()?.Underscore());
}
}
}
private static async Task MigrateDatabaseAsync<TContext>(IServiceProvider serviceProvider)
where TContext : DbContext, IDbContext
{

View File

@ -7,7 +7,7 @@ public class PersistMessageConfiguration : IEntityTypeConfiguration<PersistMessa
{
public void Configure(EntityTypeBuilder<PersistMessage> builder)
{
builder.ToTable("persistMessage");
builder.ToTable(nameof(PersistMessage));
builder.HasKey(x => x.Id);

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
{
[DbContext(typeof(PersistMessageDbContext))]
[Migration("20230113134415_initial")]
[Migration("20230113183839_initial")]
partial class initial
{
/// <inheritdoc />
@ -64,7 +64,7 @@ namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
b.HasKey("Id")
.HasName("pk_persist_message");
b.ToTable("persistMessage", (string)null);
b.ToTable("persist_message", (string)null);
});
#pragma warning restore 612, 618
}

View File

@ -12,7 +12,7 @@ namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "persistMessage",
name: "persist_message",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false),
@ -33,7 +33,7 @@ namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "persistMessage");
name: "persist_message");
}
}
}

View File

@ -61,7 +61,7 @@ namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
b.HasKey("Id")
.HasName("pk_persist_message");
b.ToTable("persistMessage", (string)null);
b.ToTable("persist_message", (string)null);
});
#pragma warning restore 612, 618
}

View File

@ -15,5 +15,6 @@ public class PersistMessageDbContext : AppDbContextBase, IPersistMessageDbContex
{
builder.ApplyConfiguration(new PersistMessageConfiguration());
base.OnModelCreating(builder);
builder.ToSnakeCaseTables();
}
}

View File

@ -8,7 +8,7 @@ public class AircraftConfiguration : IEntityTypeConfiguration<Aircraft>
{
public void Configure(EntityTypeBuilder<Aircraft> builder)
{
builder.ToTable("aircraft");
builder.ToTable(nameof(Aircraft));
builder.HasKey(r => r.Id);
builder.Property(r => r.Id).ValueGeneratedNever();
}

View File

@ -1,4 +1,3 @@
using BuildingBlocks.EFCore;
using Flight.Airports.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@ -9,7 +8,7 @@ public class AirportConfiguration: IEntityTypeConfiguration<Airport>
{
public void Configure(EntityTypeBuilder<Airport> builder)
{
builder.ToTable("airport");
builder.ToTable(nameof(Airport));
builder.HasKey(r => r.Id);
builder.Property(r => r.Id).ValueGeneratedNever();

View File

@ -12,7 +12,7 @@ public class FlightConfiguration : IEntityTypeConfiguration<Flights.Models.Fligh
{
public void Configure(EntityTypeBuilder<Flights.Models.Flight> builder)
{
builder.ToTable("flight");
builder.ToTable(nameof(Flight));
builder.HasKey(r => r.Id);
builder.Property(r => r.Id).ValueGeneratedNever();

View File

@ -11,7 +11,7 @@ public class SeatConfiguration : IEntityTypeConfiguration<Seat>
{
public void Configure(EntityTypeBuilder<Seat> builder)
{
builder.ToTable("seat");
builder.ToTable(nameof(Seat));
builder.HasKey(r => r.Id);
builder.Property(r => r.Id).ValueGeneratedNever();

View File

@ -1,5 +1,4 @@
using BuildingBlocks.EFCore;
using BuildingBlocks.Utils;
using BuildingBlocks.Web;
using Flight.Aircrafts.Models;
using Flight.Airports.Models;
@ -8,12 +7,14 @@ using Microsoft.EntityFrameworkCore;
namespace Flight.Data;
public sealed class FlightDbContext : AppDbContextBase
{
public FlightDbContext(DbContextOptions<FlightDbContext> options, ICurrentUserProvider currentUserProvider) : base(
options, currentUserProvider)
{
}
public DbSet<Flights.Models.Flight> Flights => Set<Flights.Models.Flight>();
public DbSet<Airport> Airports => Set<Airport>();
public DbSet<Aircraft> Aircraft => Set<Aircraft>();
@ -24,5 +25,6 @@ public sealed class FlightDbContext : AppDbContextBase
base.OnModelCreating(builder);
builder.FilterSoftDeletedProperties();
builder.ApplyConfigurationsFromAssembly(typeof(FlightRoot).Assembly);
builder.ToSnakeCaseTables();
}
}

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Flight.Data.Migrations
{
[DbContext(typeof(FlightDbContext))]
[Migration("20230113134450_Init")]
[Migration("20230113183335_Init")]
partial class Init
{
/// <inheritdoc />
@ -281,7 +281,7 @@ namespace Flight.Data.Migrations
.HasForeignKey("ArriveAirportId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_flight_airport_airport_id");
.HasConstraintName("fk_flight_airport_arrive_airport_id");
});
modelBuilder.Entity("Flight.Seats.Models.Seat", b =>

View File

@ -83,7 +83,7 @@ namespace Flight.Data.Migrations
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_flight_airport_airport_id",
name: "fk_flight_airport_arrive_airport_id",
column: x => x.arriveairportid,
principalTable: "airport",
principalColumn: "id",

View File

@ -278,7 +278,7 @@ namespace Flight.Data.Migrations
.HasForeignKey("ArriveAirportId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_flight_airport_airport_id");
.HasConstraintName("fk_flight_airport_arrive_airport_id");
});
modelBuilder.Entity("Flight.Seats.Models.Seat", b =>

View File

@ -34,33 +34,8 @@ public sealed class IdentityContext : IdentityDbContext<ApplicationUser, Identit
{
builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
base.OnModelCreating(builder);
// https://andrewlock.net/customising-asp-net-core-identity-ef-core-naming-conventions-for-postgresql/
foreach (var entity in builder.Model.GetEntityTypes())
{
// Replace table names
entity.SetTableName(entity.GetTableName()?.Underscore());
var identityObjectIdentifier = StoreObjectIdentifier.Table(entity.GetTableName()?.Underscore()!, entity.GetSchema());
// Replace column names
foreach (var property in entity.GetProperties())
{
property.SetColumnName(property.GetColumnName(identityObjectIdentifier)?.Underscore());
}
foreach (var key in entity.GetKeys())
{
key.SetName(key.GetName()?.Underscore());
}
foreach (var key in entity.GetForeignKeys())
{
key.SetConstraintName(key.GetConstraintName()?.Underscore());
}
}
builder.FilterSoftDeletedProperties();
builder.ToSnakeCaseTables();
}
public async Task BeginTransactionAsync(CancellationToken cancellationToken = default)

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Identity.Data.Migrations
{
[DbContext(typeof(IdentityContext))]
[Migration("20230113134523_initial")]
[Migration("20230113183552_initial")]
partial class initial
{
/// <inheritdoc />

View File

@ -8,7 +8,7 @@ public class PassengerConfiguration: IEntityTypeConfiguration<Passengers.Models.
{
public void Configure(EntityTypeBuilder<Passengers.Models.Passenger> builder)
{
builder.ToTable("passenger");
builder.ToTable(nameof(Passenger));
builder.HasKey(r => r.Id);
builder.Property(r => r.Id).ValueGeneratedNever();

View File

@ -12,7 +12,7 @@ using Passenger.Data;
namespace Passenger.Data.Migrations
{
[DbContext(typeof(PassengerDbContext))]
[Migration("20230113134610_initial")]
[Migration("20230113183717_initial")]
partial class initial
{
/// <inheritdoc />

View File

@ -17,5 +17,6 @@ public sealed class PassengerDbContext : AppDbContextBase
{
builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
base.OnModelCreating(builder);
builder.ToSnakeCaseTables();
}
}