aiogram/Makefile

146 lines
4.4 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
package_dir := aiogram
tests_dir := tests
scripts_dir := scripts
examples_dir := examples
code_dir := $(package_dir) $(tests_dir) $(scripts_dir) $(examples_dir)
2020-01-11 20:01:49 +02:00
reports_dir := reports
redis_connection := redis://localhost:6379
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:"
@echo " lint: Lint code by isort, black, flake8 and mypy tools"
@echo " reformat: Reformat code by isort and black tools"
2019-11-15 12:17:57 +02:00
@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-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:
poetry install -E fast -E redis -E proxy -E i18n -E docs
2021-09-10 00:02:53 +03:00
$(py) pre-commit 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
2019-11-17 23:40:52 +02:00
rm -f report.html
2021-09-10 00:02:53 +03: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: lint
lint:
$(py) isort --check-only $(code_dir)
$(py) black --check --diff $(code_dir)
$(py) flake8 $(code_dir)
$(py) mypy $(package_dir)
.PHONY: reformat
reformat:
$(py) black $(code_dir)
$(py) isort $(code_dir)
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/ --redis $(redis_connection)
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/ --redis $(redis_connection)
2019-11-15 14:21:35 +02: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-serve
2019-11-15 14:11:50 +02:00
docs-serve:
2021-05-13 00:13:09 +03:00
rm -rf docs/_build
$(py) sphinx-autobuild --watch aiogram/ docs/ docs/_build/
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
2021-05-13 00:13:09 +03:00
build: clean flake8-report mypy-report test-coverage
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
.PHONY: towncrier-build
towncrier-build:
towncrier build --yes
.PHONY: towncrier-draft
towncrier-draft:
towncrier build --draft
.PHONY: towncrier-draft-github
towncrier-draft-github:
mkdir -p dist
towncrier build --draft | pandoc - -o dist/release.md
.PHONY: prepare-release
prepare-release: bump towncrier-draft-github towncrier-build
.PHONY: tag-release
tag-release:
git tag v$(poetry version -s)