-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (121 loc) · 4.65 KB
/
Makefile
File metadata and controls
146 lines (121 loc) · 4.65 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
# FreeSleep Makefile
# Standard tasks for development workflow
.PHONY: help install test lint lint-py lint-js run clean setup check format type-check coverage duplication-check collector-setup collector-start collector-stop collector-status collector-monitor collector-logs
# Default target
help:
@echo "FreeSleep Development Commands"
@echo "============================="
@echo "setup - Initial project setup (install deps, create dirs)"
@echo "install - Install Python dependencies"
@echo "test - Run all tests (unit, integration, e2e)"
@echo "test-unit - Run unit tests only"
@echo "test-int - Run integration tests only"
@echo "test-e2e - Run end-to-end tests only"
@echo "lint - Run all linting tools"
@echo "lint-py - Run Python linting (pylint, flake8, black --check)"
@echo "format - Format code with black"
@echo "type-check - Run mypy type checking"
@echo "coverage - Run tests with coverage report"
@echo "duplication-check - Check for duplicated code"
@echo "clean - Clean build artifacts and cache"
@echo "run - Start the FreeSleep application"
@echo "check - Run all checks (lint, type-check, test)"
@echo ""
@echo "Data Collection Commands"
@echo "======================="
@echo "collector-collect - Run manual collection once"
@echo "collector-status - Show current collection status"
@echo "collector-cron-status - Show cron job and recent activity"
@echo "collector-enable-cron - Enable automatic collection (every 5 min)"
@echo "collector-disable-cron - Disable automatic collection"
# Virtual environment activation
VENV = ./venv
PYTHON = $(VENV)/bin/python
PIP = $(VENV)/bin/pip
# Setup and installation
setup: install
@echo "Creating necessary directories..."
@mkdir -p artifacts/logs artifacts/reports
@echo "Setup complete!"
install:
@echo "Installing dependencies..."
$(PIP) install -r requirements.txt
# Testing targets
test: test-unit test-int test-e2e
test-unit:
@echo "Running unit tests..."
$(PYTHON) -m pytest tests/unit/ -v --tb=short
test-int:
@echo "Running integration tests..."
$(PYTHON) -m pytest tests/integration/ -v --tb=short
test-e2e:
@echo "Running end-to-end tests..."
$(PYTHON) -m pytest tests/e2e/ -v --tb=short
coverage:
@echo "Running tests with coverage..."
$(PYTHON) -m pytest tests/ --cov=src/freesleep --cov-report=html --cov-report=term-missing
@echo "Coverage report generated in htmlcov/"
# Linting and formatting
lint: lint-py
lint-py:
@echo "Running Python linting..."
$(PYTHON) -m pylint src/freesleep/ --output-format=text --reports=no --score=no
$(PYTHON) -m flake8 src/freesleep/ --max-line-length=88 --extend-ignore=E203,W503
$(PYTHON) -m black --check src/freesleep/
format:
@echo "Formatting Python code..."
$(PYTHON) -m black src/freesleep/
$(PYTHON) -m black tests/
type-check:
@echo "Running type checking..."
$(PYTHON) -m mypy src/freesleep/ --ignore-missing-imports
duplication-check:
@echo "Checking for code duplication..."
@if command -v jscpd >/dev/null 2>&1; then \
jscpd --config .jscpd.json src/; \
else \
echo "jscpd not installed. Install with: npm install -g jscpd"; \
fi
# Combined check target
check: lint type-check test
@echo "All checks passed!"
# Application execution
run:
@echo "Starting FreeSleep application..."
$(PYTHON) -m src.freesleep.main
# Cleanup
clean:
@echo "Cleaning up..."
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -delete
find . -type d -name ".pytest_cache" -delete
rm -rf htmlcov/
rm -rf .coverage
rm -rf artifacts/reports/*
@echo "Clean complete!"
# Development helpers
dev-install:
$(PIP) install -e .
# Data Collection System
# Data Collection System (Cron-based)
collector-collect:
@echo "Running manual sensor data collection..."
./bin/collect_sensor_data_simple.sh once
collector-status:
@echo "Checking current collection status..."
./bin/collect_sensor_data_simple.sh status
collector-cron-status:
@echo "Checking cron job status..."
@echo "Current cron jobs:"
@crontab -l | grep freesleep || echo "No freesleep cron jobs found"
@echo ""
@echo "Recent collection activity:"
@tail -10 artifacts/logs/data_collection.log 2>/dev/null || echo "No logs yet"
collector-disable-cron:
@echo "Disabling automatic collection..."
@crontab -l 2>/dev/null | grep -v freesleep | crontab - || true
@echo "Automatic collection disabled"
collector-enable-cron:
@echo "Enabling automatic collection every 5 minutes..."
@(crontab -l 2>/dev/null | grep -v freesleep || true; echo "*/5 * * * * cd /home/jem/development/freesleep && ./bin/collect_sensor_data_simple.sh once") | crontab -
@echo "Automatic collection enabled"