-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
107 lines (89 loc) · 3.06 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
include .env
GREEN=\n\033[1;32;40m
RED=\n\033[1;31;40m
NC=\033[0m # No Color
PYCODESTYLE = pycodestyle
MYPY = mypy
# no-member: mypy
PYLINTFLAGS = --verbose --reports=no --output-format=colorized --errors-only --disable=no-member --enable=unused-import
PYTHONFILES := $(shell find . -name '*.py' | grep -v .venv)
PYTHON_VERSION = py38
PYTHON_LINE_LENGTH = 80
targets:
@echo $(PYTHONFILES)
.PHONY: targets
PIP := $(shell command -v pip 2> /dev/null)
PIPENV := $(shell command -v pipenv 2> /dev/null)
ref:
ifndef PIP
# https://pip.pypa.io/en/stable/installing/
$(error "pip이 설치되어 있지 않습니다.")
endif
@/bin/sh -c "echo \"${GREEN}pip 설치되어 있음${NC}\""
ifndef PIPENV
pip install pipenv
endif
@/bin/sh -c "echo \"${GREEN}pipenv 설치되어 있음${NC}\""
.PHONY: ref
# 의존성 모듈 관리
venv_dir=.venv
venv-dev:
ifneq "$(wildcard $(venv_dir) )" ""
@/bin/sh -c "echo \"${GREEN}Already installation${NC}\""
else
@/bin/sh -c "echo \"${GREEN}pipenv install${NC}\""
export PIPENV_VENV_IN_PROJECT=${PWD} && pipenv install --dev
pipenv graph
endif
.PHONY: venv-dev
pycodestyle: ref venv-dev
@/bin/sh -c "echo \"${GREEN}[pycodestyle 시작]${NC}\""
pipenv run $(PYCODESTYLE) --first $(PYTHONFILES)
.PHONY: pycodestyle
# vscode의 formatting 도구로 black을 사용
black: ref venv-dev
@/bin/sh -c "echo \"${GREEN}[black 시작]${NC}\""
pipenv run black -t $(PYTHON_VERSION) -l $(PYTHON_LINE_LENGTH) $(PYTHONFILES)
.PHONY: black
pylint: ref venv-dev
@/bin/sh -c "echo \"${GREEN}[pylint 시작]${NC}\""
pipenv run pylint $(PYLINTFLAGS) $(PYTHONFILES)
.PHONY: fast-pylint
mypy: ref venv-dev
@/bin/sh -c "echo \"${GREEN}[정적분석 시작]${NC}\""
pipenv run $(MYPY) --config-file mypy.ini $(PYTHONFILES)
.PHONY: mypy
lint: pycodestyle mypy pylint
.PHONY: lint
test: ref venv-dev
pipenv run pytest \
--pdb \
--cov=src tests \
--cov-report=html \
--cov-report=term \
--cov-report=xml \
--disable-warnings
.PHONY: test-coverage
VERSION:=$(shell npm run next-version | tail -1)
docker: requirements
@/bin/sh -c "echo \"${GREEN}[docker image 빌드를 시작합니다]${NC}\""
@set -ex \
&& docker build --rm -t ${APP_NAME}:${VERSION} . \
&& docker build --rm -t ${APP_NAME}:latest .
.PHONY: docker
requirements: ref venv-dev
@/bin/sh -c "echo \"${GREEN}[requirements.txt를 추출합니다]${NC}\""
@pipenv lock -r > requirements.txt
.PHONY: requirements
# yaml에서 colon 버그 존재 이외에도 특문 버그도 존재하므로 script로 처리
# https://gitlab.com/gitlab-org/gitlab-foss/-/issues/30097
__ci_commit:
@git add app/__init__.py
@git commit -m "chore(version): changed version ${AGENT_VERSION}"
.PHONY: __ci_commit
# 마지막 tag로부터 현재까지의 changelog 및 버전 확인 용
current_changelog:
@/bin/sh -c "echo \"${GREEN}[release version] $(shell yarn run standard-version --dry-run | grep tagging | cut -d ' ' -f4)${NC}\""
@/bin/sh -c "echo \"${GREEN}[description] ${NC}\""
@yarn run standard-version --dry-run --silent | grep -v yarn | grep -v Done | grep -v "\-\-\-" | grep -v standard-version
.PHONY: current_changelog