Files
EOS/Makefile
T

195 lines
7.6 KiB
Makefile
Raw Normal View History

# Define the targets
.PHONY: help venv pip install dist test test-full test-system test-ci test-profile docker-run docker-build docs read-docs clean format gitlint mypy run run-dev run-dash run-dash-dev prepare-version test-version
# - Take VERSION from version.py
VERSION := $(shell python3 scripts/get_version.py)
# Default target
all: help
# Target to display help information
help:
@echo "Available targets:"
@echo " venv - Set up a Python 3 virtual environment."
@echo " pip - Install dependencies from requirements.txt."
@echo " pip-dev - Install dependencies from requirements-dev.txt."
@echo " format - Format source code."
@echo " gitlint - Lint last commit message."
@echo " mypy - Run mypy."
@echo " install - Install EOS in editable form (development mode) into virtual environment."
@echo " docker-run - Run entire setup on docker"
@echo " docker-build - Rebuild docker image"
@echo " docs - Generate HTML documentation (in build/docs/html/)."
@echo " read-docs - Read HTML documentation in your browser."
@echo " gen-docs - Generate openapi.json and docs/_generated/*."
@echo " clean-docs - Remove generated documentation."
@echo " run - Run EOS production server in virtual environment."
@echo " run-dev - Run EOS development server in virtual environment (automatically reloads)."
@echo " run-dash - Run EOSdash production server in virtual environment."
@echo " run-dash-dev - Run EOSdash development server in virtual environment (automatically reloads)."
@echo " test - Run tests."
@echo " test-finalize - Run all tests (e.g. to finalize a commit)."
@echo " test-system - Run tests with system tests enabled."
@echo " test-ci - Run tests as CI does. No user config file allowed."
@echo " test-profile - Run single test optimization with profiling."
@echo " dist - Create distribution (in dist/)."
@echo " clean - Remove generated documentation, distribution and virtual environment."
@echo " prepare-version - Prepare a version defined in setup.py."
# Target to set up a Python 3 virtual environment
venv:
python3 -m venv .venv
2025-11-16 13:25:45 +01:00
@PYVER=$$(./.venv/bin/python --version) && \
echo "Virtual environment created in '.venv' with $$PYVER. Activate it using 'source .venv/bin/activate'."
# Target to install dependencies from requirements.txt
pip: venv
2024-10-06 13:47:16 +02:00
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt
@echo "Dependencies installed from requirements.txt."
2024-10-08 14:29:45 +02:00
# Target to install dependencies from requirements.txt
pip-dev: pip
.venv/bin/pip install -r requirements-dev.txt
@echo "Dependencies installed from requirements-dev.txt."
# Target to create a version.txt
version-txt:
echo "$(VERSION)" > version.txt
2024-10-06 13:47:16 +02:00
# Target to install EOS in editable form (development mode) into virtual environment.
install: pip-dev version-txt
2024-10-06 13:47:16 +02:00
.venv/bin/pip install build
.venv/bin/pip install -e .
@echo "EOS installed in editable form (development mode)."
# Target to create a distribution.
dist: pip
.venv/bin/pip install build
.venv/bin/python -m build --wheel
@echo "Distribution created (see dist/)."
# Target to generate documentation
gen-docs: pip-dev version-txt
2025-01-06 19:34:15 +01:00
.venv/bin/pip install -e .
.venv/bin/python ./scripts/generate_config_md.py --output-file docs/_generated/config.md
.venv/bin/python ./scripts/generate_openapi_md.py --output-file docs/_generated/openapi.md
.venv/bin/python ./scripts/generate_openapi.py --output-file openapi.json
@echo "Documentation generated to openapi.json and docs/_generated."
# Target to build HTML documentation
2024-10-10 08:33:21 +02:00
docs: pip-dev
.venv/bin/pytest --finalize tests/test_docsphinx.py
@echo "Documentation build to build/docs/html/."
# Target to read the HTML documentation
read-docs:
@echo "Read the documentation in your browser"
.venv/bin/pytest --finalize tests/test_docsphinx.py
.venv/bin/python -m webbrowser build/docs/html/index.html
# Clean Python bytecode
clean-bytecode:
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type f -name "*.pyc" -delete
2025-01-03 00:31:20 +01:00
# Clean target to remove generated documentation and documentation artefacts
clean-docs:
@echo "Searching and deleting all '_autosum' directories in docs..."
@find docs -type d -name '_autosummary' -exec rm -rf {} +;
2025-01-03 00:31:20 +01:00
@echo "Cleaning docs build directories"
rm -rf build/docs
# Clean target to remove generated documentation, distribution and virtual environment
clean: clean-docs
@echo "Cleaning virtual env, distribution and build directories"
rm -rf build .venv
@echo "Deletion complete."
run:
2025-01-21 19:20:50 +01:00
@echo "Starting EOS production server, please wait..."
.venv/bin/python -m akkudoktoreos.server.eos --startup_eosdash true
2024-11-15 22:27:25 +01:00
run-dev:
2025-01-09 16:54:49 +01:00
@echo "Starting EOS development server, please wait..."
2025-10-28 02:50:31 +01:00
.venv/bin/python -m akkudoktoreos.server.eos --host localhost --port 8503 --log_level DEBUG --startup_eosdash false --reload true
2025-01-22 23:47:28 +01:00
run-dash:
@echo "Starting EOSdash production server, please wait..."
.venv/bin/python -m akkudoktoreos.server.eosdash
run-dash-dev:
@echo "Starting EOSdash development server, please wait..."
2025-10-28 02:50:31 +01:00
.venv/bin/python -m akkudoktoreos.server.eosdash --host localhost --port 8504 --log_level DEBUG --reload true
2024-09-16 11:48:20 +02:00
2024-10-08 14:29:45 +02:00
# Target to setup tests.
test-setup: pip-dev
@echo "Setup tests"
2024-10-06 12:33:18 +02:00
# Target to run tests.
test:
@echo "Running tests..."
.venv/bin/pytest -vs --cov src --cov-report term-missing
2024-10-06 12:33:18 +02:00
# Target to run tests as done by CI on Github.
test-ci:
@echo "Running tests as CI..."
.venv/bin/pytest --finalize --check-config-side-effect -vs --cov src --cov-report term-missing
2025-10-28 02:50:31 +01:00
# Target to run tests including the system tests.
test-system:
@echo "Running tests incl. system tests..."
.venv/bin/pytest --system-test -vs --cov src --cov-report term-missing
2024-11-10 23:22:30 +01:00
# Target to run all tests.
test-finalize:
2024-11-10 23:22:30 +01:00
@echo "Running all tests..."
.venv/bin/pytest --finalize
2024-11-10 23:22:30 +01:00
# Target to run tests including the single test optimization with profiling.
test-profile:
@echo "Running single test optimization with profiling..."
.venv/bin/python tests/single_test_optimization.py --profile
2024-11-15 22:27:25 +01:00
# Target to format code.
format:
.venv/bin/pre-commit run --all-files
2024-11-15 22:27:25 +01:00
2025-10-28 02:50:31 +01:00
# Target to trigger gitlint using pre-commit for the latest commit messages
2025-04-07 22:23:35 +02:00
gitlint:
2025-10-28 02:50:31 +01:00
.venv/bin/cz check --rev-range main..HEAD
2025-04-07 22:23:35 +02:00
2024-11-26 22:28:05 +01:00
# Target to format code.
mypy:
.venv/bin/mypy
2024-09-16 11:48:20 +02:00
# Run entire setup on docker
docker-run:
@echo "Build and run EOS docker container locally."
@echo "Persistent data (and config) in ${HOME}/.local/share/net.akkudoktor.eos"
2025-11-16 13:25:45 +01:00
@docker pull python:3.13.9-slim
2024-10-07 20:56:10 +02:00
@docker compose up --remove-orphans
docker-build:
@echo "Build EOS docker container locally."
@echo "Persistent data (and config) in ${HOME}/.local/share/net.akkudoktor.eos"
2025-11-16 13:25:45 +01:00
@docker pull python:3.13.9-slim
@docker compose build
2025-10-28 02:50:31 +01:00
# Propagete version info to all version files
# Take UPDATE_FILES from GitHub action bump-version.yml
UPDATE_FILES := $(shell sed -n 's/^[[:space:]]*UPDATE_FILES[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' \
.github/workflows/bump-version.yml)
prepare-version: #pip-dev
@echo "Update version to $(VERSION) from version.py in files $(UPDATE_FILES) and doc"
.venv/bin/python ./scripts/update_version.py $(VERSION) $(UPDATE_FILES)
.venv/bin/python ./scripts/convert_lightweight_tags.py
.venv/bin/python ./scripts/generate_config_md.py --output-file docs/_generated/config.md
.venv/bin/python ./scripts/generate_openapi_md.py --output-file docs/_generated/openapi.md
.venv/bin/python ./scripts/generate_openapi.py --output-file openapi.json
.venv/bin/pytest -vv --finalize tests/test_version.py
2025-11-09 09:07:04 +01:00
test-version:
echo "Test version information to be correctly set in all version files"
.venv/bin/pytest -vv tests/test_version.py