fix: Makefile targets
This commit is contained in:
		| @@ -6,7 +6,7 @@ steps: | |||||||
| - name: build-linux-amd64 | - name: build-linux-amd64 | ||||||
|   image: docker.io/volkerraschek/build-image:latest |   image: docker.io/volkerraschek/build-image:latest | ||||||
|   commands: |   commands: | ||||||
|   - make --jobs=$(nproc) bin/linux/amd64/flucky |   - make | ||||||
|   when: |   when: | ||||||
|     event: |     event: | ||||||
|     - push |     - push | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,13 +1,6 @@ | |||||||
| # absolute files | # absolute files | ||||||
|  | bin | ||||||
| .env | .env | ||||||
| flucky |  | ||||||
| flucky.rpm |  | ||||||
| flucky.tar.bz2 |  | ||||||
| flucky.tar.gz |  | ||||||
| flucky.tar.xz |  | ||||||
|  |  | ||||||
| # relative files |  | ||||||
| **/bindata*.go |  | ||||||
|  |  | ||||||
| # directories | # directories | ||||||
| .vscode/ | .vscode/ | ||||||
|   | |||||||
							
								
								
									
										113
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										113
									
								
								Makefile
									
									
									
									
									
								
							| @@ -1,16 +1,9 @@ | |||||||
