-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
140 lines (120 loc) · 3.14 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
139
140
.SILENT:
include .manala/Makefile
NAMESPACE = manala
COLLECTION = roles
VERSION = $(shell yq '.version' galaxy.yml)
###########
# Version #
###########
## Version - Get collection version
version: SHELL := $(MANALA_DOCKER_SHELL)
version:
printf $(VERSION)
.PHONY: version
########
# Lint #
########
## Lint - Lint collection [VERBOSE]
lint: SHELL := $(MANALA_DOCKER_SHELL)
lint:
ansible-lint \
$(if $(VERBOSE), -v) \
--force-color
.PHONY: lint
########
# Test #
########
## Test - Run all collection tests (but doc and coverage)
test: test.sanity test.units test.integration
.PHONY: test
## Test - Run collection sanity tests [VERBOSE]
test.sanity: SHELL := $(MANALA_DOCKER_SHELL)
test.sanity:
ansible-test sanity \
--requirements \
--venv \
--python 3.11 \
$(if $(VERBOSE), --verbose) \
--color yes \
--exclude .github/ \
--exclude .manala/
.PHONY: test.sanity
## Test - Run collection units tests [VERBOSE|COVERAGE]
test.units: SHELL := $(MANALA_DOCKER_SHELL)
test.units:
ansible-test units \
--requirements \
--venv \
--python 3.11 \
$(if $(VERBOSE), --verbose) \
$(if $(COVERAGE), --coverage) \
--color yes
.PHONY: test.units
## Test - Run collection integration tests [VERBOSE|COVERAGE]
test.integration: SHELL := $(MANALA_DOCKER_SHELL)
test.integration:
ansible-test integration \
--requirements \
--venv \
--python 3.11 \
$(if $(VERBOSE), --verbose) \
$(if $(COVERAGE), --coverage) \
--color yes
.PHONY: test.integration
## Test - Run collection documentation tests [VERBOSE]
test.doc: SHELL := $(MANALA_DOCKER_SHELL)
test.doc:
$(foreach type,module filter, \
$(foreach plugin,$(shell ansible-doc --list $(NAMESPACE).$(COLLECTION) --type $(type) --json | jq --raw-output 'keys[]'), \
ansible-doc \
$(if $(VERBOSE), --verbose) \
--type $(type) \
$(plugin) > /dev/null && \
) \
) true
.PHONY: test.doc
## Test - Run collection coverage [VERBOSE]
test.coverage: SHELL := $(MANALA_DOCKER_SHELL)
test.coverage:
ansible-test coverage xml \
--requirements \
--venv \
--python 3.11 \
--group-by command \
--group-by version \
$(if $(VERBOSE), --verbose) \
--color yes
.PHONY: test.coverage
############
# Molecule #
############
## Molecule - Run molecule test [SCENARIO]
molecule.test: SHELL := $(MANALA_DOCKER_SHELL)
molecule.test:
PY_COLORS=1 molecule test \
$(if $(SCENARIO), --scenario-name $(SCENARIO), --all)
.PHONY: molecule.test
## Molecule - Rune molecule converge [SCENARIO]
molecule.converge: SHELL := $(MANALA_DOCKER_SHELL)
molecule.converge:
$(call manala_error_if_not, $(SCENARIO), SCENARIO has not been specified)
PY_COLORS=1 molecule converge \
--scenario-name $(SCENARIO)
.PHONY: molecule.converge
###################
# Build / Publish #
###################
## Build - Build collection [VERBOSE]
build: SHELL := $(MANALA_DOCKER_SHELL)
build:
ansible-galaxy collection build \
--output-path build \
--force \
$(if $(VERBOSE), --verbose)
.PHONY: build
## Publish - Publish collection [VERBOSE]
publish: SHELL := $(MANALA_DOCKER_SHELL)
publish:
ansible-galaxy collection publish build/$(NAMESPACE)-$(COLLECTION)-$(VERSION).tar.gz \
$(if $(VERBOSE), --verbose)
.PHONY: publish