Skip to content

Commit 35adb16

Browse files
committed
tests galore
1 parent bad160d commit 35adb16

19 files changed

Lines changed: 3224 additions & 15 deletions

.github/workflows/ci.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.8", "3.9", "3.10", "3.11"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v2
27+
28+
- name: Install dependencies
29+
run: |
30+
uv sync --dev
31+
32+
- name: Run unit tests
33+
run: |
34+
uv run pytest tests/unit/ -v --cov=bytewaves --cov-report=xml --cov-report=term-missing
35+
36+
- name: Run integration tests
37+
run: |
38+
uv run pytest tests/integration/ -v --cov=bytewaves --cov-report=xml --cov-report=term-missing --cov-append
39+
40+
- name: Run performance tests
41+
run: |
42+
uv run pytest tests/performance/ -v --cov=bytewaves --cov-report=xml --cov-report=term-missing --cov-append
43+
44+
- name: Upload coverage to Codecov
45+
uses: codecov/codecov-action@v3
46+
with:
47+
file: ./coverage.xml
48+
flags: unittests
49+
name: codecov-umbrella
50+
fail_ci_if_error: false
51+
52+
lint:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Set up Python
58+
uses: actions/setup-python@v4
59+
with:
60+
python-version: "3.11"
61+
62+
- name: Install uv
63+
uses: astral-sh/setup-uv@v2
64+
65+
- name: Install dependencies
66+
run: |
67+
uv sync --dev
68+
69+
- name: Lint with flake8
70+
run: |
71+
uv run flake8 bytewaves/ --count --select=E9,F63,F7,F82 --show-source --statistics
72+
uv run flake8 bytewaves/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
73+
74+
- name: Check formatting with black
75+
run: |
76+
uv run black --check --diff bytewaves/
77+
78+
security:
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
83+
- name: Set up Python
84+
uses: actions/setup-python@v4
85+
with:
86+
python-version: "3.11"
87+
88+
- name: Install uv
89+
uses: astral-sh/setup-uv@v2
90+
91+
- name: Install dependencies
92+
run: |
93+
uv sync
94+
95+
- name: Run safety check
96+
run: |
97+
uv run safety check
98+
99+
build:
100+
runs-on: ubuntu-latest
101+
needs: [test, lint, security]
102+
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- name: Set up Python
107+
uses: actions/setup-python@v4
108+
with:
109+
python-version: "3.11"
110+
111+
- name: Install uv
112+
uses: astral-sh/setup-uv@v2
113+
114+
- name: Build package
115+
run: |
116+
uv build
117+
118+
- name: Upload build artifacts
119+
uses: actions/upload-artifact@v3
120+
with:
121+
name: python-package-distributions
122+
path: dist/

