-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
164 lines (137 loc) · 4.45 KB
/
makefile
File metadata and controls
164 lines (137 loc) · 4.45 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
# Destination directory
RELEASE_DESTDIR := ../themeparkwaits.release/
TEST_DIR := /Volumes/CIRCUITPY
# Source directory
SRC_DIR := src
# Python interpreter and pip commands
PYTHON := python
PIP := python -m pip
.PHONY: test test-all test-unit test-coverage install-test-deps dev lint lint-errors clean format test-sldk test-sldk-unit install-sldk-dev
all: test release
# Development mode with simulator
run-local-device-simulator:
$(PYTHON) -m src.main --dev
# Testing targets
test: test-unit
# Run unit tests
# Note: Temporarily renames code.py to avoid conflict with Python's standard 'code' module
test-unit:
@echo "Running unit tests (working around code.py naming conflict)..."
@if [ -f code.py ]; then \
mv code.py code_temp_backup.py && \
$(PYTHON) -m pytest test/unit -v; \
test_result=$$?; \
mv code_temp_backup.py code.py; \
exit $$test_result; \
else \
$(PYTHON) -m pytest test/unit -v; \
fi
# Run all tests
test-all:
@echo "Running all tests (working around code.py naming conflict)..."
@if [ -f code.py ]; then \
mv code.py code_temp_backup.py && \
$(PYTHON) -m pytest; \
test_result=$$?; \
mv code_temp_backup.py code.py; \
exit $$test_result; \
else \
$(PYTHON) -m pytest; \
fi
# Run tests with coverage report
test-coverage:
@echo "Running tests with coverage (working around code.py naming conflict)..."
@if [ -f code.py ]; then \
mv code.py code_temp_backup.py && \
$(PYTHON) -m pytest --cov=src --cov-report=term --cov-report=html; \
test_result=$$?; \
mv code_temp_backup.py code.py; \
exit $$test_result; \
else \
$(PYTHON) -m pytest --cov=src --cov-report=term --cov-report=html; \
fi
# Install test dependencies
install-test-deps:
$(PIP) install pytest pytest-asyncio pytest-cov
# Install development dependencies
install-dev-deps:
$(PIP) install pygame pillow numpy
# Install lint dependencies
install-lint-deps:
$(PIP) install ruff
# Lint all Python files - comprehensive check
lint:
@echo "Running Python linter (ruff)..."
$(PYTHON) -m ruff check $(SRC_DIR) *.py test/ --fix
@echo "Linting complete!"
# Lint only for critical errors (undefined names, syntax errors, etc.)
lint-errors:
@echo "Checking for critical errors..."
$(PYTHON) -m ruff check $(SRC_DIR) *.py --select=E9,F63,F7,F82,F821 --no-fix
@echo "Critical error check complete!"
# Run lint before tests
test-with-lint: lint-errors test
# Copy all files to the release GIT archive
release: $(SRC_DIR)/*.py
cp -f boot.py $(RELEASE_DESTDIR)
cp -f code.py $(RELEASE_DESTDIR)
cp -rf $(SRC_DIR) $(RELEASE_DESTDIR)
# Copy files to the connected MatrixPortal S3 (with lint check)
copy-to-circuitpy : lint-errors $(TEST_DIR)
cp -f boot.py $(TEST_DIR)
cp -f code.py $(TEST_DIR)
rsync -av --update --progress \
--exclude='images/' \
--exclude='.DS_Store' \
--exclude='**/.DS_Store' \
--exclude="__pycache__" \
$(SRC_DIR)/ $(TEST_DIR)/src/
# Copy files without lint check (use with caution)
copy-to-circuitpy-no-lint : $(TEST_DIR)
cp -f boot.py $(TEST_DIR)
cp -f code.py $(TEST_DIR)
rsync -av --update --progress \
--exclude='images/' \
--exclude='.DS_Store' \
--exclude='**/.DS_Store' \
--exclude="__pycache__" \
$(SRC_DIR)/ $(TEST_DIR)/src/
# Clean build artifacts
clean:
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name ".DS_Store" -delete
rm -rf .pytest_cache
rm -rf htmlcov
rm -rf .coverage
# Format code using ruff
format:
@echo "Formatting Python code..."
$(PYTHON) -m ruff format $(SRC_DIR) test/
@echo "Formatting complete\!"
# Install SLDK with simulator support in development mode
install-sldk-dev:
@echo "Installing SLDK in development mode..."
cd sldk && $(PIP) install -e .[dev,simulator]
@echo "SLDK installed\!"
# Run specific experiment tests
test-experiments:
@echo "Available experiment categories:"
@echo " make test-display - Run display experiments"
@echo " make test-network - Run network experiments"
@echo " make test-system - Run system experiments"
@echo " make test-integration - Run integration experiments"
test-display:
$(PYTHON) -m pytest test/experiments/display/ -v
test-network:
$(PYTHON) -m pytest test/experiments/network/ -v
test-system:
$(PYTHON) -m pytest test/experiments/system/ -v
test-integration:
$(PYTHON) -m pytest test/experiments/integration/ -v
# SLDK Testing
test-sldk: test-sldk-unit
# Run SLDK unit tests
test-sldk-unit:
@echo "Running SLDK unit tests..."
@cd sldk && SLDK_TESTING=1 $(PYTHON) -m pytest tests/unit -v