| # VERSION |  | ||||||
| # If no version is specified as a parameter of make, the last git hash |  | ||||||
| # value is taken. |  | ||||||
| VERSION?=$(shell git describe --abbrev=0)+$(shell date +'%Y%m%d%H%I%S') | VERSION?=$(shell git describe --abbrev=0)+$(shell date +'%Y%m%d%H%I%S') | ||||||
|  |  | ||||||
| # CONTAINER_RUNTIME | EXECUTABLE:=flucky | ||||||
| # The CONTAINER_RUNTIME variable will be used to specified the path to a |  | ||||||
| # container runtime. This is needed to start and run a container images. |  | ||||||
| CONTAINER_RUNTIME?=$(shell which docker) |  | ||||||
| CONTAINER_IMAGE_VERSION?=latest |  | ||||||
|  |  | ||||||
| # EXECUTABLE | DESTDIR?= | ||||||
| EXECUTABLE=flucky | PREFIX?=/usr/local | ||||||
|  |  | ||||||
| # BINARIES | # BINARIES | ||||||
| # ============================================================================== | # ============================================================================== | ||||||
| @@ -55,6 +48,28 @@ bin/tmp/${EXECUTABLE}: | |||||||
| 	GOPRIVATE=$(shell go env GOPRIVATE) \ | 	GOPRIVATE=$(shell go env GOPRIVATE) \ | ||||||
| 		go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@} | 		go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@} | ||||||
|  |  | ||||||
|  | # COMPLETIONS | ||||||
|  | # ============================================================================== | ||||||
|  | bin/tmp/${EXECUTABLE}.sh: bin/tmp/${EXECUTABLE} | ||||||
|  | 	bin/tmp/${EXECUTABLE} completion bash > ${@} | ||||||
|  |  | ||||||
|  | bin/tmp/${EXECUTABLE}.fish: bin/tmp/${EXECUTABLE} | ||||||
|  | 	bin/tmp/${EXECUTABLE} completion fish > ${@} | ||||||
|  |  | ||||||
|  | bin/tmp/${EXECUTABLE}.zsh: bin/tmp/${EXECUTABLE} | ||||||
|  | 	bin/tmp/${EXECUTABLE} completion zsh > ${@} | ||||||
|  |  | ||||||
|  | # INSTALL | ||||||
|  | # ============================================================================== | ||||||
|  | PHONY+=install | ||||||
|  | install: bin/tmp/${EXECUTABLE} bin/tmp/${EXECUTABLE}.sh bin/tmp/${EXECUTABLE}.fish bin/tmp/${EXECUTABLE}.zsh | ||||||
|  | 	install --directory ${DESTDIR}${PREFIX}/bin | ||||||
|  | 	install --mode 755 bin/tmp/${EXECUTABLE} ${DESTDIR}${PREFIX}/bin/${EXECUTABLE} | ||||||
|  | 	install --directory ${DESTDIR}/etc/bash_completion.d/ | ||||||
|  | 	install --mode 755 bin/tmp/${EXECUTABLE}.sh ${DESTDIR}/etc/bash_completion.d/${EXECUTABLE}.sh | ||||||
|  | 	install --directory ${DESTDIR}/usr/share/fish/vendor_functions.d/ | ||||||
|  | 	install --mode 755 bin/tmp/${EXECUTABLE}.fish ${DESTDIR}/usr/share/fish/vendor_functions.d/${EXECUTABLE}.fish | ||||||
|  |  | ||||||
| # CLEAN | # CLEAN | ||||||
| # ============================================================================== | # ============================================================================== | ||||||
| PHONY+=clean | PHONY+=clean | ||||||
| @@ -67,86 +82,10 @@ PHONY+=test/unit | |||||||
| test/unit: | test/unit: | ||||||
| 	go test -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 600s -count=1 ./pkg/... | 	go test -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 600s -count=1 ./pkg/... | ||||||
|  |  | ||||||
|  | PHONY+=test/coverage | ||||||
| test/coverage: test/unit | test/coverage: test/unit | ||||||
| 	go tool cover -html=coverage.txt | 	go tool cover -html=coverage.txt | ||||||
|  |  | ||||||
| # CONTAINER IMAGE STEPS |  | ||||||
| # ============================================================================== |  | ||||||
| PHONY+=container-image/build/amd64 |  | ||||||
| container-image/build/amd64: |  | ||||||
| 	${CONTAINER_RUNTIME} build \ |  | ||||||
| 		--build-arg BASE_IMAGE=docker.io/library/alpine:3.11.2 \ |  | ||||||
| 		--build-arg BUILD_IMAGE=docker.io/volkerraschek/build-image:latest \ |  | ||||||
| 		--build-arg EXECUTABLE=${EXECUTABLE} \ |  | ||||||
| 		--build-arg EXECUTABLE_TARGET=bin/linux/amd64/${EXECUTABLE} \ |  | ||||||
| 		--build-arg GOPROXY=$(shell go env GOPROXY) \ |  | ||||||
| 		--build-arg GOPRIVATE=$(shell go env GOPRIVATE) \ |  | ||||||
| 		--build-arg VERSION=${VERSION} \ |  | ||||||
| 		--file Dockerfile \ |  | ||||||
| 		--no-cache \ |  | ||||||
| 		--tag docker.io/volkerraschek/flucky:${CONTAINER_IMAGE_VERSION} \ |  | ||||||
| 		--tag volkerraschek/flucky:${CONTAINER_IMAGE_VERSION} \ |  | ||||||
| 		. |  | ||||||
|  |  | ||||||
| PHONY+=container-image/push/amd64 |  | ||||||
| container-image/push/amd64: container-image/build/amd64 |  | ||||||
| 	${CONTAINER_RUNTIME} login docker.io \ |  | ||||||
| 		--username ${CONTAINER_IMAGE_REGISTRY_USER} \ |  | ||||||
| 		--password ${CONTAINER_IMAGE_REGISTRY_PASSWORD} |  | ||||||
| 	${CONTAINER_RUNTIME} push docker.io/volkerraschek/flucky:${CONTAINER_IMAGE_VERSION} |  | ||||||
|  |  | ||||||
| # CONTAINER STEPS - BINARY |  | ||||||
| # ============================================================================== |  | ||||||
| # current os |  | ||||||
| PHONY+=container-run/${EXECUTABLE} |  | ||||||
| container-run/${EXECUTABLE}: |  | ||||||
| 	$(MAKE) container-run COMMAND=${@:container-run/%=%} |  | ||||||
|  |  | ||||||
| # build all binaries for any operating system |  | ||||||
| PHONY+=container-run/all |  | ||||||
| container-run/all: |  | ||||||
| 	$(MAKE) container-run COMMAND=${@:container-run/%=%} |  | ||||||
|  |  | ||||||
| PHONY+=${EXECUTABLE_TARGETS:%=container-run/%} |  | ||||||
| ${EXECUTABLE_TARGETS:%=container-run/%}: |  | ||||||
| 	$(MAKE) container-run COMMAND=${@:container-run/%=%} |  | ||||||
|  |  | ||||||
| # CONTAINER STEPS - CLEAN |  | ||||||
| # ============================================================================== |  | ||||||
| PHONY+=container-run/clean |  | ||||||
| container-run/clean: |  | ||||||
| 	$(MAKE) container-run COMMAND=${@:container-run/%=%} |  | ||||||
|  |  | ||||||
| # CONTAINER STEPS - TEST |  | ||||||
| # ============================================================================== |  | ||||||
| PHONY+=container-run/test/unit |  | ||||||
| container-run/test/unit: |  | ||||||
| 	$(MAKE) container-run COMMAND=${@:container-run/%=%} |  | ||||||
|  |  | ||||||
| # GENERAL CONTAINER COMMAND |  | ||||||
| # ============================================================================== |  | ||||||
| PHONY+=container-run |  | ||||||
| container-run: |  | ||||||
| 	${CONTAINER_RUNTIME} run \ |  | ||||||
| 		--env GOPROXY=$(shell go env GOPROXY) \ |  | ||||||
| 		--env GOPRIVATE=$(shell go env GOPRIVATE) \ |  | ||||||
| 		--rm \ |  | ||||||
| 		--volume ${PWD}:/workspace \ |  | ||||||
| 		--volume /var/run/docker.sock:/var/run/docker.sock \ |  | ||||||
| 		docker.io/volkerraschek/build-image:latest \ |  | ||||||
| 			make ${COMMAND} \ |  | ||||||
| 				VERSION=${VERSION:v%=%} |  | ||||||
|  |  | ||||||
| # REMOTE |  | ||||||
| # ============================================================================== |  | ||||||
| PHONY+=${FLUCKY_REMOTE:%=remote/%} |  | ||||||
| remote/${FLUCKY_REMOTE}: bin/linux/arm/7/${EXECUTABLE} |  | ||||||
| 	scp bin/linux/arm/7/${EXECUTABLE} root@${FLUCKY_REMOTE}:/usr/local/bin/${EXECUTABLE} |  | ||||||
| 	# ssh root@${FLUCKY_REMOTE} 'mkdir --parent /etc/bash_completion.d || true' |  | ||||||
| 	# ssh root@${FLUCKY_REMOTE} 'flucky completion bash > /etc/bash_completion.d/flucky.sh && chmod +x /etc/bash_completion.d/flucky.sh' |  | ||||||
| 	# ssh root@${FLUCKY_REMOTE} 'flucky completion zsh > /etc/bash_completion.d/flucky.zsh && chmod +x /etc/bash_completion.d/flucky.zsh' |  | ||||||
| 	ssh root@${FLUCKY_REMOTE} 'chmod +x /usr/local/bin/${EXECUTABLE}' |  | ||||||
|  |  | ||||||
| # PHONY | # PHONY | ||||||
| # ============================================================================== | # ============================================================================== | ||||||
| # Declare the contents of the PHONY variable as phony.  We keep that information | # Declare the contents of the PHONY variable as phony.  We keep that information | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user