Skip to content

Commit

Permalink
Merge branch 'develop' into feat/publish_choco_win
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwelbm authored Dec 20, 2024
2 parents 89353af + aab8bc5 commit c492236
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 174 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## [1.37.0-beta.1](https://github.com/LerianStudio/midaz/compare/v1.36.0...v1.37.0-beta.1) (2024-12-20)


### Bug Fixes

* help :bug: ([8f9358f](https://github.com/LerianStudio/midaz/commit/8f9358f0d0608ce82f96084f0761de6edc7dcdae))
* **audit:** improve makefile changing docker-compose to a choose based version command :bug: ([14506fe](https://github.com/LerianStudio/midaz/commit/14506fec46ee5f5c946d67c7fc63135a08a739aa))
* **auth:** improve makefile changing docker-compose to a choose based version command :bug: ([d9ee74c](https://github.com/LerianStudio/midaz/commit/d9ee74c64e3e64e0b06ac390dd0feda4810b4daf))
* **infra:** improve makefile changing docker-compose to a choose based version command :bug: ([e43892c](https://github.com/LerianStudio/midaz/commit/e43892ce9eb930b2f57e0814b0b3793be11c8be7))
* **ledger:** improve makefile changing docker-compose to a choose based version command :bug: ([89552e0](https://github.com/LerianStudio/midaz/commit/89552e066cbf45e18d8d824d9ad025ef48bee71b))
* **midaz:** improve makefile changing docker-compose to a choose based version command :bug: ([9951e8c](https://github.com/LerianStudio/midaz/commit/9951e8c706c12bcee8fadf6af01186a82834f547))
* **transaction:** improve makefile changing docker-compose to a choose based version command :bug: ([44a1b1f](https://github.com/LerianStudio/midaz/commit/44a1b1fc977b85bedb59a368075089f0b2d5da2c))
* info :bug: ([3f01ba4](https://github.com/LerianStudio/midaz/commit/3f01ba4452082a728580a0296f4b64bff6c40e16))
* remove wire reference :bug: ([a7c61ee](https://github.com/LerianStudio/midaz/commit/a7c61ee2426ec1523d7750fc22041e9478f9ebad))

## [1.36.0](https://github.com/LerianStudio/midaz/compare/v1.35.0...v1.36.0) (2024-12-19)


Expand Down
64 changes: 54 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,52 @@
AUDIT_DIR := ./components/audit
AUTH_DIR := ./components/auth
INFRA_DIR := ./components/infra
MDZ_DIR := ./components/mdz
LEDGER_DIR := ./components/ledger
TRANSACTION_DIR := ./components/transaction
MDZ_DIR := ./components/mdz
AUDIT_DIR := ./components/audit

.PHONY: help test cover lint format check-logs check-tests \
setup-git-hooks check-hooks goreleaser tidy sec set-env up auth infra ledger \
transaction audit all-services

BLUE := \033[36m
NC := \033[0m
BOLD := \033[1m
RED := \033[31m
MAGENTA := \033[35m

DOCKER_VERSION := $(shell docker version --format '{{.Server.Version}}')
DOCKER_MIN_VERSION := 20.10.13

DOCKER_CMD := $(shell \
if [ "$(shell printf '%s\n' "$(DOCKER_MIN_VERSION)" "$(DOCKER_VERSION)" | sort -V | head -n1)" = "$(DOCKER_MIN_VERSION)" ]; then \
echo "docker compose"; \
else \
echo "docker-compose"; \
fi \
)

.PHONY: help
help:
@echo ""
@echo ""
@echo "$(BOLD)Midaz Project Management Commands$(NC)"
@echo ""
@echo ""
@echo "$(BOLD)Core Commands:$(NC)"
@echo " make test - Run tests on all projects"
@echo " make cover - Run test coverage"
@echo ""
@echo ""
@echo "$(BOLD)Code Quality Commands:$(NC)"
@echo " make lint - Run golangci-lint and performance checks"
@echo " make format - Format Go code using gofmt"
@echo " make check-logs - Verify error logging in usecases"
@echo " make check-tests - Verify test coverage for components"
@echo " make sec - Run security checks using gosec"
@echo ""
@echo ""
@echo "$(BOLD)Git Hook Commands:$(NC)"
@echo " make setup-git-hooks - Install and configure git hooks"
@echo " make check-hooks - Verify git hooks installation status"
@echo ""
@echo ""
@echo "$(BOLD)Setup Commands:$(NC)"
@echo " make set-env - Copy .env.example to .env for all components"
@echo "Usage:"
Expand All @@ -52,6 +66,7 @@ help:
@echo " make all-services Run a command to all services passing any individual container command."
@echo " make generate-docs-all Run a command to inside the ledger and transaction app to generate swagger docs."
@echo ""
@echo ""
@echo "$(BOLD)Service Commands:$(NC)"
@echo " make up - Start all services with Docker Compose"
@echo " make auth COMMAND=<cmd> - Run command in auth service"
Expand All @@ -60,11 +75,16 @@ help:
@echo " make transaction COMMAND=<cmd> - Run command in transaction service"
@echo " make audit COMMAND=<cmd> - Run command in audit service"
@echo " make all-services COMMAND=<cmd> - Run command across all services"
@echo " make clean-docker - Run command to clean docker"
@echo ""
@echo ""
@echo "$(BOLD)Development Commands:$(NC)"
@echo " make tidy - Run go mod tidy"
@echo " make goreleaser - Create a release snapshot"
@echo ""
@echo ""

.PHONY: test
test:
@echo "$(BLUE)Running tests...$(NC)"
@if ! command -v go >/dev/null 2>&1; then \
Expand All @@ -73,6 +93,7 @@ test:
fi
go test -v ./... ./...

.PHONY: cover
cover:
@echo -e "$(BLUE)Generating test coverage...$(NC)"
@if ! command -v go >/dev/null 2>&1; then \
Expand All @@ -82,22 +103,27 @@ cover:
@sh ./scripts/coverage.sh
@go tool cover -html=coverage.out -o coverage.html

.PHONY: lint
lint:
@echo "$(BLUE)Running linter and performance checks...$(NC)"
./make.sh "lint"

.PHONY: format
format:
@echo "$(BLUE)Formatting Go code...$(NC)"
./make.sh "format"

.PHONY: check-logs
check-logs:
@echo "$(BLUE)Checking error logging in usecases...$(NC)"
./make.sh "checkLogs"

.PHONY: check-tests
check-tests:
@echo "$(BLUE)Verifying test coverage...$(NC)"
./make.sh "checkTests"

.PHONY: sec
sec:
@echo "$(BLUE)Running security checks...$(NC)"
@if ! command -v gosec >/dev/null 2>&1; then \
Expand All @@ -107,14 +133,17 @@ sec:
fi
gosec ./...

.PHONY: setup-git-hooks
setup-git-hooks:
@echo "$(BLUE)Setting up git hooks...$(NC)"
./make.sh "setupGitHooks"

.PHONY: check-hooks
check-hooks:
@echo "$(BLUE)Checking git hooks status...$(NC)"
./make.sh "checkHooks"

.PHONY: set-env
set-env:
@echo "$(BLUE)Setting up environment files...$(NC)"
cp -r $(AUTH_DIR)/.env.example $(AUTH_DIR)/.env
Expand All @@ -125,34 +154,41 @@ set-env:
cp -r $(AUDIT_DIR)/.env.example $(AUDIT_DIR)/.env
@echo "$(BLUE)Environment files created successfully$(NC)"

.PHONY: up
up:
@echo "$(BLUE)Starting all services...$(NC)"
docker-compose -f $(AUTH_DIR)/docker-compose.yml up --build -d && \
docker-compose -f $(INFRA_DIR)/docker-compose.yml up --build -d && \
docker-compose -f $(LEDGER_DIR)/docker-compose.yml up --build -d && \
docker-compose -f $(TRANSACTION_DIR)/docker-compose.yml up --build -d
@$(DOCKER_CMD) -f $(AUTH_DIR)/docker-compose.yml up --build -d
@$(DOCKER_CMD) -f $(INFRA_DIR)/docker-compose.yml up --build -d
@$(DOCKER_CMD) -f $(LEDGER_DIR)/docker-compose.yml up --build -d
@$(DOCKER_CMD) -f $(TRANSACTION_DIR)/docker-compose.yml up --build -d
@echo "$(BLUE)All services started successfully$(NC)"

.PHONY: auth
auth:
@echo "$(BLUE)Executing command in auth service...$(NC)"
$(MAKE) -C $(AUTH_DIR) $(COMMAND)

.PHONY: infra
infra:
@echo "$(BLUE)Executing command in infra service...$(NC)"
$(MAKE) -C $(INFRA_DIR) $(COMMAND)

.PHONY: ledger
ledger:
@echo "$(BLUE)Executing command in ledger service...$(NC)"
$(MAKE) -C $(LEDGER_DIR) $(COMMAND)

.PHONY: transaction
transaction:
@echo "$(BLUE)Executing command in transaction service...$(NC)"
$(MAKE) -C $(TRANSACTION_DIR) $(COMMAND)

.PHONY: audit
audit:
@echo "$(BLUE)Executing command in audit service...$(NC)"
$(MAKE) -C $(AUDIT_DIR) $(COMMAND)

.PHONY: all-services
all-services:
@echo "$(BLUE)Executing command across all services...$(NC)"
$(MAKE) -C $(AUTH_DIR) $(COMMAND) && \
Expand All @@ -161,17 +197,25 @@ all-services:
$(MAKE) -C $(TRANSACTION_DIR) $(COMMAND) && \
$(MAKE) -C $(AUDIT_DIR) $(COMMAND)

.PHONY: clean-docker
clean-docker:
docker system prune -a -f && docker volume prune -a -f

.PHONY: test_integration_cli
test_integration_cli:
go test -v -tags=integration ./components/mdz/test/integration/...

.PHONY: goreleaser
goreleaser:
@echo "$(BLUE)Creating release snapshot...$(NC)"
goreleaser release --snapshot --skip-publish --rm-dist

.PHONY: tidy
tidy:
@echo "$(BLUE)Running go mod tidy...$(NC)"
go mod tidy

.PHONY: generate-docs-all
generate-docs-all:
@echo "$(BLUE)Executing command to generate swagger...$(NC)"
$(MAKE) -C $(LEDGER_DIR) generate-docs && \
Expand Down
63 changes: 43 additions & 20 deletions components/audit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ artifacts_dir := ./artifacts

$(shell mkdir -p $(artifacts_dir))

.PHONY: info gen run test cover-html tidy help build up start down destroy stop restart logs logs-api ps generate-docs
DOCKER_VERSION := $(shell docker version --format '{{.Server.Version}}')
DOCKER_MIN_VERSION := 20.10.13

DOCKER_CMD := $(shell \
if [ "$(shell printf '%s\n' "$(DOCKER_MIN_VERSION)" "$(DOCKER_VERSION)" | sort -V | head -n1)" = "$(DOCKER_MIN_VERSION)" ]; then \
echo "docker compose"; \
else \
echo "docker-compose"; \
fi \
)

# Display available commands
.PHONY: info
info:
@echo " "
@echo " "
@echo "To run a specific command inside the auth container using make, you can execute: "
@echo "To run a specific command inside the audit container using make, you can execute: "
@echo " "
@echo "make auth COMMAND=\"any\" "
@echo "make audit COMMAND=\"any\" "
@echo " "
@echo "This command will run the specified command inside the auth container. Replace \"any\" with the desired command you want to execute. "
@echo " "
@echo "## App commands:"
@echo " "
@echo " COMMAND=\"generate-docs\" Generates Swagger API documentation and an OpenAPI Specification."
@echo "This command will run the specified command inside the audit container. Replace \"any\" with the desired command you want to execute. "
@echo " "
@echo "## Docker commands:"
@echo " "
Expand All @@ -30,41 +36,58 @@ info:
@echo " COMMAND=\"destroy\" Stops and removes containers, networks, and volumes (including named volumes) defined in docker-compose.yml."
@echo " COMMAND=\"restart\" Stops and removes containers, networks, and volumes, then starts all services in detached mode."
@echo " COMMAND=\"logs\" Shows the last 100 lines of logs and follows live log output for services defined in docker-compose.yml."
@echo " COMMAND=\"logs-api\" Shows the last 100 lines of logs and follows live log output for the auth service defined in docker-compose.yml."
@echo " COMMAND=\"logs-api\" Shows the last 100 lines of logs and follows live log output for the audit service defined in docker-compose.yml."
@echo " COMMAND=\"ps\" Lists the status of containers defined in docker-compose.yml."
@echo " "
@echo "## App commands:"
@echo " "
@echo " COMMAND=\"generate-docs\" Generates Swagger API documentation and an OpenAPI Specification."
@echo " "
@echo " "

# Docker Compose Commands
.PHONY: build
build:
@docker-compose -f docker-compose.yml build $(c)
@$(DOCKER_CMD) -f docker-compose.yml build $(c)

.PHONY: up
up:
@docker-compose -f docker-compose.yml up $(c) -d
@$(DOCKER_CMD) -f docker-compose.yml up $(c) -d

.PHONY: start
start:
@docker-compose -f docker-compose.yml start $(c)
@docker compose -f docker-compose.yml start $(c)

.PHONY: down
down:
@docker-compose -f docker-compose.yml down $(c)
@$(DOCKER_CMD) -f docker-compose.yml down $(c)

.PHONY: destroy
destroy:
@docker-compose -f docker-compose.yml down -v $(c)
@$(DOCKER_CMD) -f docker-compose.yml down -v $(c)

.PHONY: stop
stop:
@docker-compose -f docker-compose.yml stop $(c)
@$(DOCKER_CMD) -f docker-compose.yml stop $(c)

.PHONY: restart
restart:
docker-compose -f docker-compose.yml down $(c) && \
docker-compose -f docker-compose.yml up -d $(c)
make stop && \
make up

.PHONY: logs
logs:
@docker-compose -f docker-compose.yml logs --tail=100 -f $(c)
@$(DOCKER_CMD) -f docker-compose.yml logs --tail=100 -f $(c)

.PHONY: logs-api
logs-api:
@docker-compose -f docker-compose.yml logs --tail=100 -f auth
@$(DOCKER_CMD) -f docker-compose.yml logs --tail=100 -f midaz-audit

.PHONY: ps
ps:
@docker-compose -f docker-compose.yml ps
@$(DOCKER_CMD) -f docker-compose.yml ps

.PHONY: generate-docs
generate-docs:
@swag init -g ../../../cmd/app/main.go -d ./internal/adapters/http -o ./api --parseDependency --parseInternal
@docker run --rm -v ./:/audit --user $(shell id -u):$(shell id -g) openapitools/openapi-generator-cli:v5.1.1 generate -i ./audit/api/swagger.json -g openapi-yaml -o ./audit/api
Expand Down
Loading

0 comments on commit c492236

Please sign in to comment.