aiogram/Makefile

135 lines
3.8 KiB
Makefile
Raw Normal View History

.DEFAULT_GOAL := lint
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
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
rm -f .coverage
rm -rf {build,dist,site,.cache,.mypy_cache,.ruff_cache,reports}
2019-11-15 14:21:35 +02:00
# =================================================================================================
# Code quality
# =================================================================================================
2020-05-26 22:13:01 +03:00
.PHONY: lint
lint:
isort --check-only $(code_dir)
black --check --diff $(code_dir)
ruff $(package_dir)
mypy $(package_dir)
.PHONY: reformat
reformat:
black $(code_dir)
isort $(code_dir)
2019-11-15 12:44:24 +02:00
2019-11-15 14:21:35 +02:00
# =================================================================================================
# Tests
# =================================================================================================
.PHONY: test-run-services
test-run-services:
@#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
test: test-run-services
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
test-coverage: test-run-services
2020-01-11 20:01:49 +02:00
mkdir -p $(reports_dir)/tests/
pytest --cov=aiogram --cov-config .coveragerc --html=$(reports_dir)/tests/index.html tests/ --redis $(redis_connection)
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:
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
# =================================================================================================
locales := uk_UA
locale_targets := $(addprefix docs-serve-, $(locales))
locales_pot := _build/gettext
docs_dir := docs
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))'
.PHONY: docs-gettext
2019-11-15 14:11:50 +02:00
docs-serve:
hatch run docs:sphinx-autobuild --watch aiogram/ --watch CHANGELOG.rst --watch README.rst docs/ docs/_build/ $(OPTS)
.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
build: clean
hatch build
.PHONY: bump
bump:
hatch 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
2022-04-19 22:09:43 +03:00
prepare-release: bump towncrier-build
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)
2023-10-29 02:15:50 +03:00
butcher_version := 0.1.23
butcher-install:
pip install -U git+ssh://git@github.com/aiogram/butcher.git@v$(butcher_version)
.PHONY: butcher-install
butcher:
butcher parse
butcher refresh
butcher apply all
.PHONY: butcher