2021-09-09 22:57:05 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-04-30 22:17:44 +02:00
|
|
|
.PHONY: all clean build swagger test lint run help
|
2020-01-12 18:23:35 +01:00
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
|
|
|
VERSION := $(shell git describe --always --tags)
|
|
|
|
BUILD_TIME=$(shell date '+%Y%m%d-%H%M%S')
|
|
|
|
DOCKER_IMAGE_NAME="spx01/blocky"
|
|
|
|
BINARY_NAME=blocky
|
|
|
|
BIN_OUT_DIR=bin
|
|
|
|
|
2021-09-09 22:57:05 +02:00
|
|
|
export PATH=$(shell go env GOPATH)/bin:$(shell echo $$PATH)
|
|
|
|
|
2021-11-10 21:44:52 +01:00
|
|
|
all: build test lint ## Build binary (with tests)
|
2020-01-12 18:23:35 +01:00
|
|
|
|
|
|
|
clean: ## cleans output directory
|
|
|
|
$(shell rm -rf $(BIN_OUT_DIR)/*)
|
|
|
|
|
2021-03-05 08:02:00 +01:00
|
|
|
swagger: ## creates swagger documentation as html file
|
2021-01-08 21:56:06 +01:00
|
|
|
npm install bootprint bootprint-openapi html-inline
|
2022-08-03 22:10:07 +02:00
|
|
|
go run github.com/swaggo/swag/cmd/swag init -g api/api.go
|
2021-01-08 21:56:06 +01:00
|
|
|
$(shell) node_modules/bootprint/bin/bootprint.js openapi docs/swagger.json /tmp/swagger/
|
|
|
|
$(shell) node_modules/html-inline/bin/cmd.js /tmp/swagger/index.html > docs/swagger.html
|
|
|
|
|
2021-03-05 08:02:00 +01:00
|
|
|
serve_docs: ## serves online docs
|
|
|
|
mkdocs serve
|
|
|
|
|
2021-01-08 21:56:06 +01:00
|
|
|
build: ## Build binary
|
2021-09-09 22:57:05 +02:00
|
|
|
go generate ./...
|
2021-08-30 18:12:33 +02:00
|
|
|
go build -v -ldflags="-w -s -X github.com/0xERR0R/blocky/util.Version=${VERSION} -X github.com/0xERR0R/blocky/util.BuildTime=${BUILD_TIME}" -o $(BIN_OUT_DIR)/$(BINARY_NAME)$(BINARY_SUFFIX)
|
2020-01-12 18:23:35 +01:00
|
|
|
|
|
|
|
test: ## run tests
|
2022-08-03 22:10:07 +02:00
|
|
|
go run github.com/onsi/ginkgo/v2/ginkgo -v --coverprofile=coverage.txt --covermode=atomic -cover ./...
|
2020-01-12 18:23:35 +01:00
|
|
|
|
2022-05-06 22:34:08 +02:00
|
|
|
race: ## run tests with race detector
|
2022-08-03 22:10:07 +02:00
|
|
|
go run github.com/onsi/ginkgo/v2/ginkgo --race ./...
|
2022-05-06 22:34:08 +02:00
|
|
|
|
2022-08-03 22:10:07 +02:00
|
|
|
lint: ## run golangcli-lint checks
|
|
|
|
go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout 5m
|
2020-01-12 18:23:35 +01:00
|
|
|
|
|
|
|
run: build ## Build and run binary
|
|
|
|
./$(BIN_OUT_DIR)/$(BINARY_NAME)
|
|
|
|
|
2021-08-25 22:12:12 +02:00
|
|
|
fmt: ## gofmt and goimports all go files
|
|
|
|
find . -name '*.go' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
|
|
|
|
|
2020-02-13 17:18:24 +01:00
|
|
|
docker-build: ## Build docker image
|
2021-03-05 22:31:48 +01:00
|
|
|
docker build --network=host --tag ${DOCKER_IMAGE_NAME} .
|
2020-02-13 17:18:24 +01:00
|
|
|
|
2020-01-12 18:23:35 +01:00
|
|
|
help: ## Shows help
|
2020-02-12 21:38:08 +01:00
|
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|