|
| 1 | +MAKEFLAGS += --warn-undefined-variables |
| 2 | +SHELL := /bin/bash |
| 3 | +.SHELLFLAGS := -o pipefail -euc |
| 4 | +.DEFAULT_GOAL := build |
| 5 | + |
| 6 | +include Makefile.variables |
| 7 | + |
| 8 | +.PHONY: help |
| 9 | +help: |
| 10 | + @echo 'Management commands for cicdtest:' |
| 11 | + @echo |
| 12 | + @echo 'Usage:' |
| 13 | + @echo ' ## Build Commands' |
| 14 | + @echo ' make tag-build Add git tag for latest build.' |
| 15 | + @echo |
| 16 | + @echo ' ## Generator Commands' |
| 17 | + @echo ' make generate Run code generator for project.' |
| 18 | + @echo |
| 19 | + @echo ' ## Develop / Test Commands' |
| 20 | + @echo ' make vendor Install dependencies using glide.' |
| 21 | + @echo ' make format Run code formatter.' |
| 22 | + @echo ' make check Run static code analysis (lint).' |
| 23 | + @echo ' make test Run tests on project.' |
| 24 | + @echo ' make cover Run tests and capture code coverage metrics on project.' |
| 25 | + @echo ' make clean Clean the directory tree of produced artifacts.' |
| 26 | + @echo |
| 27 | + @echo ' ## Utility Commands' |
| 28 | + @echo ' make setup Configures Minishfit/Docker directory mounts.' |
| 29 | + @echo |
| 30 | + |
| 31 | + |
| 32 | +.PHONY: clean |
| 33 | +clean: |
| 34 | + @rm -rf bin cover *.out *.xml |
| 35 | + |
| 36 | +veryclean: clean |
| 37 | + rm -rf tmp |
| 38 | + ${DOCKER} rmi -f ${DEV_IMAGE} > /dev/null 2>&1 || true |
| 39 | + |
| 40 | +## prefix before other make targets to run in your local dev environment |
| 41 | +local: | quiet |
| 42 | + @$(eval DOCKRUN= ) |
| 43 | +quiet: # this is silly but shuts up 'Nothing to be done for `local`' |
| 44 | + @: |
| 45 | + |
| 46 | +prepare: tmp/dev_image_id |
| 47 | +tmp/dev_image_id: |
| 48 | + @mkdir -p tmp |
| 49 | + @${DOCKER} rmi -f ${DEV_IMAGE} > /dev/null 2>&1 || true |
| 50 | + ${DOCKER} build -t ${DEV_IMAGE} -f Dockerfile.dev . |
| 51 | + @${DOCKER} inspect -f "{{ .ID }}" ${DEV_IMAGE} > tmp/dev_image_id |
| 52 | + |
| 53 | +# ---------------------------------------------- |
| 54 | +# build |
| 55 | +.PHONY: build |
| 56 | +build: build/dev |
| 57 | + |
| 58 | +.PHONY: build/dev |
| 59 | +build/dev: check */*.go *.go |
| 60 | + @mkdir -p bin/ |
| 61 | + ${DOCKRUN} go build -o bin/swagger --ldflags "$(LDFLAGS)" ./cmd/swagger |
| 62 | + |
| 63 | +.PHONY: install |
| 64 | +install: build |
| 65 | + ${DOCKRUN} go install ./cmd/swagger |
| 66 | + |
| 67 | +.PHONY: vendor |
| 68 | +vendor: tmp/dev_image_id |
| 69 | + |
| 70 | +# ---------------------------------------------- |
| 71 | +# develop and test |
| 72 | + |
| 73 | +.PHONY: format |
| 74 | +format: vendor |
| 75 | + ${DOCKRUN} bash ./hack/format.sh |
| 76 | + |
| 77 | +.PHONY: check |
| 78 | +check: format |
| 79 | + ${DOCKRUN} bash ./hack/check.sh |
| 80 | + |
| 81 | +.PHONY: test |
| 82 | +test: check |
| 83 | + ${DOCKRUN} bash ./hack/test.sh |
| 84 | + |
| 85 | +.PHONY: cover |
| 86 | +cover: check |
| 87 | + @rm -rf cover/ |
| 88 | + @mkdir -p cover |
| 89 | + ${DOCKRUN} bash ./hack/cover.sh |
| 90 | + |
| 91 | +# does not work |
| 92 | +.PHONY: canary |
| 93 | +canary: build |
| 94 | + ${DOCKRUN} bash -c 'SWAGGER_BIN=$$(pwd)/bin/swagger ./hack/run-canary.sh' |
| 95 | + |
| 96 | +# generate bindata when templates are updated |
| 97 | +.PHONY: generate |
| 98 | +generate: build/image_build |
| 99 | + ${DOCKRUN} go generate ./generator |
| 100 | + |
| 101 | +# ---------------------------------------------- |
| 102 | +# utilities |
| 103 | + |
| 104 | +.PHONY: setup |
| 105 | +setup: |
| 106 | + @bash ./hack/setup.sh |
0 commit comments