You've already forked prometheus-fail2ban-exporter
							
							fix(Makefile): adapt Makefile and golangci lint
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Golang Tests / unittest (stable, ubuntu-latest-amd64) (push) Failing after 5s
				
			
		
			
				
	
				Markdown linter / markdown-lint (push) Failing after 2s
				
			
		
			
				
	
				Golang Tests / unittest (stable, ubuntu-latest-arm64) (push) Failing after 15s
				
			
		
			
				
	
				Golang CI lint / golangci (stable, ubuntu-latest-amd64) (push) Successful in 2m1s
				
			
		
			
				
	
				Golang CI lint / golangci (stable, ubuntu-latest-arm64) (push) Successful in 2m51s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Golang Tests / unittest (stable, ubuntu-latest-amd64) (push) Failing after 5s
				
			Markdown linter / markdown-lint (push) Failing after 2s
				
			Golang Tests / unittest (stable, ubuntu-latest-arm64) (push) Failing after 15s
				
			Golang CI lint / golangci (stable, ubuntu-latest-amd64) (push) Successful in 2m1s
				
			Golang CI lint / golangci (stable, ubuntu-latest-arm64) (push) Successful in 2m51s
				
			This commit is contained in:
		
							
								
								
									
										165
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										165
									
								
								Makefile
									
									
									
									
									
								
							| @@ -1,85 +1,114 @@ | ||||
