Filip Pytloun | 40eb047 | 2016-04-14 14:11:51 +0200 | [diff] [blame] | 1 | DESTDIR=/ |
| 2 | SALTENVDIR=/usr/share/salt-formulas/env |
| 3 | RECLASSDIR=/usr/share/salt-formulas/reclass |
Petr Michalec | 973066e | 2016-08-29 21:39:31 +0200 | [diff] [blame] | 4 | FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-\_]*') |
| 5 | |
| 6 | MAKE_PID := $(shell echo $$PPID) |
| 7 | JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)"))) |
| 8 | |
| 9 | ifneq ($(subst -j,,$(JOB_FLAG)),) |
| 10 | JOBS := $(subst -j,,$(JOB_FLAG)) |
| 11 | else |
| 12 | JOBS := 1 |
| 13 | endif |
| 14 | |
| 15 | KITCHEN_LOCAL_YAML?=.kitchen.yml |
| 16 | KITCHEN_OPTS?="--concurrency=$(JOBS)" |
| 17 | KITCHEN_OPTS_CREATE?="" |
| 18 | KITCHEN_OPTS_CONVERGE?="" |
| 19 | KITCHEN_OPTS_VERIFY?="" |
| 20 | KITCHEN_OPTS_TEST?="" |
Filip Pytloun | 40eb047 | 2016-04-14 14:11:51 +0200 | [diff] [blame] | 21 | |
| 22 | all: |
| 23 | @echo "make install - Install into DESTDIR" |
| 24 | @echo "make test - Run tests" |
Petr Michalec | 973066e | 2016-08-29 21:39:31 +0200 | [diff] [blame] | 25 | @echo "make kitchen - Run Kitchen CI tests (create, converge, verify)" |
Filip Pytloun | 40eb047 | 2016-04-14 14:11:51 +0200 | [diff] [blame] | 26 | @echo "make clean - Cleanup after tests run" |
| 27 | |
| 28 | install: |
| 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 | |
| 38 | test: |
| 39 | [ ! -d tests ] || (cd tests; ./run_tests.sh) |
| 40 | |
Petr Michalec | 973066e | 2016-08-29 21:39:31 +0200 | [diff] [blame] | 41 | kitchen: kitchen-create kitchen-converge kitchen-verify kitchen-list |
| 42 | |
| 43 | kitchen-create: |
| 44 | kitchen create ${KITCHEN_OPTS} ${KITCHEN_OPTS_CREATE} |
| 45 | [ "$(shell echo $(KITCHEN_LOCAL_YAML)|grep -Eo docker)" = "docker" ] || sleep 120 |
| 46 | |
| 47 | kitchen-converge: |
| 48 | kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE} &&\ |
| 49 | kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE} |
| 50 | |
| 51 | kitchen-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 | |
| 55 | kitchen-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 | |
| 59 | kitchen-list: |
| 60 | kitchen list |
| 61 | |
Filip Pytloun | 40eb047 | 2016-04-14 14:11:51 +0200 | [diff] [blame] | 62 | clean: |
Petr Michalec | 973066e | 2016-08-29 21:39:31 +0200 | [diff] [blame] | 63 | [ ! -x "$(shell which kitchen)" ] || kitchen destroy |
| 64 | [ ! -d .kitchen ] || rm -rf .kitchen |
Filip Pytloun | 40eb047 | 2016-04-14 14:11:51 +0200 | [diff] [blame] | 65 | [ ! -d tests/build ] || rm -rf tests/build |
| 66 | [ ! -d build ] || rm -rf build |