-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (51 loc) · 1.43 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
envfile ?= .env
-include $(envfile)
ifneq ("$(wildcard $(envfile))","")
export $(shell sed 's/=.*//' $(envfile))
endif
GOLANGCI_VERSION:=1.50.1
PROJECT_NAME:=ethereum-block-scanner
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@latest
# 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 -race ./...
.PHONY: cover-test
cover-test:
@echo ">>> Running Tests with Coverage..."
go test -race ./... -coverprofile=coverage.txt -covermode=atomic
.PHONY: build-server
build-server:
@echo ">>> Building ${PROJECT_NAME} API server..."
go build -o bin/server 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