Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
155 lines
6.4 KiB
Makefile
155 lines
6.4 KiB
Makefile
TARGET=thechart
|
|
VERSION=1.14.9
|
|
ROOT=/home/will
|
|
ICON=chart-671.png
|
|
SHELL=fish
|
|
|
|
# Virtual environment variables
|
|
VENV_DIR=.venv
|
|
VENV_ACTIVATE=$(VENV_DIR)/bin/activate
|
|
PYTHON=$(VENV_DIR)/bin/python
|
|
|
|
help: ## Show this help
|
|
@grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
|
|
clean: ## Clean up build artifacts and virtual environment
|
|
@echo "Cleaning up build artifacts and virtual environment..."
|
|
@rm -rf $(VENV_DIR)
|
|
@rm -rf build/
|
|
@rm -rf dist/
|
|
@rm -rf htmlcov/
|
|
@rm -rf .pytest_cache/
|
|
@rm -rf .ruff_cache/
|
|
@rm -rf src/__pycache__/
|
|
@rm -rf tests/__pycache__/
|
|
@rm -f .coverage
|
|
@rm -f coverage.xml
|
|
@echo "✅ Cleanup complete!"
|
|
|
|
reinstall: clean install ## Clean and reinstall the development environment
|
|
|
|
check-env: ## Check if the development environment is properly set up
|
|
@echo "Checking development environment..."
|
|
@bash -c 'if [ ! -d "$(VENV_DIR)" ]; then \
|
|
echo "❌ Virtual environment not found at $(VENV_DIR)"; \
|
|
echo " Run \"make install\" to set up the environment"; \
|
|
exit 1; \
|
|
fi'
|
|
@bash -c 'if [ ! -f "$(PYTHON)" ]; then \
|
|
echo "❌ Python executable not found at $(PYTHON)"; \
|
|
echo " Run \"make install\" to set up the environment"; \
|
|
exit 1; \
|
|
fi'
|
|
@echo "✅ Virtual environment: $(VENV_DIR)"
|
|
@echo "✅ Python executable: $(PYTHON)"
|
|
@$(PYTHON) --version
|
|
@$(PYTHON) -c "import sys; print(f'✅ Python path: {sys.executable}')"
|
|
@bash -c 'if cd /home/will/Code/thechart && $(PYTHON) -c "import sys; sys.path.insert(0, \"src\"); import main" 2>/dev/null; then \
|
|
echo "✅ Main module imports successfully"; \
|
|
else \
|
|
echo "❌ Main module import failed"; \
|
|
exit 1; \
|
|
fi'
|
|
@bash -c 'if $(PYTHON) -c "import pre_commit" 2>/dev/null; then \
|
|
echo "✅ Pre-commit is installed"; \
|
|
else \
|
|
echo "⚠️ Pre-commit not found (run \"make install\" to fix)"; \
|
|
fi'
|
|
@echo "✅ Environment check completed successfully!"
|
|
install: ## Set up the development environment
|
|
@echo "Setting up the development environment..."
|
|
@echo "Creating virtual environment..."
|
|
@bash -c 'if [ -d "$(VENV_DIR)" ]; then \
|
|
echo "Virtual environment already exists. Recreating..."; \
|
|
rm -rf $(VENV_DIR); \
|
|
fi'
|
|
uv venv $(VENV_DIR) --python=python3.13
|
|
@echo "Installing dependencies..."
|
|
uv sync --dev --no-cache-dir
|
|
@echo "Installing pre-commit hooks..."
|
|
$(PYTHON) -m pre_commit install
|
|
@echo "Verifying installation..."
|
|
@$(PYTHON) --version
|
|
@$(PYTHON) -c "import sys; print(f'Python executable: {sys.executable}')"
|
|
@echo "Testing module imports..."
|
|
@cd /home/will/Code/thechart && $(PYTHON) -c "import sys; sys.path.insert(0, 'src'); import main; print('✅ Main module imports successfully')"
|
|
@echo "Development environment setup complete!"
|
|
@echo ""
|
|
@echo "🐟 For Fish shell users:"
|
|
@echo " source $(VENV_DIR)/bin/activate.fish"
|
|
@echo ""
|
|
@echo "🐚 For Bash/Zsh shell users:"
|
|
@echo " source $(VENV_ACTIVATE)"
|
|
@echo ""
|
|
@echo "To run the application: make run"
|
|
@echo "To run tests: make test"
|
|
build: ## Build the Docker image
|
|
@echo "Building the Docker image..."
|
|
docker buildx build --platform linux/amd64 -t ${IMAGE} --push .
|
|
deploy: ## Deploy the application as a standalone executable
|
|
@echo "Deploying the application..."
|
|
pyinstaller --name ${TARGET} --optimize 2 --onefile --windowed --hidden-import='PIL._tkinter_finder' --icon='${ICON}' --add-data="./.env:." --add-data='./chart-671.png:.' --log-level=DEBUG src/main.py
|
|
cp -f ./thechart_data.csv ${ROOT}/Documents/
|
|
cp -f ./dist/${TARGET} ${ROOT}/Applications/
|
|
cp -f ./deploy/${TARGET}.desktop ${ROOT}/.local/share/applications/
|
|
desktop-file-validate ${ROOT}/.local/share/applications/${TARGET}.desktop
|
|
run: $(VENV_ACTIVATE) ## Run the application
|
|
@echo "Running the application..."
|
|
@bash -c 'if [ ! -f "$(VENV_ACTIVATE)" ]; then \
|
|
echo "❌ Virtual environment not found. Run \"make install\" first."; \
|
|
exit 1; \
|
|
fi'
|
|
$(PYTHON) src/main.py
|
|
start: ## Start the application
|
|
@echo "Starting the application..."
|
|
docker-compose up -d --build
|
|
stop: ## Stop the application
|
|
@echo "Stopping the application..."
|
|
docker-compose down
|
|
test: ## Run the tests
|
|
@echo "Running the tests..."
|
|
.venv/bin/python -m pytest tests/ -v --cov=src --cov-report=term-missing --cov-report=html:htmlcov
|
|
test-unit: ## Run unit tests only
|
|
@echo "Running unit tests..."
|
|
.venv/bin/python -m pytest tests/ -v --tb=short
|
|
test-coverage: ## Run tests with detailed coverage report
|
|
@echo "Running tests with coverage..."
|
|
.venv/bin/python -m pytest tests/ --cov=src --cov-report=html:htmlcov --cov-report=xml --cov-report=term-missing
|
|
test-watch: ## Run tests in watch mode
|
|
@echo "Running tests in watch mode..."
|
|
.venv/bin/python -m pytest-watch tests/ -- -v --cov=src
|
|
test-debug: ## Run tests with debug output
|
|
@echo "Running tests with debug output..."
|
|
.venv/bin/python -m pytest tests/ -v -s --tb=long --cov=src
|
|
lint: ## Run the linter
|
|
@echo "Running the linter..."
|
|
docker-compose exec ${TARGET} pipenv run pre-commit run --all-files
|
|
format: ## Format the code
|
|
@echo "Formatting the code..."
|
|
docker-compose exec ${TARGET} pipenv run pre-commit run --all-files --show-diff
|
|
attach: ## Open a shell in the container
|
|
@echo "Opening a shell in the container..."
|
|
docker-compose exec -it ${TARGET} /bin/bash
|
|
shell: ## Open a shell in the local environment
|
|
@echo "Opening a shell in the local environment..."
|
|
source .venv/bin/activate.${SHELL}; /bin/${SHELL}
|
|
requirements: ## Export the requirements to a file
|
|
@echo "Exporting requirements to requirements.txt..."
|
|
poetry export --without-hashes -f requirements.txt -o requirements.txt
|
|
|
|
update-version: ## Update version in pyproject.toml from .env file and sync uv.lock
|
|
@echo "Updating version in pyproject.toml from .env..."
|
|
@$(PYTHON) scripts/update_version.py
|
|
|
|
update-version-only: ## Update version in pyproject.toml from .env file (skip uv.lock)
|
|
@echo "Updating version in pyproject.toml from .env (skipping uv.lock)..."
|
|
@$(PYTHON) scripts/update_version.py --skip-uv-lock
|
|
|
|
commit-emergency: ## Emergency commit (bypasses pre-commit hooks) - USE SPARINGLY
|
|
@echo "⚠️ WARNING: Emergency commit bypasses all pre-commit checks!"
|
|
@echo "This should only be used in true emergencies."
|
|
@read -p "Enter commit message: " msg; \
|
|
git add . && git commit --no-verify -m "$$msg"
|
|
@echo "✅ Emergency commit completed. Please run tests manually when possible."
|
|
.PHONY: install clean reinstall check-env build attach deploy run start stop test lint format shell requirements update-version update-version-only commit-emergency help
|