forked from giggsoff/adam
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
84 lines (62 loc) · 1.39 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
74
75
76
77
78
79
80
81
82
83
# Copyright (c) 2019 Zededa, Inc.
# SPDX-License-Identifier: Apache-2.0
.PHONY: all build build-docker build-local fmt clean lint test vet image
IMG ?= lfedge/adam
HASH ?= $(shell git show --format=%T -s)
GOVER ?= 1.12.4-alpine3.9
# check if we should append a dirty tag
DIRTY ?= $(shell git status --short)
ifneq ($(DIRTY),)
TAG = $(HASH)-dirty
else
TAG = $(HASH)
endif
GOENV ?= GO111MODULE=on CGO_ENABLED=0
GO ?=
ifneq ($(BUILD),local)
GO = docker run --rm -v $(PWD):/app -w /app golang:$(GOVER) env $(GOENV)
endif
GO_FILES := $(shell find . -type f -name '*.go')
all: build
bin:
mkdir -p bin
build:
ifneq ($(BUILD),local)
$(MAKE) build-docker
else
$(MAKE) build-local
endif
build-local: bin
$(GO) go build -o bin/adam main.go
build-docker:
docker build -t $(IMG) .
image: build-docker
ci: gitstat tag build fmt-check lint test vet image
gitstat:
@git status
tag:
@echo $(TAG)
fmt:
$(GO) gofmt -w ${GO_FILES}
fmt-check:
if [ -n "$$($(GO) gofmt -l ${GO_FILES})" ]; then \
$(GO) gofmt -s -e -d ${GO_FILES}; \
exit 1; \
fi
lint: linttools
$(GO) gometalinter --disable-all --enable=golint --vendor ./...
vet:
$(GO) go vet ./...
test:
$(GO) go test ./...
linttools:
ifeq ($(BUILD),local)
ifeq (, $(shell which golint))
$(GO) go get -u golang.org/x/lint/golint
endif
ifeq (, $(shell which gometalinter))
$(GO) go get -u github.com/alecthomas/gometalinter
endif
endif
clean:
rm -rf run/*