-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (101 loc) · 2.77 KB
/
Makefile
File metadata and controls
120 lines (101 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
srcs = src docs/modules/ROOT/examples tests
## all: Run linter and tests.
.PHONY: all
all: lint test
## help: Show this help.
.PHONY: help
help: Makefile
@sed -n 's/^##\s//p' $<
## install: Install all requirements.
.PHONY: install
install: install-corva-sdk install-dev
## install-corva-sdk: Install corva-sdk requirements.
.PHONY: install-corva-sdk
install-corva-sdk:
@pip install -U pip
@pip install -U -e .
## install-dev: Install dev requirements.
.PHONY: install-dev
install-dev: install-corva-sdk
@pip install -U '.[dev]'
## test: Run tests.
.PHONY: test
test: up-cache unit-tests integration-tests down-cache
## unit-tests: Run unit tests.
unit-tests: test_path = tests/unit
unit-tests:
@coverage run -m pytest $(test_path)
## integration-tests: Run integration tests.
.PHONY: integration-tests
integration-tests: export CACHE_URL = redis://localhost:6379
integration-tests: test_path = tests/integration
integration-tests:
@coverage run -m pytest $(test_path)
## coverage: Display code coverage in the console.
.PHONY: coverage
coverage: test
@coverage combine
@coverage report --sort=cover
## coverage-html: Display code coverage in the browser.
.PHONY: coverage-html
coverage-html: test
@coverage combine
@coverage html
@x-www-browser htmlcov/index.html
## lint: Run linter.
.PHONY: lint
lint:
@ruff check $(srcs)
@mypy $(srcs)
## format: Format all files.
.PHONY: format
format:
@ruff check --fix $(srcs)
@ruff format $(srcs)
## docs: Generate docs.
.PHONY: docs
docs:
@docker run --rm --tty -v $(CURDIR):/antora antora/antora:3.0.1 \
docs/antora-playbook.yml
## docs-view: Show HTML docs.
.PHONY: docs-view
docs-view: docs
@x-www-browser docs/build/site/index.html
## clean: Clean autogenerated files.
.PHONY: clean
clean:
@-python3 -Bc "for p in __import__('pathlib').Path('.').rglob('*.py[co]'): p.unlink()"
@-python3 -Bc "for p in __import__('pathlib').Path('.').rglob('__pycache__'): p.rmdir()"
@-rm -rf src/*.egg-info
@-rm -rf .pytest_cache
@-rm -rf htmlcov
@-rm .coverage*
@-sudo rm -rf docs/build
@-rm -rf .mypy_cache
## release: How to release a new version.
.PHONY: release
release:
@echo "Checkout the master branch."
@echo "Update src/version.py with new version."
@echo "Update pyproject.toml version"
@echo "Update docs/antora.yml 'version' with new version like '1.6.0'."
@echo "Update docs/antora-playbook.yml 'content.sources.tags'."
@echo "Update CHANGELOG.md."
@echo "Commit the changes."
@echo "Create tag like 'v1.6.0'."
@echo "Nullify version in docs/antora.yml."
@echo "Commit the changes."
@echo "Push commits and tag."
## up-cache: Start Redis.
.PHONY: up-cache
up-cache:
@docker run \
--rm \
-d \
--name python-sdk-redis \
-p 6379:6379 \
redis:7.4.0
# down-cache: Stop Redis.
.PHONY: down-cache
down-cache:
@docker stop python-sdk-redis