-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
83 lines (71 loc) · 2.71 KB
/
makefile
File metadata and controls
83 lines (71 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Variables
DOCKER_COMPOSE_FILE := docker-compose.yml
INFO := @echo
# Build the Docker containers
buildTest:
@ ${INFO} "Building required docker images for Testing"
@ docker compose -f $(DOCKER_COMPOSE_FILE) build go_test test_db
@ ${INFO} "Docker images built successfully"
@ echo " "
buildAPI:
@ ${INFO} "Building required docker images for the API"
@ docker compose -f $(DOCKER_COMPOSE_FILE) build --no-cache db go_api
@ ${INFO} "Docker images built successfully"
@ echo " "
# Run the Docker containers
run:
@ ${INFO} "Running the Docker containers"
@ docker compose -f $(DOCKER_COMPOSE_FILE) up db go_api
@ ${INFO} "Docker containers running successfully"
@ echo " "
# Run the tests
test:
@ ${INFO} "Running tests"
@ docker compose -f $(DOCKER_COMPOSE_FILE) run --rm go_test go test -v -coverprofile=coverage.txt
@ ${INFO} "Tests completed successfully"
@ echo " "
# Run godog BDD tests
test-godog:
@ ${INFO} "Running godog BDD tests"
@ docker compose -f $(DOCKER_COMPOSE_FILE) run --rm go_test go test -v -count=1 ./internal/features
@ ${INFO} "Godog tests completed successfully"
@ echo " "
# Run godog BDD tests with coverage
test-godog-coverage:
@ ${INFO} "Running godog BDD tests with coverage"
@ docker compose -f $(DOCKER_COMPOSE_FILE) run --rm go_test go test -v -count=1 -coverprofile=coverage-godog.txt -coverpkg=./... ./internal/features
@ ${INFO} "Godog tests with coverage completed successfully"
@ echo " "
# Run godog tests locally (without Docker)
test-godog-local:
@ ${INFO} "Running godog BDD tests locally"
@ go test -v ./internal/features/...
@ ${INFO} "Godog tests completed successfully"
@ echo " "
# Run godog tests locally with coverage
test-godog-local-coverage:
@ ${INFO} "Running godog BDD tests locally with coverage"
@ go test -v -coverprofile=coverage-godog.txt -coverpkg=./... ./internal/features/...
@ ${INFO} "Coverage report generated: coverage-godog.txt"
@ ${INFO} "View coverage with: go tool cover -html=coverage-godog.txt"
@ echo " "
# Generate HTML coverage report
coverage-html:
@ ${INFO} "Generating HTML coverage report"
@ if [ -f coverage.txt ]; then \
go tool cover -html=coverage.txt -o coverage.html; \
echo "Coverage report generated: coverage.html"; \
elif [ -f coverage-godog.txt ]; then \
go tool cover -html=coverage-godog.txt -o coverage.html; \
echo "Coverage report generated: coverage.html"; \
else \
echo "No coverage file found. Run 'make test' or 'make test-godog-coverage' first"; \
fi
@ echo " "
# Clean up Docker containers
clean:
@ ${INFO} "Cleaning up Docker containers"
@ docker compose -f $(DOCKER_COMPOSE_FILE) down -v
@ ${INFO} "Docker containers cleaned up successfully"
# Run clean, build, and test in sequence
rebuild-test: clean build test