-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
138 lines (112 loc) · 3.88 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
SHELL := bash -o pipefail
TODAY := $(shell date '+%Y-%m-%d')
.DEFAULT_GOAL := all
AWS_PROFILE := default
PYTEST_OPTS := ''
# Prepare for python version checks
PYTHON_MIN_VERSION := 3.8
PYTHON_CUR_VERSION := $(shell python3 -V 2>/dev/null)
PYTHON_GOOD := $(shell echo $(PYTHON_CUR_VERSION) | grep --silent $(PYTHON_MIN_VERSION) && echo true || echo false )
PYTHON_VER_WARNING = $(warning Warning! Frost supports Python $(PYTHON_MIN_VERSION), \
you're running $(shell python3 -V))
PYTHON_VER_ERROR = $(error Frost supports Python $(PYTHON_MIN_VERSION), \
you're running $(shell python3 -V))
AUTOBUILD_OPTS ?= --open-browser --port=0 --delay 5
all: check_venv
frost test
awsci: check_venv
frost test --continue-on-collection-errors -m aws aws/**/*.py \
-k "not test_ec2_security_group_in_use" \
--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 ifneq ($(PYTHON_GOOD),true)
$(PYTHON_VER_WARNING)
else
@echo "Using $(PYTHON_CUR_VERSION)"
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
frost test --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: check_venv
type sphinx-build || { echo "please run `make install-docs` to build docs"; false; }
@# we regen the api docs every time -- they are not checked in.
rm -rf docs/source
sphinx-apidoc --no-toc -o docs/source .
@# TODO: Add new service modules below also in docs/Source.rst
for module in frost aws gcp gsuite; do \
sphinx-apidoc -f -o docs/source/$$module $$module ; \
done
make -C docs clean html
doc-preview: check_venv
@#sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
sphinx-autobuild $(AUTOBUILD_OPTS) "docs/" "docs/_build/html/" $(SPHINXOPTS) $(O)
# We need the list of all python file in several places, so only compute
# it once.
# TODO: move this to a Makefile variable
.all_python_files.tmp:
find . -type d \( -name venv -o -name .??\* \) -prune \
-o -not -name setup.py -name \*.py -print \
> $@
doctest: check_venv .all_python_files.tmp
frost test -vv --doctest-modules -s --offline --debug-calls $$(cat .all_python_files.tmp)
coverage: check_venv .all_python_files.tmp
frost test --cov-config .coveragerc --cov=. \
--aws-profiles example-account \
-o python_files=meta_test*.py \
-o cache_dir=./example_cache/ \
--offline \
$$(cat .all_python_files.tmp)
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 && python setup.py develop && pre-commit install )
install-docs: venv
( . venv/bin/activate && pip install -r docs/requirements.txt )
setup_gsuite: check_venv
python -m bin.auth.setup_gsuite
metatest:
frost test --aws-profiles example-account \
-o python_files=meta_test*.py \
-o cache_dir=./example_cache/
venv:
python3 -m venv venv
build-image:
docker build -t localhost/frost:latest .
.PHONY: \
.all_python_files.tmp \
all \
awsci \
black \
build-image \
check_conftest_imports \
check_venv \
clean \
clean-cache \
clean-python \
coverage \
doc-build \
doc-preview \
doctest \
flake8 \
install \
install-docs \
metatest \
setup_gsuite \
venv