blob: fa15e0f556140bff84273b0d0421273f88e3d4ae [file] [log] [blame]
Ales Komarekf9d35ae2016-08-19 10:23:00 +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
6MAKE_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
22all:
23 @echo "make install - Install into DESTDIR"
24 @echo "make test - Run tests"
25 @echo "make kitchen - Run Kitchen CI tests (create, converge, verify)"
26 @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
41kitchen: 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 kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE}
50
51kitchen-verify:
52 [ ! -d tests/integration ] || kitchen verify -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
53 [ -d tests/integration ] || kitchen verify ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
54
55kitchen-test:
56 [ ! -d tests/integration ] || kitchen test -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
57 [ -d tests/integration ] || kitchen test ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
58
59kitchen-list:
60 kitchen list
61
62clean:
63 [ ! -x "$(shell which kitchen)" ] || kitchen destroy
64 [ ! -d .kitchen ] || rm -rf .kitchen
65 [ ! -d tests/build ] || rm -rf tests/build
66 [ ! -d build ] || rm -rf build