forked from hyperledger/fabric-sdk-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (75 loc) · 2.22 KB
/
Makefile
File metadata and controls
91 lines (75 loc) · 2.22 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
# SPDX-License-Identifier: Apache-2.0
# Triggered by the ci
# To run some specific case, run like `tox -e py30 -- test/integration/create_channel_test.py`
PATH := fabric-bin/bin:$(PATH)
SHELL := env PATH=$(PATH) /bin/bash
check: clean
scripts/check-env.sh
echo "=== Testing started... ==="
make test
# Tox related variables
TOX = tox
TOX_VENV_NAMES = pylint flake8 py36
# [tox.pylint, tox.flake8, tox.py30, tox.py36]
TOX_VENVS = $(patsubst %, $(TOX).%, $(TOX_VENV_NAMES))
# Run all unit test cases
test: venv
source venv/bin/activate ; make $(TOX_VENVS)
$(TOX).%:
$(eval TOX_VENV_NAME = ${subst $(TOX).,,${@}})
$(call run-py-tox,$(TOX_VENV_NAME))
# Tox running function
define run-py-tox
@echo ">>> Tox test: $(1) ..."
# set -o pipefail
@rm -rf .tox/$(1)/log
# bin_path=.tox/$(1)/bin
# export PYTHON=$bin_path/python
@tox -v -e$(1) test
# set +o pipefail
endef
# Check the format
flake8: linter
linter:
tox -e flake8
PREV_VERSION?=0.9.0
# changelog update
changelog:
scripts/changelog.sh v$(PREV_VERSION) HEAD
# Generate the hyperledger/fabric-sdk-py image
image:
docker build -t hyperledger/fabric-sdk-py .
# Generate the protobuf python files
proto:
shopt -s globstar
python3 -m grpc.tools.protoc \
-I./\
--python_out=./ \
--grpc_python_out=./ \
hfc/protos/**/*.proto
# Clean temporary files
clean:
rm -rf .cache *.egg-info .tox .coverage .coverage.* test/fixtures/ca/fabric-ca-server/fabric-ca-server.db test/fixtures/ca/fabric-ca-server/keystore/0e729224e8b3f31784c8a93c5b8ef6f4c1c91d9e6e577c45c33163609fe40011_sk
find . -name "*.pyc" -o -name "__pycache__" | xargs rm -rf
rm -rf ./venv
# Enter a virtual env
venv:
@echo "virtualenv can be installed by: pip3 install virtualenv"
rm -rf venv
virtualenv -p python3 venv
source venv/bin/activate;\
pip install tox;\
python --version;\
pip --version;\
tox --version;\
pip install -r requirements.txt;\
pip install -r requirements-test.txt
@echo "Active the virtual env: source venv/bin/activate"
@echo "Deactive when done: deactivate"
# Install sdk to local python env
install:
python3 setup.py install
# Auto-format to pep8
format:
python3 -m autopep8 --in-place --recursive --exclude=./hfc/protos .
.PHONY: check clean proto image install format test venv