-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
50 lines (36 loc) · 1.34 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
VERSION ?= $(shell git describe --tags --always)
IMAGE = 451291743503.dkr.ecr.eu-west-1.amazonaws.com/phoenix
PKG = github.com/rtlnl/phoenix
PKGS = $(shell go list ./...)
SEQ = $(shell seq 1 10)
LDFLAGS = "-s -w -X github.com/rtlnl/phoenix/pkg/version.Version=$(VERSION)"
OS ?= linux
ARCH ?= amd64
build:
GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/phoenix -a -tags netgo -ldflags $(LDFLAGS)
test:
@go clean -testcache
@go test -race -count=1 $(PKGS)
long-tests:
@for i in $(SEQ); do go test $(PKGS); done
lint:
@for pkg in $(PKGS); do golint $$pkg ; done
vet:
@go vet $(PKGS)
coverage:
@go test ./... -coverprofile=./coverage/coverage.out -o ./coverage/coverage.html
@go tool cover -html=./coverage/coverage.out
@go test ./... -covermode=count -coverprofile=./coverage/count.out fmt
@go tool cover -func=./coverage/count.out
docker-all: docker-build docker-image
docker-build:
@docker run -i --rm -v "$(PWD):/go/src/$(PKG)" -w /go/src/$(PKG) golang:1.10 make build OS=linux ARCH=amd64
docker-test:
@docker run -i --rm -v "$(PWD):/go/src/$(PKG)" -w /go/src/$(PKG) --network greeny_default golang:1.10 make test
docker-image:
@docker build -t $(IMAGE):$(VERSION) .
@docker tag $(IMAGE):$(VERSION) $(IMAGE):latest
@echo " ---> $(IMAGE):$(VERSION)\n ---> $(IMAGE):latest"
docker-push:
@docker push $(IMAGE):$(VERSION)
@docker push $(IMAGE):latest