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
|
|
|
|
2021-06-15 01:45:31 +03:00
|
|
|
package_dir := aiogram
|
|
|
|
|
tests_dir := tests
|
|
|
|
|
scripts_dir := scripts
|
2021-09-07 00:32:43 +03:00
|
|
|
examples_dir := examples
|
|
|
|
|
code_dir := $(package_dir) $(tests_dir) $(scripts_dir) $(examples_dir)
|
2020-01-11 20:01:49 +02:00
|
|
|
reports_dir := reports
|
|
|
|
|
|
2021-06-15 01:45:31 +03:00
|
|
|
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:"
|
2021-06-15 01:45:31 +03:00
|
|
|
@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)"
|
2020-04-28 12:07:01 +03:00
|
|
|
@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:"
|
2021-06-15 01:45:31 +03:00
|
|
|
@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:
|
2022-10-02 00:04:31 +03:00
|
|
|
poetry install -E fast -E redis -E proxy -E i18n --sync
|
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
|
2022-02-19 01:45:59 +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: lint
|
2021-06-15 01:45:31 +03:00
|
|
|
lint:
|
|
|
|
|
$(py) isort --check-only $(code_dir)
|
|
|
|
|
$(py) black --check --diff $(code_dir)
|
|
|
|
|
$(py) flake8 $(code_dir)
|
|
|
|
|
$(py) mypy $(package_dir)
|
2021-10-12 01:11:53 +03:00
|
|
|
# TODO: wemake-python-styleguide
|
2021-06-15 01:45:31 +03:00
|
|
|
|
|
|
|
|
.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
|
|
|
|
|
# =================================================================================================
|
2021-12-12 17:21:01 +02:00
|
|
|
.PHONY: test-run-services
|
|
|
|
|
test-run-services:
|
2022-02-19 01:45:59 +02:00
|
|
|
@#docker-compose -f tests/docker-compose.yml -p aiogram3-dev up -d
|
2019-11-15 14:21:35 +02:00
|
|
|
|
2020-05-26 22:13:01 +03:00
|
|
|
.PHONY: test
|
2021-12-12 17:21:01 +02:00
|
|
|
test: test-run-services
|
2021-06-15 01:45:31 +03:00
|
|
|
$(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
|
2021-12-12 17:21:01 +02:00
|
|
|
test-coverage: test-run-services
|
2020-01-11 20:01:49 +02:00
|
|
|
mkdir -p $(reports_dir)/tests/
|
2021-06-15 01:45:31 +03:00
|
|
|
$(py) pytest --cov=aiogram --cov-config .coveragerc --html=$(reports_dir)/tests/index.html tests/ --redis $(redis_connection)
|
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
|
2020-04-28 12:07:01 +03:00
|
|
|
python -c "import webbrowser; webbrowser.open('file://$(shell pwd)/reports/coverage/index.html')"
|
|
|
|
|
|
2019-11-15 14:21:35 +02:00
|
|
|
# =================================================================================================
|
|
|
|
|
# Docs
|
|
|
|
|
# =================================================================================================
|
|
|
|
|
|
2022-10-02 00:04:31 +03:00
|
|
|
locales := en uk_UA
|
2022-08-14 01:07:52 +03:00
|
|
|
locale_targets := $(addprefix docs-serve-, $(locales))
|
2022-10-02 18:24:26 +03:00
|
|
|
locales_pot := _build/gettext
|
|
|
|
|
docs_dir := docs
|
2022-08-14 01:07:52 +03:00
|
|
|
|
|
|
|
|
docs-gettext:
|
2022-10-02 18:24:26 +03:00
|
|
|
cd $(docs_dir) && make gettext
|
|
|
|
|
cd $(docs_dir) && sphinx-intl update -p $(locales_pot) $(addprefix -l , $(locales))
|
2022-08-14 01:07:52 +03:00
|
|
|
.PHONY: docs-gettext
|
|
|
|
|
|
2019-11-15 14:11:50 +02:00
|
|
|
docs-serve:
|
2022-10-02 00:04:31 +03:00
|
|
|
#rm -rf docs/_build
|
|
|
|
|
$(py) sphinx-autobuild --watch aiogram/ --watch CHANGELOG.rst --watch README.rst docs/ docs/_build/ $(OPTS)
|
2022-08-14 01:07:52 +03:00
|
|
|
.PHONY: docs-serve
|
|
|
|
|
|
|
|
|
|
$(locale_targets): docs-serve-%:
|
|
|
|
|
$(MAKE) docs-serve OPTS="-D language=$(subst docs-serve-,,$@)"
|
|
|
|
|
.PHONY: $(locale_targets)
|
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
|
2020-05-27 01:24:06 +03:00
|
|
|
|
|
|
|
|
.PHONY: bump
|
|
|
|
|
bump:
|
|
|
|
|
poetry version $(args)
|
|
|
|
|
$(python) scripts/bump_versions.py
|
2021-08-01 19:08:03 +03:00
|
|
|
|
|
|
|
|
.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
|
2022-04-19 22:09:43 +03:00
|
|
|
prepare-release: bump towncrier-build
|
2021-08-01 19:08:03 +03:00
|
|
|
|
2022-04-19 22:09:43 +03:00
|
|
|
.PHONY: release
|
|
|
|
|
release:
|
|
|
|
|
git add .
|
|
|
|
|
git commit -m "Release $(shell poetry version -s)"
|
|
|
|
|
git tag v$(shell poetry version -s)
|
2022-10-02 00:04:31 +03:00
|
|
|
|
|
|
|
|
_poetry_export_args := --format requirements.txt --without-hashes
|
|
|
|
|
|
|
|
|
|
.PHONY: export-requirements
|
|
|
|
|
export-requirements:
|
|
|
|
|
poetry export $(_poetry_export_args) --output requirements/base.txt
|
|
|
|
|
poetry export $(_poetry_export_args) --output requirements/docs.txt -E fast -E redis -E proxy -E i18n --with docs
|