diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 610efe0..b3c5e9a 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -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: @@ -27,7 +26,7 @@ categories: - test - title: 👷 CI labels: - - ci + - ci - title: ♻️ Changes labels: - changed @@ -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' diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml new file mode 100644 index 0000000..f418cbb --- /dev/null +++ b/.github/workflows/build-publish-docker.yml @@ -0,0 +1,59 @@ +name: build-publish-docker + +on: + push: + branches: [ develop ] + pull_request: + +jobs: + + build-and-push-docker-image: + name: Build and Publish Docker image to DockerHub + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + + - name: Semantic Release Version + id: semantic-version + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # because of using none default (conventionalcommits) `preset` for `semantic-release`, we should add dependency `conventional-changelog-conventionalcommits` + # using dry-run here for preventing publish release note and just calculate version + run: npx -p @semantic-release/git -p @semantic-release/changelog -p @semantic-release/exec semantic-release --dry-run + + - name: Semantic Release Versions Outputs + run: | + echo ${{ steps.semantic-version.outputs.semantic_nextRelease_version }} + echo ${{ steps.semantic-version.outputs.semantic_nextRelease_channel }} + echo ${{ steps.semantic-version.outputs.semantic_nextRelease_gitTag }} + echo ${{ steps.semantic-version.outputs.semantic_lastRelease_version }} + echo ${{ steps.semantic-version.outputs.semantic_lastRelease_channel }} + echo ${{ steps.semantic-version.outputs.semantic_lastRelease_gitTag }} + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build image + run: | + docker build -t meysamh66/booking-microservices-flight:latest -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . + docker build -t meysamh66/booking-microservices-identity:latest -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . + docker build -t meysamh66/booking-microservices-passenger:latest -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . + docker build -t meysamh66/booking-microservices-booking:latest -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . + + - name: Publish image + run: | + docker push meysamh66/booking-microservices-flight:latest + docker push meysamh66/booking-microservices-identity:latest + docker push meysamh66/booking-microservices-passenger:latest + docker push meysamh66/booking-microservices-booking:latest + diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 731b8af..9d6567a 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -2,9 +2,9 @@ name: Build-Test on: push: - branches: [ "main" , "develop"] + branches: [ "main" , "develop" ] paths-ignore: - - "README.md" + - "README.md" pull_request: branches: [ "main" , "develop" ] @@ -14,15 +14,29 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 7.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build -c Release --no-restore - - name: Test - run: dotnet test -c Release --no-restore + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 7.0.x + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + + - 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 diff --git a/src/BuildingBlocks/PersistMessageProcessor/Data/PersistMessageDbContext.cs b/src/BuildingBlocks/PersistMessageProcessor/Data/PersistMessageDbContext.cs index 0b4df06..37a45cf 100644 --- a/src/BuildingBlocks/PersistMessageProcessor/Data/PersistMessageDbContext.cs +++ b/src/BuildingBlocks/PersistMessageProcessor/Data/PersistMessageDbContext.cs @@ -12,9 +12,17 @@ using Exception = System.Exception; public class PersistMessageDbContext : DbContext, IPersistMessageDbContext { + private readonly Lazy> _logger; + public PersistMessageDbContext(DbContextOptions options) : base(options) { + _logger = new Lazy>(() => + { + var factory = LoggerFactory.Create(b => b.AddConsole()); + var logger = factory.CreateLogger(); + return logger; + }); } public DbSet PersistMessages => Set(); @@ -37,10 +45,7 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext { if (exception != null) { - var factory = LoggerFactory.Create(b => b.AddConsole()); - var logger = factory.CreateLogger(); - - logger.LogError(exception, + _logger.Value.LogError(exception, "Request failed with {StatusCode}. Waiting {TimeSpan} before next retry. Retry attempt {RetryCount}.", HttpStatusCode.Conflict, timeSpan, @@ -55,12 +60,22 @@ public class PersistMessageDbContext : DbContext, IPersistMessageDbContext { 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); - if (databaseValues != null) + _logger.Value.LogInformation( + "Entry to entity with type: {Type}, database-value: {DatabaseValue} and current-value: {CurrentValue}", + entry.GetType().Name, + databaseValue, + currentValue); + + if (databaseValue != null) { - entry.OriginalValues.SetValues(databaseValues); + entry.OriginalValues.SetValues(databaseValue); + } + else + { + entry.OriginalValues.SetValues(currentValue); } }