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

Add Masstransit to handle events #168

Merged
merged 5 commits into from
Nov 12, 2024
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
12 changes: 4 additions & 8 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
MYSQL_SERVER=localhost
MYSQL_DATABASE=techchallenge
MYSQL_PORT=3306
MYSQL_USERID=techchallenge
MYSQL_PASSWORD=techchallengeFIAP
MercadoPago_WebhookSecret=1231231231232
MercadoPago_AccessToken=APP_USR-
MercadoPago_NotificationUrl=https://a42d-mercadopago
HybridCache_Expiration=01:00:00
HybridCache_LocalCacheExpiration=01:00:00
HybridCache_Flags=DisableDistributedCache
JwtOptions__Issuer=https://localhost:7000
JwtOptions__Audience=https://localhost:7000
JwtOptions__ExpirationSeconds=300
JwtOptions__UseAccessToken=false
63 changes: 53 additions & 10 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,47 @@ jobs:
dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

semantic-release:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
name: Create Semantic Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
outputs:
version: ${{ steps.semantic-release.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Install dependencies
run: npm clean-install

- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures

- name: Release
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release
VERSION=$(cat VERSION)
echo "Resolved version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT

build-docker-image:
if: github.ref == 'refs/heads/main'
needs: [build]
needs: semantic-release
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -142,6 +179,13 @@ jobs:
API_IMAGE_TAG: ${{ fromJson(steps.meta.outputs.json).tags[0] }}

steps:
- name: Extract version
id: sanitize-version
run: |
echo ${{ needs.semantic-release.outputs.version }}
TAG=${{ needs.semantic-release.outputs.version }}
echo "version=${TAG#v}" >> $GITHUB_OUTPUT

Comment on lines +182 to +188
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for version extraction.

The version extraction step should validate the semantic-release output to prevent potential failures.

- echo ${{ needs.semantic-release.outputs.version }}
- TAG=${{ needs.semantic-release.outputs.version }}
- echo "version=${TAG#v}" >> $GITHUB_OUTPUT
+ if [ -z "${{ needs.semantic-release.outputs.version }}" ]; then
+   echo "Error: No version output from semantic-release"
+   exit 1
+ fi
+ TAG="${{ needs.semantic-release.outputs.version }}"
+ echo "version=${TAG#v}" >> $GITHUB_OUTPUT
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Extract version
id: sanitize-version
run: |
echo ${{ needs.semantic-release.outputs.version }}
TAG=${{ needs.semantic-release.outputs.version }}
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
- name: Extract version
id: sanitize-version
run: |
if [ -z "${{ needs.semantic-release.outputs.version }}" ]; then
echo "Error: No version output from semantic-release"
exit 1
fi
TAG="${{ needs.semantic-release.outputs.version }}"
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
🧰 Tools
🪛 actionlint

184-184: shellcheck reported issue in this script: SC2086:info:3:28: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint

[warning] 182-182: wrong indentation: expected 4 but found 6

(indentation)

- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -156,12 +200,12 @@ jobs:
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -171,21 +215,22 @@ jobs:
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=true
tags: type=sha
tags: |
type=raw,value=${{ steps.sanitize-version.outputs.version }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
uses: docker/build-push-action@v5
with:
context: .
file: ./src/FIAP.TechChallenge.ByteMeBurger.Api/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
file: ./src/Bmb.Payment.Api/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand Down Expand Up @@ -213,8 +258,6 @@ jobs:
cat <<EOF > tf/api.auto.tfvars
eks_cluster_name = "${{ vars.BMB_EKS_CLUSTER_NAME }}"
apgw_name ="${{ vars.BMB_AUTH_API_NAME }}"
mercadopago_webhook_secret = "${{ secrets.BMB_MERCADO_PAGO_WH_SECRET }}"
mercadopago_accesstoken = "${{ secrets.BMB_MERCADO_PAGO_ACCESS_TOKEN }}"
jwt_signing_key = "${{ secrets.BMB_JWT_SECRET_KEY }}"
jwt_issuer = "${{ vars.BMB_JWT_ISSUER }}"
jwt_aud = "${{ vars.BMB_JWT_AUDIENCE }}"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/terraform-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ jobs:
cat <<EOF > tf/api.auto.tfvars
eks_cluster_name = "${{ vars.BMB_EKS_CLUSTER_NAME }}"
apgw_name = "${{ vars.BMB_JWT_ISSUER }}"
mercadopago_webhook_secret = "${{ secrets.BMB_MERCADO_PAGO_WH_SECRET}}"
mercadopago_accesstoken = "${{ secrets.BMB_MERCADO_PAGO_ACCESS_TOKEN }}"
jwt_signing_key = "${{ secrets.BMB_JWT_SECRET_KEY }}"
jwt_issuer = "${{ vars.BMB_JWT_ISSUER }}"
jwt_aud = "${{ vars.BMB_JWT_AUDIENCE }}"
Expand Down
18 changes: 18 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"branches": [
"main",
"semantic-release-plugins"
],
Comment on lines +2 to +5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remove "semantic-release-plugins" from release branches

The "semantic-release-plugins" branch doesn't exist in the repository, and there's no historical context justifying its inclusion in the release configuration. This appears to be an unintended inclusion that should be removed to prevent potential issues with semantic releases.

  • Remove "semantic-release-plugins" from the "branches" array in .releaserc, keeping only "main" as the release branch.
🔗 Analysis chain

Verify the purpose of "semantic-release-plugins" branch

The inclusion of "semantic-release-plugins" as a release branch seems unusual. This appears to be a feature or temporary branch rather than a long-term release branch. Consider limiting releases to the "main" branch only, unless there's a specific reason for maintaining multiple release branches.

Run the following script to check the branch usage:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if semantic-release-plugins branch exists and its commit history

# Check branch existence and last commit
git branch -a | grep semantic-release-plugins
git log --oneline semantic-release-plugins 2>/dev/null || echo "Branch not found"

Length of output: 135


Script:

#!/bin/bash
# Let's check the git history to understand the context of this configuration
git log --all --full-history -- .releaserc

# Also check if there are any related pull requests
gh pr list --state all --search "semantic-release"

Length of output: 440

"tagFormat": "v${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"@semantic-release/exec",
{
"verifyReleaseCmd": "echo v${nextRelease.version} > VERSION"
}
]
]
}
25 changes: 2 additions & 23 deletions FIAP.TechChallenge.ByteMeBurger.sln
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{80
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.Persistence.Test", "tests\FIAP.TechChallenge.ByteMeBurger.Persistence.Test\FIAP.TechChallenge.ByteMeBurger.Persistence.Test.csproj", "{81F17B4E-ACC8-4640-9F1A-1068600019DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.MercadoPago.Gateway", "src\FIAP.TechChallenge.ByteMeBurger.MercadoPago.Gateway\FIAP.TechChallenge.ByteMeBurger.MercadoPago.Gateway.csproj", "{A8FC6701-D7C9-4342-B68A-4FE1538567DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.MercadoPago.Gateway.Test", "tests\FIAP.TechChallenge.ByteMeBurger.MercadoPago.Gateway.Test\FIAP.TechChallenge.ByteMeBurger.MercadoPago.Gateway.Test.csproj", "{F4A45D35-A1C8-4E65-8BAC-1670D5AEE1D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.DI", "src\FIAP.TechChallenge.ByteMeBurger.DI\FIAP.TechChallenge.ByteMeBurger.DI.csproj", "{207C0604-793B-4829-A407-6385E2457A03}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.Controllers", "src\FIAP.TechChallenge.ByteMeBurger.Controllers\FIAP.TechChallenge.ByteMeBurger.Controllers.csproj", "{3EF147B0-B21A-4D6F-940F-CD211D795C92}"
Expand All @@ -71,11 +67,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBu
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.Test.Common", "tests\FIAP.TechChallenge.ByteMeBurger.Test.Common\FIAP.TechChallenge.ByteMeBurger.Test.Common.csproj", "{69ADCE8B-AF58-4C54-B79A-547B6E2807C5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.FakePayment.Gateway", "src\FIAP.TechChallenge.ByteMeBurger.FakePayment.Gateway\FIAP.TechChallenge.ByteMeBurger.FakePayment.Gateway.csproj", "{3F7DD0CF-E214-4EF2-90F8-C9A0DFDA8EDA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.Publisher.Sqs", "src\FIAP.TechChallenge.ByteMeBurger.Publisher.Sqs\FIAP.TechChallenge.ByteMeBurger.Publisher.Sqs.csproj", "{9E8287AF-C7A6-46A6-96D8-8460642ADE4B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.Masstransit", "src\FIAP.TechChallenge.ByteMeBurger.Masstransit\FIAP.TechChallenge.ByteMeBurger.Masstransit.csproj", "{9E8287AF-C7A6-46A6-96D8-8460642ADE4B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.Publisher.Sqs.Test", "tests\FIAP.TechChallenge.ByteMeBurger.Publisher.Sqs.Test\FIAP.TechChallenge.ByteMeBurger.Publisher.Sqs.Test.csproj", "{93545102-0476-48CB-8074-5C71AC81E040}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FIAP.TechChallenge.ByteMeBurger.Masstransit.Test", "tests\FIAP.TechChallenge.ByteMeBurger.Masstransit.Test\FIAP.TechChallenge.ByteMeBurger.Masstransit.Test.csproj", "{93545102-0476-48CB-8074-5C71AC81E040}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "terraform", "terraform", "{B2898AA3-86A6-4AF1-B27F-A3706B2B0557}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -106,11 +100,8 @@ Global
{EDD56D7F-40E4-4422-AF23-CAF55957B40F} = {8000B4F6-1D23-4609-A276-5C8C37374B71}
{09D890C7-7AA0-40E2-8AA6-6DD47462548D} = {5EC029C6-230A-4782-9B62-CB475C7D05F8}
{81F17B4E-ACC8-4640-9F1A-1068600019DE} = {C244E1D6-E1EB-4314-9F39-BB59FA1F7C71}
{A8FC6701-D7C9-4342-B68A-4FE1538567DA} = {5EC029C6-230A-4782-9B62-CB475C7D05F8}
{F4A45D35-A1C8-4E65-8BAC-1670D5AEE1D1} = {C244E1D6-E1EB-4314-9F39-BB59FA1F7C71}
{C8244E3A-21AB-48FE-8CB1-CF0543B3F038} = {C244E1D6-E1EB-4314-9F39-BB59FA1F7C71}
{69ADCE8B-AF58-4C54-B79A-547B6E2807C5} = {C244E1D6-E1EB-4314-9F39-BB59FA1F7C71}
{3F7DD0CF-E214-4EF2-90F8-C9A0DFDA8EDA} = {5EC029C6-230A-4782-9B62-CB475C7D05F8}
{3EF147B0-B21A-4D6F-940F-CD211D795C92} = {5EC029C6-230A-4782-9B62-CB475C7D05F8}
{207C0604-793B-4829-A407-6385E2457A03} = {63B625A6-D80F-4C6B-86C4-BEA9F690D4C6}
{9E8287AF-C7A6-46A6-96D8-8460642ADE4B} = {5EC029C6-230A-4782-9B62-CB475C7D05F8}
Expand Down Expand Up @@ -144,14 +135,6 @@ Global
{81F17B4E-ACC8-4640-9F1A-1068600019DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81F17B4E-ACC8-4640-9F1A-1068600019DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81F17B4E-ACC8-4640-9F1A-1068600019DE}.Release|Any CPU.Build.0 = Release|Any CPU
{A8FC6701-D7C9-4342-B68A-4FE1538567DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8FC6701-D7C9-4342-B68A-4FE1538567DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8FC6701-D7C9-4342-B68A-4FE1538567DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8FC6701-D7C9-4342-B68A-4FE1538567DA}.Release|Any CPU.Build.0 = Release|Any CPU
{F4A45D35-A1C8-4E65-8BAC-1670D5AEE1D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4A45D35-A1C8-4E65-8BAC-1670D5AEE1D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4A45D35-A1C8-4E65-8BAC-1670D5AEE1D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4A45D35-A1C8-4E65-8BAC-1670D5AEE1D1}.Release|Any CPU.Build.0 = Release|Any CPU
{207C0604-793B-4829-A407-6385E2457A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{207C0604-793B-4829-A407-6385E2457A03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{207C0604-793B-4829-A407-6385E2457A03}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -168,10 +151,6 @@ Global
{69ADCE8B-AF58-4C54-B79A-547B6E2807C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69ADCE8B-AF58-4C54-B79A-547B6E2807C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69ADCE8B-AF58-4C54-B79A-547B6E2807C5}.Release|Any CPU.Build.0 = Release|Any CPU
{3F7DD0CF-E214-4EF2-90F8-C9A0DFDA8EDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F7DD0CF-E214-4EF2-90F8-C9A0DFDA8EDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F7DD0CF-E214-4EF2-90F8-C9A0DFDA8EDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F7DD0CF-E214-4EF2-90F8-C9A0DFDA8EDA}.Release|Any CPU.Build.0 = Release|Any CPU
{9E8287AF-C7A6-46A6-96D8-8460642ADE4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E8287AF-C7A6-46A6-96D8-8460642ADE4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E8287AF-C7A6-46A6-96D8-8460642ADE4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Loading
Loading