Skip to content

Commit 7291c10

Browse files
committed
fix: makefile to make coverage-all on 2 stage unit and then integration
1 parent 68426bc commit 7291c10

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,20 @@ coverage-integration: ## Generate integration test coverage report
7070
go tool cover -html=$(COVERAGE_DIR)/coverage-integration.out -o $(COVERAGE_DIR)/coverage-integration.html
7171
@echo "Integration coverage report generated: $(COVERAGE_DIR)/coverage-integration.html"
7272

73-
coverage-all: ## Generate full coverage report (unit + integration)
73+
coverage-all: ## Generate full coverage report (unit + integration merged)
7474
@echo "Generating full coverage report..."
7575
@mkdir -p $(COVERAGE_DIR)
76+
@echo "Step 1/3: Running unit tests with coverage..."
77+
@CGO_ENABLED=1 go test -short -race -coverprofile=$(COVERAGE_DIR)/coverage-unit.out ./backend/internal/... ./backend/pkg/... ./backend/cmd/...
78+
@echo "Step 2/3: Running integration tests with coverage..."
7679
@export ACKIFY_DB_DSN="postgres://postgres:testpassword@localhost:5432/ackify_test?sslmode=disable"; \
7780
export INTEGRATION_TESTS=1; \
78-
CGO_ENABLED=1 go test -v -race -tags=integration -coverprofile=$(COVERAGE_DIR)/coverage-all.out ./...
79-
go tool cover -html=$(COVERAGE_DIR)/coverage-all.out -o $(COVERAGE_DIR)/coverage-all.html
80-
go tool cover -func=$(COVERAGE_DIR)/coverage-all.out
81+
CGO_ENABLED=1 go test -v -race -tags=integration -coverprofile=$(COVERAGE_DIR)/coverage-integration.out ./backend/internal/infrastructure/database/...
82+
@echo "Step 3/3: Merging coverage files..."
83+
@echo "mode: atomic" > $(COVERAGE_DIR)/coverage-all.out
84+
@grep -h -v "^mode:" $(COVERAGE_DIR)/coverage-unit.out $(COVERAGE_DIR)/coverage-integration.out >> $(COVERAGE_DIR)/coverage-all.out || true
85+
@go tool cover -html=$(COVERAGE_DIR)/coverage-all.out -o $(COVERAGE_DIR)/coverage-all.html
86+
@go tool cover -func=$(COVERAGE_DIR)/coverage-all.out
8187
@echo "Full coverage report generated: $(COVERAGE_DIR)/coverage-all.html"
8288

8389
coverage-func: ## Show function-level coverage

0 commit comments

Comments
 (0)