2017-09-20 23:40:33 +00:00
|
|
|
MAKEFLAGS += --warn-undefined-variables
|
|
|
|
SHELL := /bin/bash
|
|
|
|
.SHELLFLAGS := -o pipefail -euc
|
|
|
|
.DEFAULT_GOAL := install
|
|
|
|
|
|
|
|
include Makefile.variables
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@echo 'Management commands for cicdtest:'
|
|
|
|
@echo
|
|
|
|
@echo 'Usage:'
|
|
|
|
@echo ' ## Develop / Test Commands'
|
2017-12-19 00:59:27 +00:00
|
|
|
@echo ' make build Build yq binary.'
|
|
|
|
@echo ' make install Install yq.'
|
|
|
|
@echo ' make xcompile Build cross-compiled binaries of yq.'
|
2018-02-16 16:14:57 +00:00
|
|
|
@echo ' make snap Build a snap package of yq.'
|
2017-09-20 23:40:33 +00:00
|
|
|
@echo ' make vendor Install dependencies using govendor.'
|
|
|
|
@echo ' make format Run code formatter.'
|
|
|
|
@echo ' make check Run static code analysis (lint).'
|
|
|
|
@echo ' make test Run tests on project.'
|
|
|
|
@echo ' make cover Run tests and capture code coverage metrics on project.'
|
|
|
|
@echo ' make clean Clean the directory tree of produced artifacts.'
|
|
|
|
@echo
|
|
|
|
@echo ' ## Utility Commands'
|
|
|
|
@echo ' make setup Configures Minishfit/Docker directory mounts.'
|
|
|
|
@echo
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@rm -rf bin build cover *.out
|
|
|
|
|
|
|
|
## prefix before other make targets to run in your local dev environment
|
|
|
|
local: | quiet
|
|
|
|
@$(eval DOCKRUN= )
|
2017-09-23 19:33:23 +00:00
|
|
|
@mkdir -p tmp
|
|
|
|
@touch tmp/dev_image_id
|
2017-09-20 23:40:33 +00:00
|
|
|
quiet: # this is silly but shuts up 'Nothing to be done for `local`'
|
|
|
|
@:
|
|
|
|
|
|
|
|
prepare: tmp/dev_image_id
|
|
|
|
tmp/dev_image_id: Dockerfile.dev scripts/devtools.sh
|
2017-09-23 19:33:23 +00:00
|
|
|
@mkdir -p tmp
|
|
|
|
@docker rmi -f ${DEV_IMAGE} > /dev/null 2>&1 || true
|
|
|
|
@docker build -t ${DEV_IMAGE} -f Dockerfile.dev .
|
|
|
|
@docker inspect -f "{{ .ID }}" ${DEV_IMAGE} > tmp/dev_image_id
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------
|
|
|
|
# build
|
|
|
|
.PHONY: build
|
|
|
|
build: build/dev
|
|
|
|
|
|
|
|
.PHONY: build/dev
|
|
|
|
build/dev: test *.go
|
|
|
|
@mkdir -p bin/
|
2017-12-17 22:11:08 +00:00
|
|
|
${DOCKRUN} go build --ldflags "$(LDFLAGS)"
|
2017-09-20 23:40:33 +00:00
|
|
|
${DOCKRUN} bash ./scripts/acceptance.sh
|
|
|
|
|
|
|
|
## Compile the project for multiple OS and Architectures.
|
|
|
|
xcompile: check
|
|
|
|
@rm -rf build/
|
|
|
|
@mkdir -p build
|
|
|
|
${DOCKRUN} bash ./scripts/xcompile.sh
|
|
|
|
@find build -type d -exec chmod 755 {} \; || :
|
|
|
|
@find build -type f -exec chmod 755 {} \; || :
|
|
|
|
|
2018-02-16 16:14:57 +00:00
|
|
|
.PHONY: snap
|
|
|
|
snap:
|
|
|
|
snapcraft
|
|
|
|
|
2017-09-20 23:40:33 +00:00
|
|
|
.PHONY: install
|
|
|
|
install: build
|
|
|
|
${DOCKRUN} go install
|
|
|
|
|
|
|
|
# Each of the fetch should be an entry within vendor.json; not currently included within project
|
|
|
|
.PHONY: vendor
|
|
|
|
vendor: tmp/dev_image_id
|
2017-12-18 00:23:33 +00:00
|
|
|
${DOCKRUN} govendor sync
|
2017-09-23 13:36:17 +00:00
|
|
|
@chmod 664 vendor/vendor.json
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------
|
|
|
|
# develop and test
|
|
|
|
|
|
|
|
.PHONY: format
|
|
|
|
format: vendor
|
|
|
|
${DOCKRUN} bash ./scripts/format.sh
|
|
|
|
|
|
|
|
.PHONY: check
|
|
|
|
check: format
|
|
|
|
${DOCKRUN} bash ./scripts/check.sh
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test: check
|
|
|
|
${DOCKRUN} bash ./scripts/test.sh
|
|
|
|
|
|
|
|
.PHONY: cover
|
|
|
|
cover: check
|
|
|
|
@rm -rf cover/
|
|
|
|
@mkdir -p cover
|
|
|
|
${DOCKRUN} bash ./scripts/coverage.sh
|
|
|
|
@find cover -type d -exec chmod 755 {} \; || :
|
|
|
|
@find cover -type f -exec chmod 644 {} \; || :
|
|
|
|
|
2017-09-23 19:33:23 +00:00
|
|
|
.PHONY: build-docs
|
|
|
|
build-docs: prepare mkdocs.yml mkdocs/*
|
|
|
|
${DOCKRUN} mkdocs build
|
|
|
|
@find docs -type d -exec chmod 755 {} \; || :
|
|
|
|
@find docs -type f -exec chmod 644 {} \; || :
|
|
|
|
|
2017-09-25 01:10:57 +00:00
|
|
|
.PHONY: release
|
|
|
|
release: xcompile
|
|
|
|
${DOCKRUN} bash ./scripts/publish.sh
|
|
|
|
|
2017-09-20 23:40:33 +00:00
|
|
|
# ----------------------------------------------
|
|
|
|
# utilities
|
|
|
|
|
|
|
|
.PHONY: setup
|
|
|
|
setup:
|
|
|
|
@bash ./scripts/setup.sh
|