Skip to content

Commit

Permalink
Merge pull request #124 from meysamhadeli/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
meysamhadeli authored Jan 25, 2023
2 parents 4352d62 + 3253502 commit 9988458
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 67 deletions.
21 changes: 10 additions & 11 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
# This release drafter follows the conventions from https://keepachangelog.com, https://common-changelog.org/
# https://www.conventionalcommits.org

name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'

template: |
## What Changed 👀
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
categories:
- title: 🚀 Features
labels:
Expand All @@ -27,7 +26,7 @@ categories:
- test
- title: 👷 CI
labels:
- ci
- ci
- title: ♻️ Changes
labels:
- changed
Expand Down Expand Up @@ -66,31 +65,31 @@ autolabeler:
- '/(security)\/.*/'
- label: 'refactor'
branch:
- '/(refactor)\/.*/'
- '/(refactor)\/.*/'
- label: 'docs'
branch:
- '/(docs)\/.*/'
- label: 'ci'
branch:
- '/(ci)\/.*/'
- '/(ci)\/.*/'
- label: 'test'
branch:
- '/(test)\/.*/'
- '/(test)\/.*/'
- label: 'bug'
branch:
- '/(fix)\/.*/'
- '/(fix)\/.*/'
- label: 'feature'
branch:
- '/(feat)\/.*/'
- label: 'minor'
branch:
- '/(feat)\/.*/'
- '/(feat)\/.*/'
- label: 'patch'
branch:
- '/(fix)\/.*/'
- '/(fix)\/.*/'
body:
- '/JIRA-[0-9]{1,4}/'

change-template: '- $TITLE (#$NUMBER)'
exclude-contributors:
- 'meysamhadeli'
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
push:
branches: [ "main" , "develop" ]
paths-ignore:
- "README.md"
pull_request:
branches: [ "main" , "develop" ]
paths-ignore:
- "README.md"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x

- name: Cache NuGet Packages
uses: actions/cache@v3
with:
key: ${{ runner.os }}-dotnet-nuget
path: ~/.nuget/packages

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test -c Release --no-restore

- name: Update Release Drafter
if: github.ref == 'refs/heads/main'
id: last_release
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Login to DockerHub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

##ref: https://docs.docker.com/language/golang/configure-ci-cd/
##ref: https://event-driven.io/en/how_to_buid_and_push_docker_image_with_github_actions
- name: Build Docker Image
if: github.ref == 'refs/heads/main'
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" .
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" .
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-passenger:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" .
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" .
- name: Publish Docker Image
if: github.ref == 'refs/heads/main'
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.last_release.outputs.tag_name }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:${{ steps.last_release.outputs.tag_name }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-passenger:${{ steps.last_release.outputs.tag_name }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:${{ steps.last_release.outputs.tag_name }}
28 changes: 0 additions & 28 deletions .github/workflows/dotnet.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/release-drafter.yml

This file was deleted.

Empty file added current-version.txt
Empty file.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "0.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public PersistMessageDbContext CreateDbContext(string[] args)

builder.UseNpgsql("Server=localhost;Port=5432;Database=persist_message;User Id=postgres;Password=postgres;Include Error Detail=true")
.UseSnakeCaseNamingConvention();
return new PersistMessageDbContext(builder.Options);
return new PersistMessageDbContext(builder.Options, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ namespace BuildingBlocks.PersistMessageProcessor.Data;

public class PersistMessageDbContext : DbContext, IPersistMessageDbContext
{
public PersistMessageDbContext(DbContextOptions<PersistMessageDbContext> options)
private readonly ILogger<PersistMessageDbContext> _logger;

public PersistMessageDbContext(DbContextOptions<PersistMessageDbContext> options,
ILogger<PersistMessageDbContext> logger)
: base(options)
{
_logger = logger;
}

public DbSet<PersistMessage> PersistMessages => Set<PersistMessage>();
Expand All @@ -37,10 +41,7 @@ public override async Task<int> SaveChangesAsync(CancellationToken cancellationT
{
if (exception != null)
{
var factory = LoggerFactory.Create(b => b.AddConsole());
var logger = factory.CreateLogger<PersistMessageDbContext>();

logger.LogError(exception,
_logger.LogError(exception,
"Request failed with {StatusCode}. Waiting {TimeSpan} before next retry. Retry attempt {RetryCount}.",
HttpStatusCode.Conflict,
timeSpan,
Expand All @@ -55,12 +56,22 @@ public override async Task<int> SaveChangesAsync(CancellationToken cancellationT
{
foreach (var entry in ex.Entries)
{
var currentEntity = entry.Entity; // we can use it for specific merging
var databaseValues = await entry.GetDatabaseValuesAsync(cancellationToken);
var currentValue = entry.Entity; // we can use it for specific merging
var databaseValue = await entry.GetDatabaseValuesAsync(cancellationToken);

_logger.LogInformation(
"Entry to entity with type: {Type}, database-value: {DatabaseValue} and current-value: {CurrentValue}",
entry.GetType().Name,
databaseValue,
currentValue);

if (databaseValues != null)
if (databaseValue != null)
{
entry.OriginalValues.SetValues(databaseValue);
}
else
{
entry.OriginalValues.SetValues(databaseValues);
entry.OriginalValues.SetValues(currentValue);
}
}

Expand Down

0 comments on commit 9988458

Please sign in to comment.