Skip to content

Commit 25d6b96

Browse files
committed
Add Makefile for dev tasks
1 parent 8d7d4fe commit 25d6b96

4 files changed

Lines changed: 199 additions & 17 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ jobs:
3434
3535
- name: Test with pytest
3636
run: |
37-
uv run pytest
37+
uv run pytest --testiq-output=testiq_coverage.json
38+
39+
- name: Analyze test quality with TestIQ
40+
run: |
41+
uv run testiq analyze testiq_coverage.json --threshold 1.0
3842
3943
- name: Upload coverage
4044
uses: codecov/codecov-action@v4

Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.PHONY: help install test lint format clean testiq coverage html-report all
2+
3+
help: ## Show this help message
4+
@echo 'Usage: make [target]'
5+
@echo ''
6+
@echo 'Available targets:'
7+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
8+
9+
install: ## Install dependencies with uv
10+
uv sync --all-extras
11+
12+
test: ## Run tests with pytest
13+
uv run pytest
14+
15+
test-verbose: ## Run tests with verbose output
16+
uv run pytest -v
17+
18+
lint: ## Run ruff linter
19+
uv run ruff check .
20+
21+
lint-fix: ## Run ruff linter with auto-fix
22+
uv run ruff check . --fix
23+
24+
format: ## Format code with black
25+
uv run black .
26+
27+
format-check: ## Check code formatting without changes
28+
uv run black --check .
29+
30+
testiq: ## Run testiq analysis (skips similarity checks)
31+
uv run pytest --testiq-output=testiq_coverage.json
32+
uv run testiq analyze testiq_coverage.json --threshold 1.0
33+
34+
testiq-score: ## Get test quality score
35+
uv run pytest --testiq-output=testiq_coverage.json
36+
uv run testiq quality-score testiq_coverage.json
37+
38+
testiq-html: ## Generate testiq HTML report
39+
uv run pytest --testiq-output=testiq_coverage.json
40+
uv run testiq analyze testiq_coverage.json --threshold 1.0 --format html --output testiq_report.html
41+
@echo "Report generated: testiq_report.html"
42+
43+
coverage: ## Run tests with coverage report
44+
uv run pytest --cov=pingping --cov-report=term-missing
45+
46+
html-report: ## Generate HTML coverage report
47+
uv run pytest --cov=pingping --cov-report=html
48+
@echo "Report generated: htmlcov/index.html"
49+
50+
clean: ## Clean up generated files
51+
rm -rf .pytest_cache
52+
rm -rf htmlcov
53+
rm -rf .ruff_cache
54+
rm -rf dist
55+
rm -rf build
56+
rm -rf *.egg-info
57+
rm -f coverage.xml coverage.json testiq_coverage.json testiq_report.html
58+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
59+
find . -type f -name "*.pyc" -delete
60+
61+
all: lint-fix format test ## Run linter, formatter, and tests
62+
63+
ci: lint format-check test testiq ## Run all CI checks locally
64+
65+
.DEFAULT_GOAL := help

README.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,45 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
162162
# Clone and set up the project
163163
git clone https://github.com/network-tools/pingping.git
164164
cd pingping
165-
uv sync --all-extras
165+
166+
# Install dependencies
167+
make install
166168

167169
# Run tests
168-
uv run pytest
170+
make test
171+
172+
# Run all quality checks (linter, formatter, tests)
173+
make all
174+
```
175+
176+
### Makefile Commands
177+
178+
The project includes a Makefile for common development tasks:
179+
180+
```bash
181+
make help # Show all available commands
182+
# Run testiq analysis (using Makefile)
183+
make testiq
184+
185+
# Get test quality score
186+
make testiq-score
169187

170-
# Run linter
171-
uv run ruff check .
188+
# Generate HTML report
189+
make testiq-html
190+
open testiq_report.html
191+
```
192+
193+
Or use commands directly:
172194

173-
# Format code
174-
uv run black .
195+
```bash
196+
# Generate coverage data for TestIQ
197+
uv run pytest --testiq-output=testiq_coverage.json
198+
199+
# Analyze for duplicate tests (skip similarity with threshold 1.0)
200+
uv run testiq analyze testiq_coverage.json --threshold 1.0
201+
202+
# Get test quality score
203+
uv run testiq quality-score testiq_coverage.jsonn all CI checks locally
175204
```
176205

177206
### Test Quality Analysis
@@ -182,14 +211,14 @@ Analyze test quality and find duplicates using TestIQ:
182211
# Generate coverage data for TestIQ
183212
uv run pytest --testiq-output=testiq_coverage.json
184213

185-
# Analyze for duplicate tests
186-
uv run testiq analyze testiq_coverage.json
214+
# Analyze for duplicate tests (skip similarity with threshold 1.0)
215+
uv run testiq analyze testiq_coverage.json --threshold 1.0
187216

188217
# Get test quality score
189218
uv run testiq quality-score testiq_coverage.json
190219

191220
# Generate HTML report with test duplicates analysis
192-
uv run testiq analyze testiq_coverage.json --format html --output testiq_report.html
221+
uv run testiq analyze testiq_coverage.json --threshold 1.0 --format html --output testiq_report.html
193222
open testiq_report.html
194223
```
195224

