forked from valory-xyz/open-autonomy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
253 lines (218 loc) · 8.17 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
OPEN_AEA_REPO_PATH := "${OPEN_AEA_REPO_PATH}"
DEPLOYMENT_TYPE := "${DEPLOYMENT_TYPE}"
SERVICE_ID := "${SERVICE_ID}"
PLATFORM_STR := $(shell uname)
.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:
find . -type d -name .hypothesis -prune -exec rm -rf {} \;
rm -fr .pytest_cache
rm -fr .mypy_cache/
# 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 abci docstrings
# check copyright
# generate latest hashes for updated packages
# generate docs for updated packages
# fix hashes in docs
.PHONY: generators
generators: clean-cache
tox -e abci-docstrings
tox -e fix-copyright
tox -e lock-packages
tox -e generate-api-documentation
tox -e fix-doc-hashes
.PHONY: common-checks-1
common-checks-1:
tox -p -e check-copyright -e check-hash -e check-packages
.PHONY: common-checks-2
common-checks-2:
tox -e check-api-docs
tox -e check-abci-docstrings
tox -e check-abciapp-specs
tox -e check-handlers
tox -e check-dialogues
tox -e check-doc-links-hashes
.PHONY: docs
docs:
mkdocs build --clean --strict
.PHONY: test
test:
pytest -rfE --doctest-modules autonomy tests/ --cov=autonomy --cov-report=html --cov=packages/valory --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;
.PHONY: all-checks
all-checks: clean security generators common-checks-1 common-checks-2
.PHONY: test-skill
test-skill:
make test-sub-p tdir=skills/test_$(skill)/ dir=skills.$(skill)
# how to use:
#
# make test-sub-p tdir=$TDIR dir=$DIR
#
# where:
# - TDIR is the path to the test module/directory (but without the leading "test_")
# - DIR is the *dotted* path to the module/subpackage whose code coverage needs to be reported.
#
# For example, to run the ABCI connection tests (in tests/test_connections/test_abci.py)
# and check the code coverage of the package packages.valory.connections.abci:
#
# make test-sub-p tdir=connections/test_abci.py dir=connections.abci
#
# Or, to run tests in tests/test_skills/test_counter/ directory and check the code coverage
# of the skill packages.valory.skills.counter:
#
# make test-sub-p tdir=skills/test_counter/ dir=skills.counter
#
.PHONY: test-sub-p
test-sub-p:
pytest -rfE tests/test_$(tdir) --cov=packages.valory.$(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: eject-contracts
eject-contracts:
@for contract in component_registry agent_registry registries_manager service_manager service_registry gnosis_safe gnosis_safe_proxy_factory service_registry_token_utility multisend erc20 ; do \
echo Updating $$contract contract; \
rm -rf autonomy/data/contracts/$$contract ; \
cp -r packages/valory/contracts/$$contract autonomy/data/contracts/$$contract ; \
done
.PHONY: dist
dist: clean eject-contracts
python setup.py sdist
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: new_env
new_env: clean
if [ ! -z "$(which svn)" ];\
then\
echo "The development setup requires SVN, exit";\
exit 1;\
fi;\
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-test-autonomy;\
echo "Enter virtual environment with all development dependencies now: 'pipenv shell'.";\
else\
echo "In a virtual environment! Exit first: 'exit'.";\
fi
.PHONY: install-hooks
install-hooks:
@echo "Installing pre-push"
cp scripts/pre-push .git/hooks/pre-push
.PHONY: run-hardhat
run-hardhat:
docker run -p 8545:8545 -it valory/open-autonomy-hardhat:0.1.0
protolint_install:
mkdir protolint_install
cd protolint_install && \
wget https://github.com/yoheimuta/protolint/releases/download/v0.27.0/protolint_0.27.0_Linux_x86_64.tar.gz && \
tar -xvf protolint_0.27.0_Linux_x86_64.tar.gz && \
sudo mv protolint /usr/local/bin/protolint
sudo rm -rf protolint_install
protolint_install_darwin:
mkdir protolint_install
cd protolint_install && \
wget https://github.com/yoheimuta/protolint/releases/download/v0.27.0/protolint_0.27.0_Darwin_x86_64.tar.gz && \
tar -xvf protolint_0.27.0_Darwin_x86_64.tar.gz && \
sudo mv protolint /usr/local/bin/protolint
sudo rm -rf protolint_install
# TODO: use precompiled binary
protolint_install_win:
powershell -command '$$env:GO111MODULE="on"; go install github.com/yoheimuta/protolint/cmd/[email protected]'
teardown-docker-compose:
cd abci_build/ && \
docker-compose kill && \
docker-compose down && \
echo "Deployment torndown!" && \
exit 0
echo "Failed to teardown deployment!"
exit 1
teardown-kubernetes:
if [ "${VERSION}" = "" ];\
then\
echo "Ensure you have exported a version to teardown!";\
exit 1
fi
kubectl delete ns ${VERSION}
echo "Done!"
.PHONY: fix-abci-app-specs
fix-abci-app-specs:
autonomy analyse fsm-specs --update --app-class AgentRegistrationAbciApp --package packages/valory/skills/registration_abci || (echo "Failed to check registration_abci consistency" && exit 1)
autonomy analyse fsm-specs --update --app-class ResetPauseAbciApp --package packages/valory/skills/reset_pause_abci || (echo "Failed to check reset_pause_abci consistency" && exit 1)
autonomy analyse fsm-specs --update --app-class RegisterResetAbciApp --package packages/valory/skills/register_reset_abci || (echo "Failed to check register_reset_abci consistency" && exit 1)
autonomy analyse fsm-specs --update --app-class TransactionSubmissionAbciApp --package packages/valory/skills/transaction_settlement_abci || (echo "Failed to check transaction_settlement_abci consistency" && exit 1)
autonomy analyse fsm-specs --update --app-class OffendAbciApp --package packages/valory/skills/offend_abci || (echo "Failed to check offend_abci consistency" && exit 1)
echo "Successfully validated abcis!"
release-images:
skaffold build -p release --cache-artifacts=false && skaffold build -p release-latest
# Usage: INCLUDE=PATH_TO_PROTOC_INCLUDE_DIRECTORY make build-proto
.PHONY: build-proto
build-proto:
@protoc -I $$INCLUDE \
--proto_path=packages/valory/connections/abci/protos/ \
--python_out=packages/valory/connections/abci/ \
packages/valory/connections/abci/protos/gogoproto/gogo.proto \
packages/valory/connections/abci/protos/tendermint/crypto/proof.proto \
packages/valory/connections/abci/protos/tendermint/crypto/keys.proto \
packages/valory/connections/abci/protos/tendermint/abci/types.proto \
packages/valory/connections/abci/protos/tendermint/types/types.proto \
packages/valory/connections/abci/protos/tendermint/types/validator.proto \
packages/valory/connections/abci/protos/tendermint/types/params.proto \
packages/valory/connections/abci/protos/tendermint/version/types.proto