Makefile 1.22 KB
PACKAGE:=vendor/node_modules.tar.gz
DOCKER_IMAGE:=slashdeploy/kpis
NODE_VERSION:=$(shell cat Dockerfile | head -n 1 | cut -d ' ' -f 2)
IMAGE:=tmp/image
NODE_MODULES:=tmp/node_modules

.PHONY: check
check:
	docker --version > /dev/null
	zip --version > /dev/null
	unzip -v > /dev/null
	ansible --version > /dev/null

.PHONY: foo
$(PACKAGE): package.json
	mkdir -p $(@D)
	docker run --rm -it -v $(CURDIR):/data -w /data $(NODE_VERSION) \
		npm install
	tar -czf $@ node_modules
	rm -rf node_modules

$(NODE_MODULES): $(PACKAGE)
	tar xzf $<
	mkdir -p $(@D)
	touch $@

$(IMAGE): $(NODE_MODULES)
	docker build -t $(DOCKER_IMAGE) .
	mkdir -p $(@D)
	touch $@

.PHONY: test
test: $(IMAGE)
	docker run --rm -it -v $(CURDIR):/data -w /data $(DOCKER_IMAGE) \
		npm test

.PHONY: test-shellcheck
test-shellcheck:
	docker run --rm -v $(CURDIR):/data:ro -w /data jrotter/shellcheck \
		shellcheck -s bash \
		$(shell find script -type f -exec test -x {} \; -print | paste -s -d ' ' -)

.PHONY: test-application
test-application: $(IMAGE)
	docker run --rm $(DOCKER_IMAGE) npm run lint
	docker run --rm $(DOCKER_IMAGE) npm test

.PHONY: test-ci
test-ci: test-shellcheck test-application

.PHONY: clean
clean:
	rm -rf $(DOCKER_IMAGE) $(NODE_MODULES) node_modules