-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmakefile
69 lines (48 loc) · 1.73 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
.PHONY: all install clean build release protos test ptw
# grpc related
SRC = clearly
PROTOC = python -m grpc_tools.protoc
PROTOS = $(SRC)/protos
# coverage related
COV = --cov=$(SRC) --cov-branch --cov-report=term-missing
# docker related
DOCKER_REPO = rsalmei/clearly
VERSION_BUILD = $(shell python -c "from clearly import __version__; print(__version__)")
VERSION_MINOR = $(shell python -c "from clearly import __version__; print(__version__.rpartition('.')[0])")
VERSION_MAJOR = $(shell python -c "from clearly import __version__; print(__version__.rpartition('.')[0].partition('.')[0])")
IMAGE_BUILD = $(DOCKER_REPO):$(VERSION_BUILD)
IMAGE_MINOR = $(DOCKER_REPO):$(VERSION_MINOR)
IMAGE_MAJOR = $(DOCKER_REPO):$(VERSION_MAJOR)
IMAGE_LATEST = $(DOCKER_REPO):latest
all:
@grep -E "^\w+:" makefile | cut -d: -f1
install:
pip install -e .[test]
dev: install
pip install -r requirements/dev.txt
clean: clean-build clean-pyc
clean-build:
rm -rf build dist
clean-pyc:
find . -type f -name *.pyc -delete
build: build-python build-docker
build-python: clean
python setup.py sdist bdist_wheel
build-docker:
docker build -t $(IMAGE_BUILD) -t $(IMAGE_MINOR) -t $(IMAGE_MAJOR) -t $(IMAGE_LATEST) .
release: test release-python release-docker
release-python: build-python
twine upload dist/*
release-docker: build-docker
echo $(IMAGE_BUILD) $(IMAGE_MINOR) $(IMAGE_MAJOR) $(IMAGE_LATEST) | xargs -n 1 docker push
protos: clean-protos
$(PROTOC) --proto_path=$(SRC) --python_out=$(SRC) --grpc_python_out=$(SRC) $(PROTOS)/clearly.proto
sed -i '' 's/^from protos import/from . import/' $(PROTOS)/clearly_pb2_grpc.py
clean-protos:
rm -f $(PROTOS)/*_pb2.py $(PROTOS)/*_pb2_grpc.py
test:
pytest $(COV)
ptw:
ptw -- $(COV)
cov-report:
coverage report -m