-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
103 lines (79 loc) · 2.61 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
TODAY := $(shell date '+%Y-%m-%d')
.DEFAULT_GOAL := all
AWS_PROFILE := default
PYTEST_OPTS := ''
PYTHON_MIN_VERSION := 3.6
PYTHON_VER_WARNING = $(warning Warning! Frost supports Python $(PYTHON_MIN_VERSION), \
you're running $(shell python -V))
PYTHON_VER_ERROR = $(error Frost supports Python $(PYTHON_MIN_VERSION), \
you're running $(shell python -V))
all: check_venv
pytest
awsci: check_venv
pytest --continue-on-collection-errors aws/ \
--ignore aws/ec2/test_ec2_security_group_in_use.py \
--json=results-$(AWS_PROFILE)-$(TODAY).json $(PYTEST_OPTS)
check_venv:
ifeq ($(VIRTUAL_ENV),)
$(error "Run frost from a virtualenv (try 'make install && source venv/bin/activate')")
else
python -V | grep $(PYTHON_MIN_VERSION) || true ; $(PYTHON_VER_WARNING)
endif
check_conftest_imports:
# refs: https://github.com/mozilla/frost/issues/119
grep --recursive --exclude-dir '*venv' --include '*.py' '^import\s+conftest|^from\s+conftest\s+import\s+pytest' ./ ; [ $$? -eq 1 ]
clean: clean-cache clean-python
rm -rf venv
# remember to deactivate your active virtual env
clean-cache: check_venv
@# do as little work as possible to clear the cache, and guarantee success
pytest --cache-clear --continue-on-collection-errors \
--collect-only -m "no_such_marker" \
--noconftest --tb=no --disable-warnings --quiet \
|| true
clean-python:
find . -type d -name venv -prune -o -type d -name __pycache__ -print0 | xargs -0 rm -rf
doc-build:
type sphinx-build || { echo "please install sphinx to build docs"; false; }
make -C docs html
doctest: check_venv
pytest --doctest-modules -s --offline --debug-calls
coverage: check_venv
pytest --cov-config .coveragerc --cov=. \
--aws-profiles example-account \
-o python_files=meta_test*.py \
-o cache_dir=./example_cache/
coverage report -m
coverage html
flake8: check_venv
flake8 --max-line-length 120 $(shell git ls-files | grep \.py$$)
black: check_venv
pre-commit run black --all-files
install: venv
( . venv/bin/activate && pip install -U pip && pip install -r requirements.txt && pre-commit install )
setup_gsuite: check_venv
python -m bin.auth.setup_gsuite
stage-docs: docs
git add --all --force docs/_build/html
metatest:
pytest --aws-profiles example-account \
-o python_files=meta_test*.py \
-o cache_dir=./example_cache/
venv:
python3 -m venv venv
./venv/bin/python -V | grep $(PYTHON_MIN_VERSION) || true; $(PYTHON_VER_WARNING)
build-image:
docker build -t localhost/frost:latest .
.PHONY:
all \
build-image \
check_venv \
check_conftest_imports \
clean \
clean-cache \
clean-python \
doc-build \
flake8 \
install \
stage-docs \
venv