forked from fetchai/agents-aea
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
199 lines (173 loc) · 7.71 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
.PHONY: clean
clean: clean-test clean-build clean-pyc clean-docs
.PHONY: clean-build
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
rm -fr pip-wheel-metadata
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -fr {} +
find . -type d -name __pycache__ -exec rm -rv {} +
rm -fr Pipfile.lock
rm -rf plugins/*/build
rm -rf plugins/*/dist
.PHONY: clean-docs
clean-docs:
rm -fr site/
.PHONY: clean-pyc
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
find . -name '.DS_Store' -exec rm -fr {} +
.PHONY: clean-test
clean-test: clean-cache
rm -fr .tox/
rm -f .coverage
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;
rm -fr coverage.xml
rm -fr htmlcov/
find . -name 'log.txt' -exec rm -fr {} +
find . -name 'log.*.txt' -exec rm -fr {} +
# removes various cache files
.PHONY: clean-cache
clean-cache:
rm -fr .hypothesis/
rm -fr .pytest_cache
rm -fr .mypy_cache/
.PHONY: package-checks
package_checks:
tox -e hash-check
tox -e package-version-checks
tox -e package-dependencies-checks
.PHONY: docs
docs:
mkdocs build --clean
.PHONY: test
test:
pytest -rfE plugins/aea-ledger-fetchai/tests --cov=aea_ledger_fetchai --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
pytest -rfE plugins/aea-ledger-ethereum/tests --cov=aea_ledger_ethereum --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
pytest -rfE plugins/aea-ledger-cosmos/tests --cov=aea_ledger_cosmos --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
pytest -rfE plugins/aea-cli-ipfs/tests --cov=aea_cli_ipfs --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
pytest -rfE --doctest-modules aea packages/valory/protocols packages/valory/connections packages/fetchai/protocols packages/fetchai/connections packages/fetchai/skills tests/ --cov=aea --cov=packages/valory/connections --cov=packages/fetchai/connections --cov=packages/fetchai/contracts --cov=packages/fetchai/protocols --cov=packages/fetchai/skills --cov-report=html --cov-report=xml --cov-report=term-missing --cov-report=term --cov=aea --cov=packages/valory/protocols --cov=packages/fetchai/protocols --cov=packages/fetchai/connections --cov=packages/fetchai/skills --cov-config=.coveragerc
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;
.PHONY: test-sub
test-sub:
pytest -rfE --doctest-modules aea packages/valory/connections packages/valory/protocols packages/fetchai/connections packages/fetchai/protocols packages/fetchai/skills tests/test_$(tdir) --cov=aea.$(dir) --cov-report=html --cov-report=xml --cov-report=term-missing --cov-report=term --cov-config=.coveragerc
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;
.PHONY: test-sub-p
test-sub-p:
pytest -rfE --doctest-modules aea packages/valory/connections packages/valory/protocols packages/fetchai/connections packages/fetchai/protocols packages/fetchai/skills tests/test_packages/test_$(tdir) --cov=packages.fetchai.$(dir) --cov-report=html --cov-report=xml --cov-report=term-missing --cov-report=term --cov-config=.coveragerc
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;
.PHONY: test-all
test-all:
tox
.PHONY: install
install: clean
python3 setup.py install
.PHONY: dist
dist: clean
python setup.py sdist
WIN_BUILD_WHEEL=1 python setup.py bdist_wheel --plat-name=win_amd64
WIN_BUILD_WHEEL=1 python setup.py bdist_wheel --plat-name=win32
python setup.py bdist_wheel --plat-name=manylinux1_x86_64
python setup.py bdist_wheel --plat-name=manylinux2014_aarch64
python setup.py bdist_wheel --plat-name=macosx_10_9_x86_64
python setup.py bdist_wheel
h := $(shell git rev-parse --abbrev-ref HEAD)
.PHONY: release_check
release:
if [ "$h" = "main" ];\
then\
echo "Please ensure everything is merged into main & tagged there";\
pip install twine;\
twine upload dist/*;\
else\
echo "Please change to main branch for release.";\
fi
v := $(shell pip -V | grep virtualenvs)
.PHONY: all-checks
all-checks: clean formatters code-checks generators common-checks-1 common-checks-2 security
.PHONY: new_env
new_env: clean
if [ -z "$v" ];\
then\
pipenv --rm;\
pipenv --clear;\
pipenv --python 3.10;\
pipenv install --dev --skip-lock;\
pipenv run pip install -e .[all];\
pipenv run pip install --no-deps file:plugins/aea-ledger-ethereum;\
pipenv run pip install --no-deps file:plugins/aea-ledger-ethereum-flashbots;\
pipenv run pip install --no-deps file:plugins/aea-ledger-cosmos;\
pipenv run pip install --no-deps file:plugins/aea-ledger-fetchai;\
pipenv run pip install --no-deps file:plugins/aea-ledger-solana;\
pipenv run pip install --no-deps file:plugins/aea-cli-ipfs;\
echo "Enter virtual environment with all development dependencies now: 'pipenv shell'.";\
pipenv run pip install --no-deps file:plugins/aea-ledger-solana;\
else\
echo "In a virtual environment! Exit first: 'exit'.";\
fi
protolint_install:
GO111MODULE=on GOPATH=~/go go install -v github.com/yoheimuta/protolint/cmd/[email protected]
protolint:
PATH=${PATH}:${GOPATH}/bin/:~/go/bin protolint lint -config_path=./protolint.yaml -fix ./aea/mail ./packages/fetchai/protocols ./packages/valory/protocols
protolint_install_win:
powershell -command '$$env:GO111MODULE="on"; go install -v github.com/yoheimuta/protolint/cmd/[email protected]'
protolint_win:
protolint lint -config_path=./protolint.yaml -fix ./aea/mail ./packages/fetchai/protocols ./packages/valory/protocols
# isort: fix import orders
# black: format files according to the pep standards
.PHONY: formatters
formatters:
tox -e isort
tox -e black
# black-check: check code style
# isort-check: check for import order
# flake8: wrapper around various code checks, https://flake8.pycqa.org/en/latest/user/error-codes.html
# mypy: static type checker
# pylint: code analysis for code smells and refactoring suggestions
# vulture: finds dead code
# darglint: docstring linter
.PHONY: code-checks
code-checks:
tox -p -e black-check -e isort-check -e flake8 -e mypy -e pylint -e vulture -e darglint
# safety: checks dependencies for known security vulnerabilities
# bandit: security linter
.PHONY: security
security:
tox -p -e safety -e bandit
gitleaks detect --report-format json --report-path leak_report
# generate latest hashes for updated packages
# generate docs for updated packages
# update copyright headers
.PHONY: generators
generators: clean-cache
rm -rf packages/fetchai/connections/stub/input_file
tox -e fix-copyright
tox -e lock-packages
tox -e generate-all-protocols
tox -e generate-api-documentation
tox -e fix-doc-hashes
.PHONY: common-checks-1
common-checks-1:
tox -p -e check-copyright -e hash-check -e package-dependencies-checks
.PHONY: common-checks-2
common-checks-2:
tox -e check-api-docs
tox -e check-doc-links-hashes
.PHONY: build-proto
build-proto:
@# Usage: INCLUDE=PATH_TO_PROTOC_INCLUDE_DIRECTORY make build-proto
@echo "Building aea/mail/base.proto"
@protoc --proto_path=aea/mail/ --python_out=aea/mail/ aea/mail/base.proto -I $$INCLUDE
@echo "Building aea/ipfs/pb/merkledag.proto"
@protoc --proto_path=aea/helpers/ipfs/pb/ --python_out=aea/helpers/ipfs/pb/ aea/helpers/ipfs/pb/merkledag.proto -I $$INCLUDE
@echo "Building aea/ipfs/pb/unixfs.proto"
@protoc --proto_path=aea/helpers/ipfs/pb/ --python_out=aea/helpers/ipfs/pb/ aea/helpers/ipfs/pb/unixfs.proto -I $$INCLUDE
@echo "Building aea/helpers/search/models.proto"
@protoc --proto_path=aea/helpers/search/ --python_out=aea/helpers/search/ aea/helpers/search/models.proto -I $$INCLUDE
@echo "Building aea/helpers/multiaddr/crypto.proto"
@protoc --proto_path=aea/helpers/multiaddr/ --python_out=aea/helpers/multiaddr/ aea/helpers/multiaddr/crypto.proto -I $$INCLUDE