Makefile

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
.PHONY: help install test test-unit test-integration test-performance test-all lint format clean coverage docs
2+
3+
# Default target
4+
help:
5+
@echo "ByteWaves Testing Framework"
6+
@echo "=========================="
7+
@echo ""
8+
@echo "Available targets:"
9+
@echo " install - Install the package with development dependencies"
10+
@echo " test - Run all tests"
11+
@echo " test-unit - Run unit tests only"
12+
@echo " test-int - Run integration tests only"
13+
@echo " test-perf - Run performance tests only"
14+
@echo " test-all - Run all tests with coverage"
15+
@echo " lint - Run linting checks"
16+
@echo " format - Format code with black and isort"
17+
@echo " clean - Clean up generated files"
18+
@echo " coverage - Generate coverage report"
19+
@echo " docs - Generate documentation"
20+
@echo " ci - Run full CI pipeline locally"
21+
22+
# Installation
23+
install:
24+
@echo "Installing ByteWaves with development dependencies..."
25+
@if command -v uv &> /dev/null; then \
26+
uv sync --dev; \
27+
else \
28+
pip install -e ".[dev]"; \
29+
fi
30+
31+
# Testing targets
32+
test:
33+
@echo "Running all tests..."
34+
@if command -v uv &> /dev/null; then \
35+
uv run pytest tests/ -v; \
36+
else \
37+
pytest tests/ -v; \
38+
fi
39+
40+
test-unit:
41+
@echo "Running unit tests..."
42+
@if command -v uv &> /dev/null; then \
43+
uv run pytest tests/unit/ -v; \
44+
else \
45+
pytest tests/unit/ -v; \
46+
fi
47+
48+
test-int:
49+
@echo "Running integration tests..."
50+
@if command -v uv &> /dev/null; then \
51+
uv run pytest tests/integration/ -v; \
52+
else \
53+
pytest tests/integration/ -v; \
54+
fi
55+
56+
test-perf:
57+
@echo "Running performance tests..."
58+
@if command -v uv &> /dev/null; then \
59+
uv run pytest tests/performance/ -v; \
60+
else \
61+
pytest tests/performance/ -v; \
62+
fi
63+
64+
test-all:
65+
@echo "Running all tests with coverage..."
66+
@if command -v uv &> /dev/null; then \
67+
uv run pytest tests/ --cov=bytewaves --cov-report=html --cov-report=term-missing; \
68+
else \
69+
pytest tests/ --cov=bytewaves --cov-report=html --cov-report=term-missing; \
70+
fi
71+
72+
# Code quality
73+
lint:
74+
@echo "Running linting checks..."
75+
@if command -v uv &> /dev/null; then \
76+
uv run flake8 bytewaves/; \
77+
uv run black --check --diff bytewaves/; \
78+
uv run isort --check-only --diff bytewaves/; \
79+
else \
80+
flake8 bytewaves/; \
81+
black --check --diff bytewaves/; \
82+
isort --check-only --diff bytewaves/; \
83+
fi
84+
85+
format:
86+
@echo "Formatting code..."
87+
@if command -v uv &> /dev/null; then \
88+
uv run black bytewaves/; \
89+
uv run isort bytewaves/; \
90+
else \
91+
black bytewaves/; \
92+
isort bytewaves/; \
93+
fi
94+
95+
# Cleanup
96+
clean:
97+
@echo "Cleaning up generated files..."
98+
@rm -rf build/
99+
@rm -rf dist/
100+
@rm -rf *.egg-info/
101+
@rm -rf .coverage
102+
@rm -rf coverage.xml
103+
@rm -rf htmlcov/
104+
@rm -rf .pytest_cache/
105+
@rm -rf __pycache__/
106+
@find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
107+
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
108+
109+
# Coverage
110+
coverage:
111+
@echo "Generating coverage report..."
112+
@if command -v uv &> /dev/null; then \
113+
uv run pytest tests/ --cov=bytewaves --cov-report=html; \
114+
else \
115+
pytest tests/ --cov=bytewaves --cov-report=html; \
116+
fi
117+
@echo "Coverage report generated in htmlcov/index.html"
118+
119+
# Documentation
120+
docs:
121+
@echo "Generating documentation..."
122+
@if command -v uv &> /dev/null; then \
123+
uv run sphinx-build docs/ docs/_build/; \
124+
else \
125+
sphinx-build docs/ docs/_build/; \
126+
fi
127+
128+
# Local CI simulation
129+
ci: lint test-all coverage
130+
@echo "CI pipeline completed successfully!"
131+
132+
# Quick test (fast feedback)
133+
quick-test:
134+
@echo "Running quick test suite..."
135+
@if command -v uv &> /dev/null; then \
136+
uv run pytest tests/unit/ -x; \
137+
else \
138+
pytest tests/unit/ -x; \
139+
fi
140+
141+
# Benchmark specific components
142+
benchmark:
143+
@echo "Running benchmarks..."
144+
@if command -v uv &> /dev/null; then \
145+
uv run pytest tests/performance/test_benchmarks.py -v; \
146+
else \
147+
pytest tests/performance/test_benchmarks.py -v; \
148+
fi
149+
150+
# Security scan
151+
security:
152+
@echo "Running security checks..."
153+
@if command -v uv &> /dev/null; then \
154+
uv run safety check; \
155+
uv run bandit -r bytewaves/; \
156+
else \
157+
safety check; \
158+
bandit -r bytewaves/; \
159+
fi
160+
161+
# Development workflow
162+
dev-setup: install
163+
@echo "Setting up development environment..."
164+
@cp -n requirements-dev.txt requirements-dev.txt.backup 2>/dev/null || true
165+
@echo "Installing pre-commit hooks..."
166+
@if command -v uv &> /dev/null; then \
167+
uv run pre-commit install; \
168+
else \
169+
pre-commit install; \
170+
fi
171+
172+
# Quick check for common issues
173+
health-check:
174+
@echo "Running health checks..."
175+
@if command -v uv &> /dev/null; then \
176+
uv run python -c "import bytewaves; print('✅ Import successful')"; \
177+
uv run python -m py_compile bytewaves/*.py; \
178+
else \
179+
python -c "import bytewaves; print('✅ Import successful')"; \
180+
python -m py_compile bytewaves/*.py; \
181+
fi
182+
@echo "Health check completed"

0 commit comments

Comments
 (0)