-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (72 loc) · 2.44 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
.PHONY: review
.PHONY: lint lint-style lint-mypy lint-release
.PHONY: format
.PHONY: test docker-test docker-build-test
.PHONY: docs
add_cwd_to_path = PATH=$(shell pwd):$${PATH} PYTHONPATH=$(shell pwd):$${PYTHONPATH}
# --------------Review-------------- #
review : lint test
# --------------Lint-------------- #
LINT = $(shell pwd)
lint : lint-style lint-mypy
lint-style :
@echo 'Checking codestyle...'
@flake8 $(LINT) \
&& python tools/lint_trailing_comma.py $(shell find $(LINT) -type f -name "*.py")
@echo 'No issues'
lint-mypy :
@echo 'Running static type checker...'
@mypy $(LINT)
@echo 'No issues'
git_branch = $(shell git rev-parse --abbrev-ref HEAD)
git_version = $(shell git describe --tags --abbrev=0)
marsh_version = $(shell python tools/find_version.py marsh/__init__.py)
lint-release :
@echo 'Checking branch...'
@if [ "$(git_branch)" != "main" ]; \
then \
echo 'Error: not on main branch'; \
exit 1; \
fi;
@echo 'Checking version...'
@if [ "$(git_version)" != "v$(marsh_version)" ]; \
then \
printf 'Error: git tag "$(git_version)" mismatch with marsh version "v$(marsh_version)"\n'; \
exit 1; \
fi;
@echo 'No issues'
# --------------Format-------------- #
FORMAT = $(shell pwd)
format :
@add-trailing-comma \
--py36-plus \
--exit-zero-even-if-changed \
$(shell find $(FORMAT) -type f -name "*.py")
# --------------Testing-------------- #
TEST = test
test :
@$(add_cwd_to_path) pytest $(TEST)
DOCKER_PYTHON_VERSION := 3.8
DOCKER_TEST_FILE := test/Dockerfile
DOCKER_TEST_NAME := marsh/test/py${DOCKER_PYTHON_VERSION}
DOCKER_TEST_TAG := $$(git rev-parse HEAD)
DOCKER_TEST_IMG := ${DOCKER_TEST_NAME}:${DOCKER_TEST_TAG}
DOCKER_TEST_LATEST := ${DOCKER_TEST_NAME}:latest
docker-build-test :
@docker build \
--build-arg PYTHON_VERSION=$(DOCKER_PYTHON_VERSION) \
-t ${DOCKER_TEST_IMG} \
-f ${DOCKER_TEST_FILE} \
.
@docker tag ${DOCKER_TEST_IMG} ${DOCKER_TEST_LATEST}
docker-test :
@if [ "$$(docker images -q $(DOCKER_TEST_LATEST) 2> /dev/null)" == "" ]; \
then \
$(MAKE) docker-build-test DOCKER_PYTHON_VERSION=$(DOCKER_PYTHON_VERSION); \
fi;
@docker run --rm -e TEST=$(TEST) -v $(shell pwd):/marsh $(DOCKER_TEST_LATEST) /bin/bash -c 'test/main.sh'
# --------------Docs-------------- #
docs :
-@rm -r docs/build &> /dev/null || exit 0
@$(add_cwd_to_path) python docs/source/scripts/build_supported_types.py
@$(add_cwd_to_path) sphinx-build docs/source -W docs/build/html