-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
68 lines (52 loc) · 1.87 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
# basic:
PROJECT_NAME=StockScraper
PWD:=$(shell pwd)
PYTHONPATH=$(PWD)
TEST_DIR=tests
VENV=venv/bin
PIP=$(VENV)/pip3
PIP_FLAGS=--trusted-host=http://pypi.python.org/simple/
PYTEST=$(VENV)/py.test
PYLINT=$(VENV)/pylint
COVERAGE=$(VENV)/coverage
MYPY=$(VENV)/mypy
MYPYFLAGS=--ignore-missing-imports --follow-imports=skip
PYTHON_VERSION=python3.5
HOST_PYTHON_VER=$(shell echo which $(PYTHON_VERSION))
VENV_PYTHOM_VER=$(VENV)/python3
CODE_COV=codecov
# git settings:
GIT_COMMIT = $(shell git log -1 "--pretty=format:%H")
GIT_STATUS = $(shell git status -sb --untracked=no | wc -l | awk '{ if($$1 == 1){ print "clean" } else { print "pending" } }')
GIT_BRANCH = $(shell git describe --contains --all HEAD)
.PHONY: all venv clean test test_pytest test_gen_coverage_rep test_pylint test_mypy git-status commit-id
all: venv test clean
venv: venv/bin/activate
venv/bin/activate: requirements.txt
test -d venv || virtualenv -p $(PYTHON_VERSION) venv
$(PIP) $(PIP_FLAGS) install -Ur requirements.txt
touch venv/bin/activate
test_pytest:
$(PYTEST) --verbose --color=yes --cov=$(PROJECT_NAME) --cov-report html --cov-config .coveragerc --tb=short $(TEST_DIR)
test_pylint:
find $(PROJECT_NAME) -name '*.py' | xargs $(PYLINT) --rcfile=$(PWD)/.pylintrc
test_gen_coverage_rep:
$(COVERAGE) report
test_mypy:
find $(PROJECT_NAME) -name '*.py' | xargs $(MYPY) $(MYPYFLAGS)
test_codecov:
$(CODE_COV) --token=$(SCRAPERTOKEN)
test: test_pytest test_pylint test_mypy test_gen_coverage_rep
clean:
rm -rf htmlcov
rm -rf .coverage
rm -rf .cache
rm -rf .mypy_cache
find -name '$(PROJECT_NAME).log' | xargs rm -rf
find $(PROJECT_NAME) -name '*.pyc' | xargs rm -rf
find $(PROJECT_NAME) -name '__pycache__' -type d | xargs rm -rf
find $(TEST_DIR) -name '__pycache__' -type d | xargs rm -rf
git-status:
test "${GIT_STATUS}" == "clean" || (echo "GIT STATUS NOT CLEAN"; exit 1) >&2
commit-id:
test ${GIT_COMMIT}