-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
173 lines (142 loc) · 5.56 KB
/
Makefile
File metadata and controls
173 lines (142 loc) · 5.56 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
.PHONY: help test test-all test-watch test-spec test-debug test-coverage test-ui test-api test-e2e test-verbose test-retry test-report test-fix up down build logs restart clean dev logs-api logs-backend logs-frontend stop install install-frontend install-backend install-api
# Default target
help:
@echo "Available commands:"
@echo " make test - Run all tests (headless, will fail on error)"
@echo " make test-all - Run all tests and continue on error"
@echo " make test-watch - Open Cypress test runner"
@echo " make test-spec - Run specific test (spec=path/to/test.cy.js)"
@echo " make test-debug - Run tests with debug output"
@echo " make test-coverage - Generate test coverage report"
@echo " make test-ui - Run only UI tests"
@echo " make test-api - Run only API tests"
@echo " make test-e2e - Run only E2E tests"
@echo " make test-verbose - Run tests with verbose output"
@echo " make test-retry - Retry failed tests up to 3 times"
@echo " make test-report - Generate HTML test report"
@echo " make test-fix - Try to automatically fix test issues"
@echo " make up - Start all services"
@echo " make down - Stop all services"
@echo " make build - Build all services"
@echo " make logs - Show logs for all services"
@echo " make restart - Restart all services"
@echo " make clean - Remove all containers, volumes, and images"
@echo " make dev - Start development environment"
@echo " make install - Install all dependencies"
@echo " make help - Show this help"
# Docker commands
up:
docker compose up --build
down:
docker-compose down
build:
docker-compose build
logs:
docker-compose logs -f
restart: down up
# Test commands
test:
@echo "🚀 Running backend tests with pytest..."
python -m pytest edix/tests/ -v --timeout=60 --timeout-method=thread
@echo "🚀 Running frontend tests with jest..."
cd frontend_src && npm test -- --testTimeout=60000
test-all:
@echo "🏃 Running all tests (continue on error)..."
@if ! curl -s http://localhost:3004 >/dev/null; then \
echo "⚠️ Starting test server..."; \
make up; \
sleep 10; \
fi
npx cypress run --headless --browser chrome --no-exit
test-watch:
@echo "👀 Opening Cypress test runner..."
npx cypress open
test-spec:
@if [ -z "$(spec)" ]; then \
echo "❌ Error: Please specify test file with spec=path/to/test.cy.js"; \
exit 1; \
fi
@echo "🔍 Running specific test: $(spec)"
npx cypress run --headless --browser chrome --spec "$(spec)"
test-debug:
@echo "🐛 Running tests with debug information..."
DEBUG=cypress:* npx cypress run --headless --browser chrome
test-coverage:
@echo "📊 Generating test coverage report..."
npx cypress run --headless --browser chrome --env coverage=true
test-ui:
@echo "🎨 Running UI tests..."
npx cypress run --headless --browser chrome --spec "cypress/e2e/**/ui-*.cy.js"
test-api:
@echo "🔌 Running API tests..."
npx cypress run --headless --browser chrome --spec "cypress/e2e/**/api-*.cy.js"
test-e2e:
@echo "🏃 Running end-to-end tests..."
npx cypress run --headless --browser chrome --spec "cypress/e2e/**/e2e-*.cy.js"
test-verbose:
@echo "🔊 Running tests with verbose output..."
npx cypress run --headless --browser chrome --browser-args="--log-level=DEBUG"
test-retry:
@echo "🔄 Retrying failed tests (max 3 attempts)..."
@n=0; until [ "$$n" -ge 3 ]; do \
echo "Attempt $$((n+1))/3..."; \
if npx cypress run --headless --browser chrome; then \
exit 0; \
fi; \
n=$$((n+1)); \
echo "Retrying..."; \
sleep 2; \
done; \
echo "❌ All attempts failed"; \
exit 1
test-report:
@echo "📄 Generating HTML test report..."
@if ! command -v mochawesome-merge >/dev/null 2>&1; then \
echo "Installing mochawesome-merge..."; \
npm install -g mochawesome-merge mochawesome-report-generator; \
fi
@rm -rf cypress/results cypress/reports || true
@mkdir -p cypress/results cypress/reports
npx cypress run --headless --browser chrome --reporter mochawesome --reporter-options "reportDir=cypress/results,overwrite=false,html=false,json=true"
npx mochawesome-merge "cypress/results/*.json" > cypress/reports/mochawesome.json
npx marge cypress/reports/mochawesome.json -f cypress-test-report -o cypress/reports
@echo "✅ Report generated at: cypress/reports/cypress-test-report.html"
test-fix:
@echo "🔧 Attempting to fix test issues..."
@echo "1. Cleaning up test environment..."
@make clean
@echo "2. Reinstalling dependencies..."
@rm -rf node_modules
@npm install
@echo "3. Starting services..."
@make up
@echo "4. Waiting for services to be ready..."
@sleep 10
@echo "✅ Fix attempt complete. Try running tests again."
# Logs
logs-api:
docker-compose logs -f api
logs-backend:
docker-compose logs -f backend
logs-frontend:
docker-compose logs -f frontend
# Cleanup
clean:
docker-compose down --volumes --rmi all
stop: down
# Installation
install:
make install-frontend
make install-backend
make install-api
install-frontend:
cd frontend_src && npm install --ignore-scripts
install-backend:
pip install -e . && pip install pytest pydantic[email] pydantic-settings python-jose[cryptography] passlib[bcrypt]
install-api:
pip install -e . && pip install pytest pydantic[email] pydantic-settings python-jose[cryptography] passlib[bcrypt]
# ==============================================================================
# PUBLISHING
# ==============================================================================
publish: ## Publish project to PyPI
@bash scripts/publish.sh