forked from murbard/pytezos
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
132 lines (99 loc) · 4.93 KB
/
Makefile
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
121
122
123
124
125
126
127
128
129
130
131
132
.ONESHELL:
.PHONY: $(MAKECMDGOALS)
##
## 🚧 PyTezos developer tools
##
## DEV=1 Whether to install dev dependencies
DEV=1
## TAG=latest Tag for the `image` command
TAG=latest
##
help: ## Show this help (default)
@grep -Fh "##" $(MAKEFILE_LIST) | grep -Fv grep -F | sed -e 's/\\$$//' | sed -e 's/##//'
all: ## Run a whole CI pipeline: lint, run tests, build docs
make install lint test docs
install-deps: ## Install binary dependencies
ifneq (,$(findstring linux-gnu,$(OSTYPE)))
sudo apt install libsodium-dev libgmp-dev pkg-config
else ifneq (,$(findstring darwin,$(OSTYPE)))
brew install libsodium gmp pkg-config
else
echo "Unsupported platform $(OSTYPE)"
exit 1
endif
install: ## Install project dependencies
poetry install \
`if [ "${DEV}" = "0" ]; then echo "--no-dev"; fi`
lint: ## Lint with all tools
make isort black ruff mypy
test: ## Run test suite
# FIXME: https://github.com/pytest-dev/pytest-xdist/issues/385#issuecomment-1177147322
poetry run sh -c "pytest --cov-report=term-missing --cov=pytezos --cov=michelson_kernel --cov-report=xml -n auto -s -v tests/contract_tests tests/integration_tests tests/unit_tests && pytest -xv tests/sandbox_tests"
test-ci:
poetry run sh -c "pytest --junitxml="unit_test_results.xml" -sv tests/unit_tests"
poetry run sh -c "pytest --junitxml="contract_test_results.xml" -sv tests/contract_tests"
poetry run sh -c "pytest --junitxml="integration_test_results.xml" -sv tests/integration_tests"
ifneq (,$(findstring linux-gnu,$(OSTYPE)))
poetry run sh -c "pytest --junitxml="sandbox_test_results.xml" -xv tests/sandbox_tests"
endif
docs: ## Build docs
make kernel-docs rpc-docs
cd docs
rm -r build || true
poetry run make html
cd ..
##
isort: ## Format with isort
poetry run isort src tests scripts
black: ## Format with black
poetry run black src tests scripts --exclude ".*/docs.py"
ruff: ## Lint with ruff
poetry run ruff check src tests scripts
mypy: ## Lint with mypy
poetry run mypy src scripts tests
cover: ## Print coverage for the current branch
poetry run diff-cover --compare-branch `git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'` coverage.xml
build: ## Build Python wheel package
poetry build
image: ## Build Docker image
docker buildx build . --file pytezos.dockerfile -t pytezos:${TAG} --load
docker buildx build . --file michelson-kernel.dockerfile -t michelson-kernel:${TAG} --load
clean: ## Remove all files from .gitignore except for `.venv`
git clean -xdf --exclude=".venv"
update: ## Update dependencies, export requirements.txt
poetry update
cp pyproject.toml pyproject.toml.bak
cp poetry.lock poetry.lock.bak
poetry export --without-hashes -o requirements.txt
poetry export --without-hashes -o requirements.dev.txt --with dev
poetry remove notebook
poetry export --without-hashes -o requirements.slim.txt
mv pyproject.toml.bak pyproject.toml
mv poetry.lock.bak poetry.lock
make install
##
install-kernel: ## Install Michelson IPython kernel
poetry run michelson-kernel install
remove-kernel: ## Remove Michelson IPython kernel
jupyter kernelspec uninstall michelson -f
notebook: ## Run Jupyter notebook
poetry run jupyter notebook
##
update-tzips: ## Update TZIP-16 schema and tests
wget https://gitlab.com/tzip/tzip/-/raw/master/proposals/tzip-16/metadata-schema.json -O src/pytezos/contract/metadata-schema.json
wget https://gitlab.com/tzip/tzip/-/raw/master/proposals/tzip-16/examples/example-000.json -O tests/unit_tests/test_contract/metadata/example-000.json
wget https://gitlab.com/tzip/tzip/-/raw/master/proposals/tzip-16/examples/example-001.json -O tests/unit_tests/test_contract/metadata/example-001.json
wget https://gitlab.com/tzip/tzip/-/raw/master/proposals/tzip-16/examples/example-002.json -O tests/unit_tests/test_contract/metadata/example-002.json
wget https://gitlab.com/tzip/tzip/-/raw/master/proposals/tzip-16/examples/example-003.json -O tests/unit_tests/test_contract/metadata/example-003.json
wget https://gitlab.com/tzip/tzip/-/raw/master/proposals/tzip-16/examples/example-004.json -O tests/unit_tests/test_contract/metadata/example-004.json
wget https://gitlab.com/tzip/tzip/-/raw/master/proposals/tzip-16/examples/example-005.json -O tests/unit_tests/test_contract/metadata/example-005.json
update-contracts: ## Update contract tests
poetry run python scripts/fetch_contract_data.py
poetry run python scripts/generate_contract_tests.py
# poetry run pytest -v tests/contract_tests
kernel-docs: ## Build docs for Michelson IPython kernel
poetry run python scripts/generate_kernel_docs.py
rpc-docs: ## Build docs for Tezos node RPC
poetry run python scripts/fetch_rpc_docs.py
before_release: ## Prepare for a new release after updating version in pyproject.toml
make update all