Skip to content

Commit 251b414

Browse files
WIP
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
1 parent 7c89dd6 commit 251b414

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@ go-feature-flag-relay-proxy/
4343
node_modules/
4444
oryxBuildBinary
4545

46-
./.sonarlint
46+
./.sonarlint
47+
sonarlint.xml
48+
vcs.xml
49+
workspace.xml
50+
codeStyles/
51+
inspectionProfiles/
52+
misc.xml
53+
modules.xml
54+
shelf/

Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
GOCMD=go
2+
GOTEST=$(GOCMD) test
3+
GOVET=$(GOCMD) vet
4+
5+
GREEN := $(shell tput -Txterm setaf 2)
6+
YELLOW := $(shell tput -Txterm setaf 3)
7+
WHITE := $(shell tput -Txterm setaf 7)
8+
CYAN := $(shell tput -Txterm setaf 6)
9+
RESET := $(shell tput -Txterm sgr0)
10+
11+
.PHONY: all test build vendor
12+
13+
14+
15+
all: help
16+
## Build:
17+
build: build-api ## Build all the binaries and put the output in out/bin/
18+
19+
create-out-dir:
20+
mkdir -p out/bin
21+
22+
build-api: create-out-dir ## Build the migration cli in out/bin/
23+
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/goff-api .
24+
25+
clean: ## Remove build related file
26+
-rm -fr ./bin ./out ./release
27+
-rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml
28+
29+
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
30+
$(GOCMD) mod tidy
31+
$(GOCMD) mod vendor
32+
33+
## Dev:
34+
swagger: ## Build swagger documentation
35+
$(GOCMD) install github.com/swaggo/swag/cmd/swag@latest
36+
cd cmd/relayproxy && swag init --parseDependency --parseDepth=1 --parseInternal --markdownFiles docs
37+
38+
setup-env:
39+
docker stop goff || true
40+
docker rm goff || true
41+
docker run --name goff -e POSTGRES_DB=gofeatureflag -e POSTGRES_PASSWORD=my-secret-pw -p 5432:5432 -e POSTGRES_USER=goff-user -d postgres
42+
sleep 2
43+
migrate -source "file://database_migration" -database "postgres://goff-user:my-secret-pw@localhost:5432/gofeatureflag?sslmode=disable" up
44+
45+
## Test:
46+
test: ## Run the tests of the project
47+
$(GOTEST) -v -race ./...
48+
49+
coverage: ## Run the tests of the project and export the coverage
50+
$(GOTEST) -cover -covermode=count -tags=docker -coverprofile=coverage.cov.tmp ./... \
51+
&& cat coverage.cov.tmp | grep -v "/examples/" > coverage.cov
52+
53+
54+
## Lint:
55+
lint: ## Use golintci-lint on your project
56+
mkdir -p ./bin
57+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest # Install linters
58+
./bin/golangci-lint run --timeout=5m --timeout=5m ./... --enable-only=gci --fix # Run linters
59+
60+
## Help:
61+
help: ## Show this help.
62+
@echo ''
63+
@echo 'Usage:'
64+
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
65+
@echo ''
66+
@echo 'Targets:'
67+
@awk 'BEGIN {FS = ":.*?## "} { \
68+
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
69+
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
70+
}' $(MAKEFILE_LIST)

0 commit comments

Comments
 (0)