-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathMakefile
118 lines (92 loc) · 3.17 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
NOSE := nosetests --failed --verbose --no-byte-compile --logging-level=DEBUG --detailed-errors --stop
COVERAGE := $(NOSE) --with-coverage --cover-package=terrascript --cover-erase --cover-branches --cover-html
FLAKE8 := python3 -m flake8
TESTS_BASIC := $(wildcard tests/test_basic_*.py)
TESTS_ISSUES := $(wildcard tests/test_issue*.py)
TESTS_EXAMPLES := $(wildcard tests/test_example_*.py)
TESTS_MAKECODE := $(wildcard tests/test_makecode_*.py)
TESTS_PROVIDERS := $(wildcard tests/test_provider_*.py)
export TF_IN_AUTOMATION=1
DEFAULT_GOAL: help
.PHONY: \
black \
clean \
code \
coverage \
debug_basic \
debug_issues \
docs \
flake8 \
help \
install \
package \
providers \
test \
test_basic \
test_black \
test_docs \
test_examples \
test_issues
black: clean ## Format Python code with Black to keep style consistent
black -t py36 .
clean: ## Cleanup temporary / cached files
rm -f tests/*.pyc
rm -f terrascript/*.pyc
rm -f terrascript/*/*.pyc
rm -f .coverage
rm -f .noseid*
rm -rf build/*
#code: clean ## Generate providers shim classes / code
# ( cd tools && ./makecode.py 2>&1 | tee makecode.out )
# # Workarounds
# cp -vf terrascript/provider/azurerm.py terrascript/provider/azure.py
# cp -vf terrascript/resource/azurerm.py terrascript/resource/azure.py
# cp -vf terrascript/data/azurerm.py terrascript/data/azure.py
coverage: clean ## Generate code test coverage
$(COVERAGE) $(TESTS_BASIC) $(TEST_ISSUES)
debug_basic: clean ## Run basic tests in debug mode
$(NOSE) --pdb $(TESTS_BASIC)
debug_issues: clean ## Run tests in debug mode for previous issues
$(NOSE) --pdb $(TESTS_ISSUES)
debug_providers: clean ## Run tests for providers in debug mode
$(NOSE) --pdb $(TESTS_PROVIDERS)
docs: clean ## Build documentation files
make -C docs html
flake8: clean ## Validate code against PEP8
$(FLAKE8) \
terrascript/__init__.py # tests/
help: ## Print this help and exit
@echo "Available build targets:"
@grep -e "^[a-zA-Z0-9_-]*: *.*## *" $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-25s\033[0m %s\n", $$1, $$2}'
install: clean ## Install as python package from sources
python3 setup.py install
package: clean ## Build python package from sources
python3 setup.py clean
python3 setup.py sdist
providers: ## Build bindings for providers
tools/makecode.py
$(MAKE) black
# Workarounds
# cp -vf terrascript/provider/azurerm.py terrascript/provider/azure.py
# cp -vf terrascript/resource/azurerm.py terrascript/resource/azure.py
# cp -vf terrascript/data/azurerm.py terrascript/data/azure.py
test: clean test_makecode test_basic test_issues test_docs test_providers ## Run all tests
test_basic: clean ## Run basic tests
$(NOSE) $(TESTS_BASIC)
test_black: clean ## Verify that all Python code are formatted correctly
black \
--check \
--diff \
--target-version py36 \
.
test_docs: ## Run tests for documentation
(cd docs && make test)
test_examples: clean ## Run tests for examples
$(NOSE) $(TESTS_EXAMPLES)
test_issues: clean ## Run tests for previous issues
$(NOSE) $(TESTS_ISSUES)
test_makecode: clean ## Run tests for makecode
$(NOSE) $(TESTS_MAKECODE)
test_providers: clean ## Run tests for providers
$(NOSE) $(TESTS_PROVIDERS)