aiogram/Makefile

153 lines
4.2 KiB
Makefile
Raw Normal View History

2019-11-15 12:17:57 +02:00
.DEFAULT_GOAL := help
2019-12-26 00:00:53 +02:00
base_python := python3
2019-11-16 22:32:26 +02:00
py := poetry run
python := $(py) python
2019-11-15 12:17:57 +02:00
2020-01-11 20:01:49 +02:00
reports_dir := reports
2020-05-26 22:13:01 +03:00
.PHONY: help
2019-11-15 12:17:57 +02:00
help:
@echo "======================================================================================="
@echo " aiogram build tools "
@echo "======================================================================================="
2019-11-15 12:44:24 +02:00
@echo "Environment:"
2019-11-18 14:57:11 +02:00
@echo " help: Show this message"
2019-11-15 12:17:57 +02:00
@echo " install: Install development dependencies"
2019-11-18 14:57:11 +02:00
@echo " clean: Delete temporary files"
2019-11-15 12:44:24 +02:00
@echo ""
@echo "Code quality:"
2019-11-15 12:17:57 +02:00
@echo " isort: Run isort tool"
@echo " black: Run black tool"
@echo " flake8: Run flake8 tool"
2019-11-18 14:57:11 +02:00
@echo " flake8-report: Run flake8 with HTML reporting"
2019-11-15 12:17:57 +02:00
@echo " mypy: Run mypy tool"
2019-11-18 14:57:11 +02:00
@echo " mypy-report: Run mypy tool with HTML reporting"
2019-11-15 12:17:57 +02:00
@echo " lint: Run isort, black, flake8 and mypy tools"
@echo ""
2019-11-15 12:44:24 +02:00
@echo "Tests:"
@echo " test: Run tests"
2019-11-18 14:57:11 +02:00
@echo " test-coverage: Run tests with HTML reporting (results + coverage)"
@echo " test-coverage-report: Open coverage report in default system web browser"
2019-11-15 12:44:24 +02:00
@echo ""
2019-11-15 14:11:50 +02:00
@echo "Documentation:"
@echo " docs: Build docs"
@echo " docs-serve: Serve docs for local development"
2019-11-18 14:57:11 +02:00
@echo " docs-prepare-reports: Move all HTML reports to docs dir"
2019-11-15 12:44:24 +02:00
@echo ""
2019-11-18 14:57:11 +02:00
@echo "Project"
@echo " build: Run tests build package and docs"
2019-11-15 12:17:57 +02:00
@echo ""
2019-11-18 14:57:11 +02:00
2019-11-15 14:21:35 +02:00
# =================================================================================================
# Environment
# =================================================================================================
2020-05-26 22:13:01 +03:00
.PHONY: install
2019-11-15 12:17:57 +02:00
install:
2019-11-16 22:32:26 +02:00
$(base_python) -m pip install --user -U poetry
2019-11-15 12:17:57 +02:00
poetry install
2017-10-22 18:36:13 +03:00
2020-05-26 22:13:01 +03:00
.PHONY: clean
2019-11-15 14:21:35 +02:00
clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
2019-11-28 23:21:19 +02:00
rm -rf `find . -name .pytest_cache`
2019-11-15 14:21:35 +02:00
rm -rf *.egg-info
rm -f .coverage
2019-11-17 23:40:52 +02:00
rm -f report.html
2019-11-15 14:21:35 +02:00
rm -f .coverage.*
2019-11-28 23:21:19 +02:00
rm -rf {build,dist,site,.cache,.mypy_cache,reports}
2019-11-15 14:21:35 +02:00
# =================================================================================================
# Code quality
# =================================================================================================
2020-05-26 22:13:01 +03:00
.PHONY: isort
2019-11-15 12:17:57 +02:00
isort:
$(py) isort aiogram tests
2017-11-15 18:51:29 +02:00
2020-05-26 22:13:01 +03:00
.PHONY: black
2019-11-15 12:17:57 +02:00
black:
2019-11-16 22:32:26 +02:00
$(py) black aiogram tests
2017-12-01 01:59:15 +02:00
.PHONY: flake8
2019-11-15 12:17:57 +02:00
flake8:
$(py) flake8 aiogram
2019-11-18 14:57:11 +02:00
.PHONY: flake8-report
2019-11-18 14:57:11 +02:00
flake8-report:
2020-01-11 20:01:49 +02:00
mkdir -p $(reports_dir)/flake8
$(py) flake8 --format=html --htmldir=$(reports_dir)/flake8 aiogram
2017-12-01 02:14:49 +02:00
2020-05-26 22:13:01 +03:00
.PHONY: mypy
2019-11-15 12:17:57 +02:00
mypy:
2020-03-25 16:19:48 +03:00
$(py) mypy aiogram
2019-11-18 14:57:11 +02:00
2020-05-26 22:13:01 +03:00
.PHONY: mypy-report
2019-11-18 14:57:11 +02:00
mypy-report:
2020-03-25 16:19:48 +03:00
$(py) mypy aiogram --html-report $(reports_dir)/typechecking
2017-12-01 02:28:25 +02:00
2020-05-26 22:13:01 +03:00
.PHONY: lint
2019-11-15 12:17:57 +02:00
lint: isort black flake8 mypy
2019-11-15 12:44:24 +02:00
2019-11-15 14:21:35 +02:00
# =================================================================================================
# Tests
# =================================================================================================
2020-05-26 22:13:01 +03:00
.PHONY: test
2019-11-15 12:44:24 +02:00
test:
$(py) pytest --cov=aiogram --cov-config .coveragerc tests/
2019-11-18 14:57:11 +02:00
2020-05-26 22:13:01 +03:00
.PHONY: test-coverage
2019-11-18 14:57:11 +02:00
test-coverage:
2020-01-11 20:01:49 +02:00
mkdir -p $(reports_dir)/tests/
$(py) pytest --cov=aiogram --cov-config .coveragerc --html=$(reports_dir)/tests/index.html tests/
2019-11-15 14:21:35 +02:00
2020-05-26 00:23:35 +03:00
2020-05-26 22:13:01 +03:00
.PHONY: test-coverage-report
test-coverage-report:
2020-05-26 00:23:35 +03:00
$(py) coverage html -d $(reports_dir)/coverage
2020-05-26 22:13:01 +03:00
.PHONY: test-coverage-view
2020-05-26 00:23:35 +03:00
test-coverage-view:
$(py) coverage html -d $(reports_dir)/coverage
python -c "import webbrowser; webbrowser.open('file://$(shell pwd)/reports/coverage/index.html')"
2019-11-15 14:21:35 +02:00
# =================================================================================================
# Docs
# =================================================================================================
2020-05-26 22:13:01 +03:00
.PHONY: docs
2019-11-15 14:11:50 +02:00
docs:
2019-11-16 22:32:26 +02:00
$(py) mkdocs build
2019-11-15 14:11:50 +02:00
2020-05-26 22:13:01 +03:00
.PHONY: docs-serve
2019-11-15 14:11:50 +02:00
docs-serve:
2019-11-16 22:32:26 +02:00
$(py) mkdocs serve
2019-11-17 23:40:52 +02:00
2020-05-26 22:13:01 +03:00
.PHONY: docs-copy-reports
2019-11-17 23:40:52 +02:00
docs-copy-reports:
2020-01-11 20:01:49 +02:00
mv $(reports_dir)/* site/reports
2019-11-18 14:57:11 +02:00
# =================================================================================================
# Project
# =================================================================================================
2019-11-17 23:40:52 +02:00
2020-05-26 22:13:01 +03:00
.PHONY: build
2020-01-11 20:01:49 +02:00
build: clean flake8-report mypy-report test-coverage docs docs-copy-reports
2019-11-18 14:57:11 +02:00
mkdir -p site/simple
poetry build
mv dist site/simple/aiogram
.PHONY: bump
bump:
poetry version $(args)
$(python) scripts/bump_versions.py