| EXECUTABLE=prometheus-fail2ban-exporter | ||||
| VERSION?=$(shell git describe --abbrev=0)+hash.$(shell git rev-parse --short HEAD) | ||||
|  | ||||
| # Destination directory and prefix to place the compiled binaries, documentaions | ||||
| # and other files. | ||||
| DESTDIR?= | ||||
| PREFIX?=/usr/local | ||||
| EXECUTABLE?=prometheus-fail2ban-exporter | ||||
|  | ||||
| # CONTAINER_RUNTIME | ||||
| # The CONTAINER_RUNTIME variable will be used to specified the path to a | ||||
| # container runtime. This is needed to start and run a container image. | ||||
| CONTAINER_RUNTIME?=$(shell which podman) | ||||
|  | ||||
| # List make commands | ||||
| .PHONY: ls | ||||
| ls: | ||||
| 	cat Makefile | grep "^[a-zA-Z#].*" | cut -d ":" -f 1 | sed s';#;\n#;'g | ||||
| # PROM_FAIL2BAN_EXP_IMAGE_REGISTRY_NAME | ||||
| # Defines the name of the new container to be built using several variables. | ||||
| PROM_FAIL2BAN_EXP_IMAGE_REGISTRY_NAME:=git.cryptic.systems | ||||
| PROM_FAIL2BAN_EXP_IMAGE_REGISTRY_USER:=volker.raschek | ||||
|  | ||||
| # Run project tests | ||||
| .PHONY: test | ||||
| test: | ||||
| 	GONOSUMDB=${GONOSUMDB} \ | ||||
| 	GOPROXY=${GOPROXY} \ | ||||
| 		go test ./... -v -race | ||||
| PROM_FAIL2BAN_EXP_IMAGE_NAMESPACE?=${PROM_FAIL2BAN_EXP_IMAGE_REGISTRY_USER} | ||||
| PROM_FAIL2BAN_EXP_IMAGE_NAME:=${EXECUTABLE} | ||||
| PROM_FAIL2BAN_EXP_IMAGE_VERSION?=latest | ||||
| PROM_FAIL2BAN_EXP_IMAGE_FULLY_QUALIFIED=${PROM_FAIL2BAN_EXP_IMAGE_REGISTRY_NAME}/${PROM_FAIL2BAN_EXP_IMAGE_NAMESPACE}/${PROM_FAIL2BAN_EXP_IMAGE_NAME}:${PROM_FAIL2BAN_EXP_IMAGE_VERSION} | ||||
|  | ||||
| # Look for "suspicious constructs" in source code | ||||
| .PHONY: vet | ||||
| vet: | ||||
| 	GONOSUMDB=${GONOSUMDB} \ | ||||
| 	GOPROXY=${GOPROXY} \ | ||||
| 		go vet ./... | ||||
| # BIN | ||||
| # ============================================================================== | ||||
| prometheus-fail2ban-exporter: | ||||
| 	CGO_ENABLED=0 \ | ||||
| 	GOPROXY=$(shell go env GOPROXY) \ | ||||
| 		go build -ldflags "-X 'main.version=${VERSION}' -X 'main.date=$(shell date --rfc-3339=seconds )'" -o ${@} main.go | ||||
|  | ||||
| # Format code | ||||
| .PHONY: fmt | ||||
| fmt: | ||||
| 	GONOSUMDB=${GONOSUMDB} \ | ||||
| 	GOPROXY=${GOPROXY} \ | ||||
| 		go mod tidy | ||||
| # CLEAN | ||||
| # ============================================================================== | ||||
| PHONY+=clean | ||||
| clean: | ||||
| 	rm --force --recursive prometheus-fail2ban-exporter | ||||
|  | ||||
| 	GONOSUMDB=${GONOSUMDB} \ | ||||
| 	GOPROXY=${GOPROXY} \ | ||||
| 		go fmt ./... | ||||
| # TESTS | ||||
| # ============================================================================== | ||||
| PHONY+=test/unit | ||||
| test/unit: | ||||
| 	CGO_ENABLED=0 \ | ||||
| 	GOPROXY=$(shell go env GOPROXY) \ | ||||
| 		go test -v -p 1 -coverprofile=coverage.txt -covermode=count -timeout 1200s ./pkg/... | ||||
|  | ||||
| # Check for unformatted go code | ||||
| .PHONY: check/fmt | ||||
| check/fmt: | ||||
| 	test -z $(shell gofmt -l .) | ||||
| PHONY+=test/integration | ||||
| test/integration: | ||||
| 	CGO_ENABLED=0 \ | ||||
| 	GOPROXY=$(shell go env GOPROXY) \ | ||||
| 		go test -v -p 1 -count=1 -timeout 1200s ./it/... | ||||
|  | ||||
| # Build project | ||||
| .PHONY: build | ||||
| build: | ||||
| 	CGO_ENABLED=0 | ||||
| 	GONOSUMDB=${GONOSUMDB} \ | ||||
| 	GOPROXY=${GOPROXY} \ | ||||
| 		go build \ | ||||
| 			-ldflags "\ | ||||
| 				-X main.version=${shell git describe --tags} \ | ||||
| 				-X main.commit=${shell git rev-parse HEAD} \ | ||||
| 				-X main.date=${shell date --iso-8601=seconds} \ | ||||
| 				-X main.builtBy=manual \ | ||||
| 			" \ | ||||
| 			-trimpath \ | ||||
| 			-o ${EXECUTABLE} \ | ||||
| 			exporter.go | ||||
| PHONY+=test/coverage | ||||
| test/coverage: test/unit | ||||
| 	CGO_ENABLED=0 \ | ||||
| 	GOPROXY=$(shell go env GOPROXY) \ | ||||
| 		go tool cover -html=coverage.txt | ||||
|  | ||||
| # build container-image | ||||
| .PHONY: build/container-image | ||||
| build/container-image: | ||||
| # GOLANGCI-LINT | ||||
| # ============================================================================== | ||||
| PHONY+=golangci-lint | ||||
| golangci-lint: | ||||
| 	golangci-lint run --concurrency=$(shell nproc) | ||||
|  | ||||
| # INSTALL | ||||
| # ============================================================================== | ||||
| PHONY+=uninstall | ||||
| install: prometheus-fail2ban-exporter | ||||
| 	install --directory ${DESTDIR}/etc/bash_completion.d | ||||
| 	./prometheus-fail2ban-exporter completion bash > ${DESTDIR}/etc/bash_completion.d/${EXECUTABLE} | ||||
|  | ||||
| 	install --directory ${DESTDIR}${PREFIX}/bin | ||||
| 	install --mode 0755 ${EXECUTABLE} ${DESTDIR}${PREFIX}/bin/${EXECUTABLE} | ||||
|  | ||||
| 	install --directory ${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE} | ||||
| 	install --mode 0644 LICENSE ${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE}/LICENSE | ||||
|  | ||||
| # UNINSTALL | ||||
| # ============================================================================== | ||||
| PHONY+=uninstall | ||||
| uninstall: | ||||
| 	-rm --force --recursive \ | ||||
| 		${DESTDIR}/etc/bash_completion.d/${EXECUTABLE} \ | ||||
| 		${DESTDIR}${PREFIX}/bin/${EXECUTABLE} \ | ||||
| 		${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE} | ||||
|  | ||||
| # BUILD CONTAINER IMAGE | ||||
| # ============================================================================== | ||||
| PHONY+=container-image/build | ||||
| container-image/build: | ||||
| 	${CONTAINER_RUNTIME} build \ | ||||
| 		--tag ${EXECUTABLE} \ | ||||
| 		--build-arg VERSION=${VERSION} \ | ||||
| 		--file Dockerfile \ | ||||
| 		--no-cache \ | ||||
| 		--pull \ | ||||
| 		--tag ${PROM_FAIL2BAN_EXP_IMAGE_FULLY_QUALIFIED} \ | ||||
| 		. | ||||
|  | ||||
| .PHONY: install | ||||
| install: build | ||||
| 	mkdir --parents ${DESTDIR}/usr/lib/systemd/system | ||||
| 	sed -e "s/EXECUTABLE/${EXECUTABLE}/gm" systemd/systemd.service > ${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service | ||||
| 	chmod 0644 ${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service | ||||
| # DELETE CONTAINER IMAGE | ||||
| # ============================================================================== | ||||
| PHONY:=container-image/delete | ||||
| container-image/delete: | ||||
| 	- ${CONTAINER_RUNTIME} image rm ${PROM_FAIL2BAN_EXP_IMAGE_FULLY_QUALIFIED} | ||||
|  | ||||
| 	install -D --mode 0755 --target-directory ${DESTDIR}${PREFIX}/bin ${EXECUTABLE} | ||||
| # PUSH CONTAINER IMAGE | ||||
| # ============================================================================== | ||||
| PHONY+=container-image/push | ||||
| container-image/push: | ||||
| 	echo ${PROM_FAIL2BAN_EXP_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${PROM_FAIL2BAN_EXP_IMAGE_REGISTRY_NAME} --username ${PROM_FAIL2BAN_EXP_IMAGE_REGISTRY_USER} --password-stdin | ||||
| 	${CONTAINER_RUNTIME} push ${PROM_FAIL2BAN_EXP_IMAGE_FULLY_QUALIFIED} | ||||
|  | ||||
| # NOTE: Set restrict file permissions by default to protect optional basic auth credentials | ||||
| 	install -D --mode 0600 env ${DESTDIR}/etc/conf.d/${EXECUTABLE} | ||||
|  | ||||
| 	install -D --mode 0755 --target-directory ${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE} LICENSE | ||||
|  | ||||
| .PHONY: uninstall | ||||
| uninstall: | ||||
| 	-rm --recursive --force \ | ||||
| 		${DESTDIR}${PREFIX}/bin/${EXECUTABLE} \ | ||||
| 		${DESTDIR}/usr/lib/systemd/system/${EXECUTABLE}.service \ | ||||
| 		${DESTDIR}/etc/conf.d/${EXECUTABLE} \ | ||||
| 		${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE}/LICENSE | ||||
| # PHONY | ||||
| # ============================================================================== | ||||
| # Declare the contents of the PHONY variable as phony.  We keep that information | ||||
| # in a variable so we can use it in if_changed. | ||||
| .PHONY: ${PHONY} | ||||
		Reference in New Issue
	
	Block a user