-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
109 lines (84 loc) · 2.52 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
.PHONY: all
# the python version must be inline with:
# * poetry, travis, docker
PYTHON_VERSION=3.8.5
PYTHON_MINOR_VERSION=3.8
# docker
REGISTRY_HOST=docker.io
USERNAME=$(USER)
NAME=$(shell basename $(PWD))
IMAGE=$(shell tr '[:upper:]' '[:lower:]' <<< $(NAME))
#
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
VERSION=$(shell poetry version|cut -d" " -f2)
SHELL=/bin/bash
all: test build
test: format lint unittest test-coverage
req:
ifeq ($(shell which pyenv), "pyenv not found")
@echo "Installing pyenv"
curl https://pyenv.run | bash
endif
ifneq ($(shell python --version|cut -d" " -f2), ${PYTHON_VERSION})
ifeq ("v$(shell pyenv versions|grep ${PYTHON_VERSION}|sed 's/^[[:space:]]*//g')", "v${PYTHON_VERSION}")
@echo "Local python version must be ${PYTHON_VERSION}"
pyenv local ${PYTHON_VERSION}
else
@echo "Python ${PYTHON_VERSION} not in local pyenv versions. Installing python ${PYTHON_VERSION}"
pyenv install ${PYTHON_VERSION}
pyenv local ${PYTHON_VERSION}
pip install poetry virtualenv
endif
endif
venv: req
poetry install
install:
poetry run python setup.py install
format: venv
poetry run autopep8 --in-place --aggressive --aggressive --aggressive --recursive goap/
lint: format
poetry run flake8 goap/
install-in-venv: venv install
poetry run python setup.py install
unittest: install-in-venv
@echo "Running unit tests"
poetry run pytest -v -s tests/
test-coverage: venv
poetry run coverage run --source=goap/ setup.py test
build:
poetry build
docker-build:
docker build -t goapy:$(shell poetry version|cut -d" " -f2) .
.PHONY: version
version:
@poetry version|cut -d" " -f2
patch:
poetry version patch
poetry version|cut -d" " -f2 > .release
minor:
poetry version minor
poetry version|cut -d" " -f2 > .release
major:
poetry version major
poetry version|cut -d" " -f2 > .release
release-patch: paatch tag
release-minor: minor tag
release-major: major tag
tag: TAG=$(shell cat .release)
tag: check-status
REL=$(shell cat .release)
HASTAG=$(shell git tag -l |grep ^"v${REL}\$")
@test "$(BRACH)" = "mater" || (echo "ERROR: Please merge your changes to master first" >&2 && exit 1)
@test -n "$tag" && test -z "$(HASTAG)" || (echo "ERROR: Tag already exists" >&2 && exit 1)
git tag v$(TAG)
@[ -n "$(shell git remote -v)" ] && git push --tags
check-status:
test -n "$(git status -s .)" || (echo "ERROR: there are still outstanding changes" >&2 && exit 1) ;
clean-venv:
rm -rf .venv/
clean-build:
rm -rf build/ *.egg-info/
clean-dist:
rm -rf dist/
clean-all: clean-venv clean-build clean-dist
clean: clean-all