forked from Pylons/pyramid_openapi3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (70 loc) · 2.32 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
# Convenience makefile to build the dev env and run common commands
# Based on https://github.com/niteoweb/Makefile
.EXPORT_ALL_VARIABLES:
PIPENV_VENV_IN_PROJECT = 1
PIPENV_IGNORE_VIRTUALENVS=1
.PHONY: all
all: .installed
.PHONY: install
install:
@rm -f .installed # force re-install
@make .installed
.installed: Pipfile Pipfile.lock
@echo "Pipfile(.lock) is newer than .installed, (re)installing"
@pipenv install --dev
@pipenv run pre-commit install -f --hook-type pre-commit
@pipenv run pre-commit install -f --hook-type pre-push
@echo "This file is used by 'make' for keeping track of last install time. If Pipfile or Pipfile.lock are newer then this file (.installed) then all 'make *' commands that depend on '.installed' know they need to run pipenv install first." \
> .installed
# Testing and linting targets
all = false
# Testing and linting targets
.PHONY: lint
lint: .installed
# 1. get all unstaged modified files
# 2. get all staged modified files
# 3. get all untracked files
# 4. run pre-commit checks on them
ifeq ($(all),true)
@pipenv run pre-commit run --hook-stage push --all-files
else
@{ git diff --name-only ./; git diff --name-only --staged ./;git ls-files --other --exclude-standard; } \
| sort -u | uniq | xargs pipenv run pre-commit run --hook-stage push --files
endif
.PHONY: type
type: types
.PHONY: types
types: .installed
@pipenv run mypy examples/todoapp
@cat ./typecov/linecount.txt
@pipenv run typecov 100 ./typecov/linecount.txt
@pipenv run mypy pyramid_openapi3
@cat ./typecov/linecount.txt
@pipenv run typecov 100 ./typecov/linecount.txt
# anything, in regex-speak
filter = "."
# additional arguments for pytest
unit_test_all = "false"
ifeq ($(filter),".")
unit_test_all = "true"
endif
args = ""
pytest_args = -k $(filter) $(args)
coverage_args = ""
ifeq ($(unit_test_all),"true")
coverage_args = --cov=pyramid_openapi3 --cov-branch --cov-report html --cov-report xml:cov.xml --cov-report term-missing --cov-fail-under=100
endif
.PHONY: unit
unit: .installed
@pipenv run pytest pyramid_openapi3 $(coverage_args) $(pytest_args)
.PHONY: test
test: tests
.PHONY: tests
tests: lint types unit
.PHONY: clean
clean:
@if [ -d ".venv/" ]; then pipenv --rm; fi
@rm -rf .coverage htmlcov/ pyramid_openapi3.egg-info xunit.xml \
htmltypecov typecov \
.git/hooks/pre-commit .git/hooks/pre-push
@rm -f .installed