-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Thomas Poignant <[email protected]>
- Loading branch information
1 parent
7c89dd6
commit 251b414
Showing
2 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
GOCMD=go | ||
GOTEST=$(GOCMD) test | ||
GOVET=$(GOCMD) vet | ||
|
||
GREEN := $(shell tput -Txterm setaf 2) | ||
YELLOW := $(shell tput -Txterm setaf 3) | ||
WHITE := $(shell tput -Txterm setaf 7) | ||
CYAN := $(shell tput -Txterm setaf 6) | ||
RESET := $(shell tput -Txterm sgr0) | ||
|
||
.PHONY: all test build vendor | ||
|
||
|
||
|
||
all: help | ||
## Build: | ||
build: build-api ## Build all the binaries and put the output in out/bin/ | ||
|
||
create-out-dir: | ||
mkdir -p out/bin | ||
|
||
build-api: create-out-dir ## Build the migration cli in out/bin/ | ||
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/goff-api . | ||
|
||
clean: ## Remove build related file | ||
-rm -fr ./bin ./out ./release | ||
-rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml | ||
|
||
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory | ||
$(GOCMD) mod tidy | ||
$(GOCMD) mod vendor | ||
|
||
## Dev: | ||
swagger: ## Build swagger documentation | ||
$(GOCMD) install github.com/swaggo/swag/cmd/swag@latest | ||
cd cmd/relayproxy && swag init --parseDependency --parseDepth=1 --parseInternal --markdownFiles docs | ||
|
||
setup-env: | ||
docker stop goff || true | ||
docker rm goff || true | ||
docker run --name goff -e POSTGRES_DB=gofeatureflag -e POSTGRES_PASSWORD=my-secret-pw -p 5432:5432 -e POSTGRES_USER=goff-user -d postgres | ||
sleep 2 | ||
migrate -source "file://database_migration" -database "postgres://goff-user:my-secret-pw@localhost:5432/gofeatureflag?sslmode=disable" up | ||
|
||
## Test: | ||
test: ## Run the tests of the project | ||
$(GOTEST) -v -race ./... | ||
|
||
coverage: ## Run the tests of the project and export the coverage | ||
$(GOTEST) -cover -covermode=count -tags=docker -coverprofile=coverage.cov.tmp ./... \ | ||
&& cat coverage.cov.tmp | grep -v "/examples/" > coverage.cov | ||
|
||
|
||
## Lint: | ||
lint: ## Use golintci-lint on your project | ||
mkdir -p ./bin | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest # Install linters | ||
./bin/golangci-lint run --timeout=5m --timeout=5m ./... --enable-only=gci --fix # Run linters | ||
|
||
## Help: | ||
help: ## Show this help. | ||
@echo '' | ||
@echo 'Usage:' | ||
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}' | ||
@echo '' | ||
@echo 'Targets:' | ||
@awk 'BEGIN {FS = ":.*?## "} { \ | ||
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \ | ||
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \ | ||
}' $(MAKEFILE_LIST) |