|
| 1 | + |
| 2 | +default: help |
| 3 | + |
| 4 | +help: # Show help for each of the Makefile recipes. |
| 5 | + @grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done |
| 6 | + |
| 7 | +lint: # Format with black and lint with ruff. |
| 8 | + @echo "[+] Linting" |
| 9 | + @if [ ! -d "./venv" ]; then echo "No venv detected. Please use 'make install-dev' first."; exit 1; fi |
| 10 | + @. ./venv/bin/activate && black . |
| 11 | + |
| 12 | +type-check: # Run mypy. |
| 13 | + @echo "[+] Type checking" |
| 14 | + @if [ ! -d "./venv" ]; then echo "No venv detected. Please use 'make install-dev' first."; exit 1; fi |
| 15 | + @# Only run mypy for now, maybe add pylint/ruff |
| 16 | + @. ./venv/bin/activate && python -m mypy --exclude build --exclude tests \ |
| 17 | + --check-untyped-defs \ |
| 18 | + --follow-untyped-imports \ |
| 19 | + --config-file sighthouse-core/pyproject.toml \ |
| 20 | + sighthouse-core |
| 21 | + @# Exclude core modules as well for now |
| 22 | + @. ./venv/bin/activate && python -m mypy --exclude build --exclude tests --exclude core_modules \ |
| 23 | + --check-untyped-defs \ |
| 24 | + --follow-untyped-imports \ |
| 25 | + --config-file sighthouse-core/pyproject.toml \ |
| 26 | + sighthouse-pipeline |
| 27 | + @. ./venv/bin/activate && python -m mypy --exclude build --exclude tests \ |
| 28 | + --check-untyped-defs \ |
| 29 | + --follow-untyped-imports \ |
| 30 | + --config-file sighthouse-frontend/pyproject.toml \ |
| 31 | + sighthouse-frontend |
| 32 | + |
| 33 | +test: # Run pytest. |
| 34 | + @echo "[+] Run tests" |
| 35 | + @if [ ! -d "./venv" ]; then echo "No venv detected. Please use 'make install-dev' first."; exit 1; fi |
| 36 | + @# Create tmp directory if it does not exists (it's the case for github CI) |
| 37 | + @mkdir -p /tmp/ |
| 38 | + @. ./venv/bin/activate && python -m pytest --cov="sighthouse" --cov-report=html \ |
| 39 | + src sighthouse-core sighthouse-pipeline \ |
| 40 | + sighthouse-client sighthouse-frontend |
| 41 | + |
| 42 | +install-hooks: # Install git hooks |
| 43 | + @echo "Copy git hooks" |
| 44 | + @if [ -d ".git" ]; then mkdir -p .git/hooks/ && cp ./.hooks/* .git/hooks/; fi |
| 45 | + |
| 46 | +install: # Install sighthouse in a new virtual env. |
| 47 | + @if [ ! -d "./venv" ]; then python3 -m venv venv; fi |
| 48 | + @. ./venv/bin/activate && cd sighthouse-cli && pip install . |
| 49 | + @. ./venv/bin/activate && cd sighthouse-core && pip install . |
| 50 | + @. ./venv/bin/activate && cd sighthouse-client && pip install . |
| 51 | + @. ./venv/bin/activate && cd sighthouse-frontend && pip install . |
| 52 | + @. ./venv/bin/activate && cd sighthouse-pipeline && pip install . |
| 53 | + @. ./venv/bin/activate && pip install .[all] |
| 54 | + |
| 55 | +install-dev: # Install sighthouse in a new virtual env in debug mode. |
| 56 | +install-dev: install-hooks |
| 57 | + @if [ ! -d "./venv" ]; then python3 -m venv venv; fi |
| 58 | + @. ./venv/bin/activate && cd sighthouse-cli && pip install . |
| 59 | + @. ./venv/bin/activate && cd sighthouse-core && pip install . |
| 60 | + @. ./venv/bin/activate && cd sighthouse-client && pip install . |
| 61 | + @. ./venv/bin/activate && cd sighthouse-frontend && pip install . |
| 62 | + @. ./venv/bin/activate && cd sighthouse-pipeline && pip install . |
| 63 | + @. ./venv/bin/activate && pip install .[all] |
| 64 | + @. ./venv/bin/activate && pip install pytest mypy black pytest-cov |
| 65 | + |
| 66 | +clean: # Clean build artefacts |
| 67 | + @echo "[+] Clean" |
| 68 | + @find . -name '__pycache__' -type d -exec rm -rf {} + |
| 69 | + @find . -name '*.class' -type f -delete |
| 70 | + @find . -name '*.egg-info' -type d -exec rm -rf {} + |
| 71 | + @$(RM) -rf dist build sighthouse-pipeline/build sighthouse-frontend/build sighthouse-core/build \ |
| 72 | + sighthouse-client/build htmlcov .coverage |
| 73 | + |
0 commit comments