-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (59 loc) · 1.66 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
envfile ?= .env
-include $(envfile)
ifneq ("$(wildcard $(envfile))","")
export $(shell sed 's/=.*//' $(envfile))
endif
GOLANGCI_VERSION:=1.52.2
SWAG_VERSION:=v1.8.12
PROJECT_NAME:=maritime-ports-service
GOPATH_BIN:=$(shell go env GOPATH)/bin
.PHONY: install
install:
# Install Swag tool for Swagger API documentation generation.
go install \
github.com/swaggo/swag/cmd/swag@${SWAG_VERSION}
# Install golangci-lint for go code linting.
curl -sSfL \
"https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | \
sh -s -- -b ${GOPATH_BIN} v${GOLANGCI_VERSION}
.PHONY: all
all: clean init lint test build-server
.PHONY: init
init:
@cp .env.dist .env
.PHONY: lint
lint:
@echo ">>> Performing golang code linting.."
golangci-lint run --config=.golangci.yml
.PHONY: test
test:
@echo ">>> Running Unit Tests..."
go test -v -race ./...
.PHONY: test-no-cache
test-no-cache:
@echo ">>> Running Unit Tests without Caching..."
go test -v -count=1 -race ./...
.PHONY: cover-test
cover-test:
@echo ">>> Running Tests with Coverage..."
go test -v -race ./... -coverprofile=coverage.out -covermode=atomic
.PHONY: show-cover
show-cover:
@go tool cover -html=coverage.out
.PHONY: build-server
build-server:
@echo ">>> Building ${PROJECT_NAME} API server..."
go build -o bin/${PROJECT_NAME} cmd/${PROJECT_NAME}/main.go
.PHONY: run-server
run-server:
@echo ">>> Running ${PROJECT_NAME} API server..."
@go run ./cmd/${PROJECT_NAME}/main.go
.PHONY: docs
docs:
@echo ">>> Generate Swagger API Documentation..."
swag init --generalInfo cmd/${PROJECT_NAME}/main.go
.PHONY: clean
clean:
@echo ">>> Removing old binaries and env files..."
@rm -rf bin/*
@rm -rf .env