2017-09-20 23:40:33 +00:00
|
|
|
MAKEFLAGS += --warn-undefined-variables
|
|
|
|
SHELL := /bin/bash
|
|
|
|
.SHELLFLAGS := -o pipefail -euc
|
|
|
|
.DEFAULT_GOAL := install
|
2021-12-01 23:01:44 +00:00
|
|
|
ENGINE := $(shell { command -v podman || command -v docker; } 2>/dev/null)
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
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.'
|
2019-10-29 21:19:17 +00:00
|
|
|
@echo ' make vendor Install dependencies to vendor directory.'
|
2017-09-20 23:40:33 +00:00
|
|
|
@echo ' make format Run code formatter.'
|
|
|
|
@echo ' make check Run static code analysis (lint).'
|
2021-03-03 08:44:23 +00:00
|
|
|
@echo ' make secure Run gosec.'
|
2017-09-20 23:40:33 +00:00
|
|
|
@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
|
2021-12-01 23:01:44 +00:00
|
|
|
@$(eval ENGINERUN= )
|
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
|
2021-12-01 23:01:44 +00:00
|
|
|
@${ENGINE} rmi -f ${DEV_IMAGE} > /dev/null 2>&1 || true
|
|
|
|
@${ENGINE} build -t ${DEV_IMAGE} -f Dockerfile.dev .
|
|
|
|
@${ENGINE} inspect -f "{{ .ID }}" ${DEV_IMAGE} > tmp/dev_image_id
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------
|
|
|
|
# build
|
|
|
|
.PHONY: build
|
2021-03-19 02:20:19 +00:00
|
|
|
build: build/dev
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
.PHONY: build/dev
|
|
|
|
build/dev: test *.go
|
|
|
|
@mkdir -p bin/
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} go build --ldflags "$(LDFLAGS)"
|
|
|
|
${ENGINERUN} bash ./scripts/acceptance.sh
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
## Compile the project for multiple OS and Architectures.
|
|
|
|
xcompile: check
|
|
|
|
@rm -rf build/
|
|
|
|
@mkdir -p build
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} bash ./scripts/xcompile.sh
|
2017-09-20 23:40:33 +00:00
|
|
|
@find build -type d -exec chmod 755 {} \; || :
|
|
|
|
@find build -type f -exec chmod 755 {} \; || :
|
|
|
|
|
|
|
|
.PHONY: install
|
|
|
|
install: build
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} go install
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
# Each of the fetch should be an entry within vendor.json; not currently included within project
|
|
|
|
.PHONY: vendor
|
|
|
|
vendor: tmp/dev_image_id
|
2021-12-01 23:01:44 +00:00
|
|
|
@mkdir -p vendor
|
|
|
|
${ENGINERUN} go mod vendor
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------
|
|
|
|
# develop and test
|
|
|
|
|
|
|
|
.PHONY: format
|
|
|
|
format: vendor
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} bash ./scripts/format.sh
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
|
2023-09-18 23:52:36 +00:00
|
|
|
.PHONY: spelling
|
|
|
|
spelling: format
|
|
|
|
${ENGINERUN} bash ./scripts/spelling.sh
|
|
|
|
|
2021-03-03 08:44:23 +00:00
|
|
|
.PHONY: secure
|
2023-09-18 23:52:36 +00:00
|
|
|
secure: spelling
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} bash ./scripts/secure.sh
|
2021-03-03 08:44:23 +00:00
|
|
|
|
2021-11-10 02:09:58 +00:00
|
|
|
.PHONY: check
|
|
|
|
check: secure
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} bash ./scripts/check.sh
|
2021-11-10 02:09:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-20 23:40:33 +00:00
|
|
|
.PHONY: test
|
|
|
|
test: check
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} bash ./scripts/test.sh
|
2017-09-20 23:40:33 +00:00
|
|
|
|
|
|
|
.PHONY: cover
|
|
|
|
cover: check
|
|
|
|
@rm -rf cover/
|
|
|
|
@mkdir -p cover
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} bash ./scripts/coverage.sh
|
2017-09-20 23:40:33 +00:00
|
|
|
@find cover -type d -exec chmod 755 {} \; || :
|
|
|
|
@find cover -type f -exec chmod 644 {} \; || :
|
|
|
|
|
2017-09-23 19:33:23 +00:00
|
|
|
|
2017-09-25 01:10:57 +00:00
|
|
|
.PHONY: release
|
|
|
|
release: xcompile
|
2021-12-01 23:01:44 +00:00
|
|
|
${ENGINERUN} bash ./scripts/publish.sh
|
2017-09-25 01:10:57 +00:00
|
|
|
|
2017-09-20 23:40:33 +00:00
|
|
|
# ----------------------------------------------
|
|
|
|
# utilities
|
|
|
|
|
|
|
|
.PHONY: setup
|
|
|
|
setup:
|
|
|
|
@bash ./scripts/setup.sh
|