-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (37 loc) · 1.12 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
all: lint test
PHONY: test coverage lint golint clean vendor docker-up docker-down unit-test
GOOS=linux
# use the working dir as the app name, this should be the repo name
APP_NAME=$(shell basename $(CURDIR))
test: | unit-test
unit-test: | lint
@echo Running unit tests...
@go test -cover -short -tags testtools ./...
coverage:
@echo Generating coverage report...
@go test ./... -race -coverprofile=coverage.out -covermode=atomic -tags testtools -p 1
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out
lint: golint
golint: | vendor
@echo Linting Go files...
@golangci-lint run --build-tags "-tags testtools"
build:
@go mod download
@CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o bin/${APP_NAME}
clean: docker-clean
@echo Cleaning...
@rm -f app
@rm -rf ./dist/
@rm -rf coverage.out
@go clean -testcache
vendor:
@go mod download
@go mod tidy
docker-up: | build
@docker-compose build --no-cache --build-arg NAME=${APP_NAME}
@docker-compose -f docker-compose.yml up -d app
docker-down:
@docker-compose -f docker-compose.yml down
docker-clean:
@docker-compose -f docker-compose.yml down --volumes