-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (149 loc) · 5.89 KB
/
Makefile
File metadata and controls
174 lines (149 loc) · 5.89 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
174
.PHONY: help install test test-cov test-api examples clean setup-env lint format check typecheck venv docker-build docker-up docker-shell docker-down docker-test docker-test-cov docker-test-api docker-examples docker-example docker-example-auth docker-example-user docker-example-doc
help:
@echo "SignNow Python SDK - Makefile commands:"
@echo ""
@echo "=== Setup ==="
@echo " make venv - Create virtualenv and install all deps"
@echo " make install - Install dependencies into current env"
@echo " make setup-env - Create .env file from example"
@echo ""
@echo "=== Code quality ==="
@echo " make format - Format code with Black"
@echo " make lint - Run Black (check) and Flake8"
@echo " make typecheck - Run mypy type checks"
@echo " make check - Run lint + typecheck + tests (full CI)"
@echo ""
@echo "=== Tests ==="
@echo " make test - Run all unit tests"
@echo " make test-cov - Run tests with coverage report"
@echo " make test-api - Run only mock-API integration tests"
@echo ""
@echo "=== Docker ==="
@echo " make docker-build - Build Docker image"
@echo " make docker-up - Start Docker container"
@echo " make docker-shell - Open shell in Docker container"
@echo " make docker-down - Stop Docker container"
@echo " make docker-test - Run all tests in Docker"
@echo " make docker-test-cov - Run tests with coverage in Docker"
@echo " make docker-test-api - Run only real API tests in Docker"
@echo ""
@echo "=== Examples ==="
@echo " make examples - Run all examples"
@echo " make docker-examples - Run all examples in Docker"
@echo " make docker-example EXAMPLE=auth_check_example.py - Run one example"
@echo ""
@echo "=== Other ==="
@echo " make clean - Remove caches, build artefacts, coverage"
@echo ""
install:
@echo "Installing dependencies..."
pip install -r requirements.txt
pip install -e ".[dev]"
venv:
@echo "Creating virtualenv and installing all deps..."
python3 -m venv venv
. venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt && pip install -e ".[dev]"
@echo "Done. Activate with: source venv/bin/activate"
lint:
@echo "Running code quality checks..."
black --check --diff signnow/ tests/ examples/ run_examples.py
flake8 signnow/ tests/ examples/ run_examples.py --max-line-length=88 --extend-ignore=E203,W503,E501
@echo "Lint passed."
format:
@echo "Formatting code with Black..."
black signnow/ tests/ examples/ run_examples.py
@echo "Done."
typecheck:
@echo "Running mypy type checks..."
mypy signnow/ --ignore-missing-imports --no-error-summary || true
check: lint typecheck test
@echo "All checks passed."
setup-env:
@echo "Creating .env file..."
@if [ ! -f .env ]; then \
if [ -f env.example ]; then \
cp env.example .env; \
echo ".env file created from env.example! Please edit it and add your credentials."; \
else \
echo "# SignNow API Configuration" > .env; \
echo "# Copy this file to .env and fill in your credentials" >> .env; \
echo "" >> .env; \
echo "SIGNNOW_API_HOST=https://api.signnow.com" >> .env; \
echo "SIGNNOW_API_BASIC_TOKEN=your_basic_token_here" >> .env; \
echo "SIGNNOW_API_USERNAME=your_username_here" >> .env; \
echo "SIGNNOW_API_PASSWORD=your_password_here" >> .env; \
echo "SIGNNOW_DOWNLOADS_DIR=./downloads" >> .env; \
echo ".env file created! Please edit it and add your credentials."; \
fi \
else \
echo ".env file already exists."; \
fi
test:
@echo "Running tests..."
pytest tests/ -v
test-cov:
@echo "Running tests with coverage..."
pytest tests/ --cov=signnow --cov-report=html --cov-report=term
@echo "Coverage report generated in htmlcov/index.html"
test-api:
@echo "Running real API tests..."
pytest tests/api/ -k "api_call" -v
examples:
@echo "Running all examples..."
python run_examples.py
example-auth:
@echo "Running token check example..."
python examples/auth_check_example.py
example-doc:
@echo "Running document get example..."
python examples/document_get_example.py
example-user:
@echo "Running user info example..."
python examples/user_info_example.py
clean:
@echo "Cleaning temporary files..."
find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type d -name "*.egg-info" -exec rm -r {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -r {} + 2>/dev/null || true
find . -type d -name "htmlcov" -exec rm -r {} + 2>/dev/null || true
find . -type d -name ".coverage" -exec rm -r {} + 2>/dev/null || true
@echo "Cleanup complete!"
docker-build:
@echo "Building Docker image..."
docker-compose build
docker-up:
@echo "Starting Docker container..."
docker-compose up -d signnow-sdk
@echo "Container started. Use 'make docker-shell' to enter."
docker-shell:
@echo "Entering Docker container..."
docker-compose exec signnow-sdk bash
docker-down:
@echo "Stopping Docker container..."
docker-compose down
docker-test:
@echo "Running tests in Docker..."
docker-compose --profile test run --rm test
docker-test-cov:
@echo "Running tests with coverage in Docker..."
docker-compose --profile test run --rm test-cov
@echo ""
@echo "Coverage report generated in htmlcov/index.html"
@echo "Open htmlcov/index.html in browser to view"
docker-test-api:
@echo "Running real API tests in Docker..."
docker-compose --profile test run --rm test-api
docker-examples:
@echo "Running all examples in Docker..."
docker-compose --profile examples run --rm run-examples
docker-example:
ifndef EXAMPLE
@echo "Usage: make docker-example EXAMPLE=<name>"
@echo " e.g. make docker-example EXAMPLE=auth_check_example.py"
@echo " e.g. make docker-example EXAMPLE=auth_check_example"
exit 1
endif
@echo "Running example $(EXAMPLE) in Docker..."
docker-compose --profile examples run --rm run-examples python run_examples.py $(EXAMPLE)