forked from manala/ansible-roles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (75 loc) · 1.78 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
.SILENT:
ANSIBLE_COLLECTION=roles
ANSIBLE_NAMESPACE=manala
ANSIBLE_IMAGE=quay.io/ansible/toolset:3.5.0
-include \
./.env
##########
# Docker #
##########
define docker_run
docker run \
--rm \
--tty \
--interactive \
--hostname ansible \
--mount 'type=bind,source=$(CURDIR),target=/srv/ansible_collections/$(ANSIBLE_NAMESPACE)/$(ANSIBLE_COLLECTION)' \
--mount 'type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock' \
--workdir /srv/ansible_collections/$(ANSIBLE_NAMESPACE)/$(ANSIBLE_COLLECTION) \
$(ANSIBLE_IMAGE) \
$(strip $(1))
endef
define docker_collection
docker run \
--rm \
--env COLLECTION_API_TOKEN \
--volume $(PWD):/srv/ \
--workdir /srv/ \
$(ANSIBLE_IMAGE) \
$(1)
endef
######
# Sh #
######
sh:
$(call docker_run)
.PHONY: sh
########
# Lint #
########
lint:
$(call docker_run, ansible-lint)
.PHONY: lint
########
# Test #
########
test: test.sanity test.units
.PHONY: test
test.sanity:
$(call docker_run, ansible-test sanity --python 3.8 --requirements --verbose --color)
.PHONY: test.sanity
test.units:
$(call docker_run, ansible-test units --python 3.8 --requirements --verbose --color)
.PHONY: test.units
############
# Molecule #
############
molecule:
$(call docker_run, molecule test --all)
$(call docker_run, molecule test \
$(if $(ROLE),--scenario-name $(ROLE),--all))
.PHONY: molecule
##############
# Collection #
##############
MANALA_COLLECTION = $(ANSIBLE_NAMESPACE)-$(ANSIBLE_COLLECTION)-*.tar.gz
define collection
$(call docker_collection, ansible-galaxy collection $(1))
endef
collection.build:
rm -rf $(MANALA_COLLECTION)
$(call collection,build --force --verbose)
.PHONY: collection.build
collection.publish:
$(call collection,publish $(MANALA_COLLECTION) --api-key $(COLLECTION_API_TOKEN))
.PHONY: collection.publish