blob: 8f8523a5ddeed986d1b00da4cdade93798707cee [file] [log] [blame]
Filip Pytlound5d7cc42016-05-16 10:56:18 +02001DESTDIR=/
2SALTENVDIR=/usr/share/salt-formulas/env
3RECLASSDIR=/usr/share/salt-formulas/reclass
4FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-]*')
5
Filip Pytloun3893a6b2016-07-11 15:49:40 +02006MAKE_PID := $(shell echo $$PPID)
7JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)")))
8
9ifneq ($(subst -j,,$(JOB_FLAG)),)
10JOBS := $(subst -j,,$(JOB_FLAG))
11else
12JOBS := 1
13endif
14
15KITCHEN_LOCAL_YAML?=.kitchen.yml
16KITCHEN_OPTS?="--concurrency=$(JOBS)"
17KITCHEN_OPTS_CREATE?=""
18KITCHEN_OPTS_CONVERGE?=""
19KITCHEN_OPTS_VERIFY?=""
20KITCHEN_OPTS_TEST?=""
21
Filip Pytlound5d7cc42016-05-16 10:56:18 +020022all:
23 @echo "make install - Install into DESTDIR"
24 @echo "make test - Run tests"
Filip Pytloun3893a6b2016-07-11 15:49:40 +020025 @echo "make kitchen - Run Kitchen CI tests (create, converge, verify)"
Filip Pytlound5d7cc42016-05-16 10:56:18 +020026 @echo "make clean - Cleanup after tests run"
27
28install:
29 # Formula
30 [ -d $(DESTDIR)/$(SALTENVDIR) ] || mkdir -p $(DESTDIR)/$(SALTENVDIR)
31 cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/
32 [ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/
33 [ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true
34 # Metadata
35 [ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
36 cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
37
38test:
39 [ ! -d tests ] || (cd tests; ./run_tests.sh)
40
Filip Pytloun3893a6b2016-07-11 15:49:40 +020041kitchen: kitchen-create kitchen-converge kitchen-verify kitchen-list
42
43kitchen-create:
44 kitchen create ${KITCHEN_OPTS} ${KITCHEN_OPTS_CREATE}
45 [ "$(shell echo $(KITCHEN_LOCAL_YAML)|grep -Eo docker)" = "docker" ] || sleep 120
46
47kitchen-converge:
48 kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE}
49
50kitchen-verify:
51 [ ! -d tests/integration ] || kitchen verify -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
52 [ -d tests/integration ] || kitchen verify ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
53
54kitchen-test:
55 [ ! -d tests/integration ] || kitchen test -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
56 [ -d tests/integration ] || kitchen test ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
57
58kitchen-list:
59 kitchen list
60
Filip Pytlound5d7cc42016-05-16 10:56:18 +020061clean:
Filip Pytloun3893a6b2016-07-11 15:49:40 +020062 [ ! -x "$(shell which kitchen)" ] || kitchen destroy
63 [ ! -d .kitchen ] || rm -rf .kitchen
Filip Pytlound5d7cc42016-05-16 10:56:18 +020064 [ ! -d tests/build ] || rm -rf tests/build
65 [ ! -d build ] || rm -rf build