Skip to content
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

ci: Add update-changelog and pr-title-checker #86

Merged
merged 2 commits into from
Jan 13, 2023
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
44 changes: 22 additions & 22 deletions .github/workflows/pr-title-checker.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 0 additions & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
on:
push:
branches:
- develop
- main

jobs:
Expand Down
54 changes: 27 additions & 27 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/BuildingBlocks/BuildingBlocks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
<ItemGroup>
<Folder Include="Contracts" />
<Folder Include="EventStoreDB\BackgroundWorkers" />
<Folder Include="PersistMessageProcessor\Data\Configurations" />
<Folder Include="PersistMessageProcessor\Data\Migrations" />
</ItemGroup>

Expand Down
32 changes: 32 additions & 0 deletions src/BuildingBlocks/EFCore/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace BuildingBlocks.EFCore;

using Humanizer;
using Microsoft.EntityFrameworkCore.Metadata;

public static class Extensions
{
public static IServiceCollection AddCustomDbContext<TContext>(
Expand Down Expand Up @@ -71,6 +74,35 @@ public static void FilterSoftDeletedProperties(this ModelBuilder modelBuilder)
}
}


//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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class initial : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "persistMessage",
name: "persist_message",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false),
Expand All @@ -33,7 +33,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "persistMessage");
name: "persist_message");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("Id")
.HasName("pk_persist_message");

b.ToTable("persistMessage", (string)null);
b.ToTable("persist_message", (string)null);
});
#pragma warning restore 612, 618
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ protected override void OnModelCreating(ModelBuilder builder)
{
builder.ApplyConfiguration(new PersistMessageConfiguration());
base.OnModelCreating(builder);
builder.ToSnakeCaseTables();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using BuildingBlocks.EFCore;
using Flight.Airports.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/Services/Flight/src/Flight/Data/FlightDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BuildingBlocks.EFCore;
using BuildingBlocks.Utils;
using BuildingBlocks.Web;
using Flight.Aircrafts.Models;
using Flight.Airports.Models;
Expand All @@ -8,12 +7,14 @@

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>();
Expand All @@ -24,5 +25,6 @@ protected override void OnModelCreating(ModelBuilder builder)
base.OnModelCreating(builder);
builder.FilterSoftDeletedProperties();
builder.ApplyConfigurationsFromAssembly(typeof(FlightRoot).Assembly);
builder.ToSnakeCaseTables();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.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 =>
Expand Down
27 changes: 1 addition & 26 deletions src/Services/Identity/src/Identity/Data/IdentityContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,8 @@ protected override void OnModelCreating(ModelBuilder builder)
{
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)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading