Skip to content

Instantly share code, notes, and snippets.

@ahawkins
Created May 12, 2016 18:48
Show Gist options
  • Select an option

  • Save ahawkins/30a3ab7f8843173b448139466a0c3494 to your computer and use it in GitHub Desktop.

Select an option

Save ahawkins/30a3ab7f8843173b448139466a0c3494 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment