generated from cloudposse/terraform-example-module
-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
69 lines (58 loc) · 2.07 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
TEST_HARNESS ?= https://github.com/cloudposse/test-harness.git
TEST_HARNESS_BRANCH ?= master
TEST_HARNESS_PATH = $(realpath .test-harness)
BATS_ARGS ?= --tap
BATS_LOG ?= test.log
# Define a macro to run the tests
define RUN_TESTS
@echo "Running tests in $(1)"
@cd $(1) && bats $(BATS_ARGS) $(addsuffix .bats,$(addprefix $(TEST_HARNESS_PATH)/test/terraform/,$(TESTS)))
endef
default: all
-include Makefile.*
## Provision the test-harnesss
.test-harness:
[ -d $@ ] || git clone --depth=1 -b $(TEST_HARNESS_BRANCH) $(TEST_HARNESS) $@
## Initialize the tests
init: .test-harness
## Install all dependencies (OS specific)
deps::
@exit 0
## Clean up the test harness
clean:
[ "$(TEST_HARNESS_PATH)" == "/" ] || rm -rf $(TEST_HARNESS_PATH)
## Run all tests
all: module pre-test examples/complete examples/advanced_features examples/alert_policy examples/api_integration examples/complete examples/config examples/escalation examples/integration_action examples/notification_policy examples/schedule examples/team examples/team_routing_rule examples/user
## Run basic sanity checks against the module itself
module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions
module: deps
$(call RUN_TESTS, ../)
pre-test:
export TESTS ?= installed lint get-modules get-plugins validate
## Run tests against example
examples/complete: deps
$(call RUN_TESTS, ../$@)
examples/advanced_features: deps
$(call RUN_TESTS, ../$@)
examples/alert_policy: deps
$(call RUN_TESTS, ../$@)
examples/api_integration: deps
$(call RUN_TESTS, ../$@)
examples/complete: deps
$(call RUN_TESTS, ../$@)
examples/config: deps
$(call RUN_TESTS, ../$@)
examples/escalation: deps
$(call RUN_TESTS, ../$@)
examples/integration_action: deps
$(call RUN_TESTS, ../$@)
examples/notification_policy: deps
$(call RUN_TESTS, ../$@)
examples/schedule: deps
$(call RUN_TESTS, ../$@)
examples/team: deps
$(call RUN_TESTS, ../$@)
examples/team_routing_rule: deps
$(call RUN_TESTS, ../$@)
examples/user: deps
$(call RUN_TESTS, ../$@)