docs/CONTRIBUTING.md

Lines changed: 91 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ uv automatically manages virtual environments. Simply sync the project:
3737
```bash
3838
# This will create a virtual environment and install all dependencies
3939
uv sync --all-extras
40+
41+
# Or using Makefile
42+
make install
4043
```
4144

4245
The virtual environment will be created in `.venv/` directory.
@@ -50,7 +53,86 @@ Development dependencies are already included when you use `--all-extras`:
5053
- **ruff** - Fast Python linter
5154
- **black** - Code formatter
5255
- **testiq** - Test quality analysis tool
56+
Using Makefile (R
57+
58+
Using Makefile:
59+
60+
```bash
61+
# Run all tests
62+
make test
63+
64+
# Run with verbose output
65+
make test-verbose
66+
67+
# Run with coverage
68+
make coverage
69+
```
70+
71+
Using uv directly:ecommended)
72+
73+
The project includes a Makefile for common tasks:
74+
Using Makefile (Recommended)
75+
76+
```bash
77+
# Run linter
78+
make lint
79+
80+
# Auto-fix linting issues
81+
make lint-fix
82+
83+
# Format code
84+
make format
85+
86+
# Check formatting without changes
87+
make format-check
88+
89+
# Run all checks
90+
make all
91+
```
92+
93+
#### Using uv directly
5394

95+
####
96+
```bash
97+
# Show all available commands
98+
make
99+
100+
# Run tests
101+
make test
102+
103+
# Run linter and auto-fix issues
104+
make lint-fix
105+
Using Makefile (Recommended)
106+
107+
```bash
108+
# Run testiq analysis
109+
make testiq
110+
111+
# Get test quality score
112+
make testiq-score
113+
114+
# Generate HTML report
115+
make testiq-html
116+
open testiq_report.html
117+
```
118+
119+
#### Using uv directly
120+
121+
####
122+
# Format code
123+
make format
124+
125+
# Run all quality checks
126+
make all
127+
128+
# Run CI checks locally
129+
make ci
130+
131+
# Clean up generated files
132+
make clean
133+
```
134+
135+
###
54136
## Development Workflow
55137

56138
### Running Tests
@@ -74,9 +156,11 @@ uv run pytest tests/test_ping.py::TestPing::test_ping_en
74156
#### Linting with Ruff
75157

76158
```bash
77-
# Check for linting issues
78-
uv run ruff check .
79-
159+
# Cmake all
160+
# Or individually:
161+
make lint-fix
162+
make format
163+
make
80164
# Auto-fix linting issues
81165
uv run ruff check . --fix
82166
```
@@ -112,8 +196,8 @@ uv run pytest --testiq-output=testiq_coverage.json
112196
#### Analyze Test Duplicates
113197

114198
```bash
115-
# Analyze for duplicate tests
116-
uv run testiq analyze testiq_coverage.json
199+
# Analyze for duplicate tests (threshold 1.0 skips similarity checks)
200+
uv run testiq analyze testiq_coverage.json --threshold 1.0
117201

118202
# Get test quality score
119203
uv run testiq quality-score testiq_coverage.json
@@ -135,8 +219,8 @@ open htmlcov/index.html
135219
#### Generate TestIQ HTML Report
136220

137221
```bash
138-
# Generate TestIQ HTML report with duplicate test analysis
139-
uv run testiq analyze testiq_coverage.json --format html --output testiq_report.html
222+
# Generate TestIQ HTML report with duplicate test analysis (skip similarity with threshold 1.0)
223+
uv run testiq analyze testiq_coverage.json --threshold 1.0 --format html --output testiq_report.html
140224

141225
# Open the report in your browser
142226
open testiq_report.html

0 commit comments

Comments
 (0)