2023-01-12 02:49:58 +02:00
|
|
|
.DEFAULT_GOAL := lint
|
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
|
2024-05-07 22:42:31 +03:00
|
|
|
mongo_connection := mongodb://mongo:mongo@localhost:27017
|
2021-06-15 01:45:31 +03:00
|
|
|
|
2019-11-15 14:21:35 +02:00
|
|
|
# =================================================================================================
|
|
|
|
|
# Environment
|
|
|
|
|
# =================================================================================================
|
|
|
|
|
|
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
|
2023-02-18 15:46:28 +02:00
|
|
|
rm -rf {build,dist,site,.cache,.mypy_cache,.ruff_cache,reports}
|
2019-11-15 14:21:35 +02:00
|
|
|
|
2024-06-14 20:11:08 +03:00
|
|
|
.PHONY: install
|
|
|
|
|
install: clean
|
|
|
|
|
pip install -e ."[dev,test,docs]" -U --upgrade-strategy=eager
|
|
|
|
|
pre-commit install
|
|
|
|
|
|
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:
|
2023-01-12 02:49:58 +02:00
|
|
|
isort --check-only $(code_dir)
|
|
|
|
|
black --check --diff $(code_dir)
|
2025-10-06 19:19:23 +03:00
|
|
|
ruff check --show-fixes --preview $(package_dir) $(examples_dir)
|
2023-01-12 02:49:58 +02:00
|
|
|
mypy $(package_dir)
|
2021-06-15 01:45:31 +03:00
|
|
|
|
|
|
|
|
.PHONY: reformat
|
|
|
|
|
reformat:
|
2023-01-12 02:49:58 +02:00
|
|
|
black $(code_dir)
|
|
|
|
|
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
|
2024-05-07 22:42:31 +03:00
|
|
|
pytest --cov=aiogram --cov-config .coveragerc tests/ --redis $(redis_connection) --mongo $(mongo_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/
|
2024-05-07 22:42:31 +03:00
|
|
|
pytest --cov=aiogram --cov-config .coveragerc --html=$(reports_dir)/tests/index.html tests/ --redis $(redis_connection) --mongo $(mongo_connection)
|
2023-01-12 02:49:58 +02:00
|
|
|
coverage html -d $(reports_dir)/coverage
|
2020-05-26 00:23:35 +03:00
|
|
|
|
2020-05-26 22:13:01 +03:00
|
|
|
.PHONY: test-coverage-view
|
2020-05-26 00:23:35 +03:00
|
|
|
test-coverage-view:
|
2023-01-12 02:49:58 +02:00
|
|
|
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
|
|
|
|
|
# =================================================================================================
|
|
|
|
|
|
2023-10-08 19:14:12 +03:00
|
|
|
locales := 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:
|
2023-07-30 18:32:37 +03:00
|
|
|
hatch run docs:bash -c 'cd $(docs_dir) && make gettext'
|
|
|
|
|
hatch run docs:bash -c '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:
|
2024-09-08 15:53:44 +03:00
|
|
|
hatch run docs:sphinx-autobuild --watch aiogram/ --watch CHANGES.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
|
2023-01-12 02:49:58 +02:00
|
|
|
build: clean
|
|
|
|
|
hatch build
|
2020-05-27 01:24:06 +03:00
|
|
|
|
|
|
|
|
.PHONY: bump
|
|
|
|
|
bump:
|
2023-01-12 02:49:58 +02:00
|
|
|
hatch version $(args)
|
|
|
|
|
python scripts/bump_versions.py
|
2021-08-01 19:08:03 +03:00
|
|
|
|
2024-08-16 00:44:40 +03:00
|
|
|
update-api:
|
|
|
|
|
butcher parse
|
|
|
|
|
butcher refresh
|
|
|
|
|
butcher apply all
|
|
|
|
|
@$(MAKE) bump
|
|
|
|
|
|
2021-08-01 19:08:03 +03:00
|
|
|
.PHONY: towncrier-build
|
|
|
|
|
towncrier-build:
|
2023-11-24 23:29:21 +02:00
|
|
|
hatch run docs:towncrier build --yes
|
2021-08-01 19:08:03 +03:00
|
|
|
|
|
|
|
|
.PHONY: towncrier-draft
|
|
|
|
|
towncrier-draft:
|
2024-08-09 19:10:39 +03:00
|
|
|
hatch run docs:towncrier build --draft
|
2021-08-01 19:08:03 +03:00
|
|
|
|
|
|
|
|
.PHONY: towncrier-draft-github
|
|
|
|
|
towncrier-draft-github:
|
|
|
|
|
mkdir -p dist
|
2024-08-09 19:10:39 +03:00
|
|
|
hatch run docs:towncrier build --draft | pandoc - -o dist/release.md
|
2021-08-01 19:08:03 +03:00
|
|
|
|
|
|
|
|
.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)"
|
2023-02-19 18:10:11 +02:00
|
|
|
git tag v$(shell hatch version -s)
|