forked from brigadecore/brigade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
146 lines (126 loc) · 4.01 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# The Docker registry where images are pushed.
# Note that if you use an org (like on Quay and DockerHub), you should
# include that: quay.io/foo
DOCKER_REGISTRY ?= deis
DOCKER_BUILD_FLAGS :=
LDFLAGS :=
BINS = brigade-api brigade-controller brigade-gateway brig brigade-cr-gateway brigade-vacuum
IMAGES = brigade-api brigade-controller brigade-gateway brigade-worker git-sidecar brigade-cr-gateway brigade-vacuum
DOCKER_BINS = brigade-api brigade-controller brigade-gateway brigade-cr-gateway brigade-vacuum
GIT_TAG = $(shell git describe --tags --always 2>/dev/null)
VERSION ?= ${GIT_TAG}
IMAGE_TAG ?= ${VERSION}
LDFLAGS += -X github.com/Azure/brigade/pkg/version.Version=$(VERSION)
# Build native binaries
.PHONY: build
build: $(BINS)
.PHONY: $(BINS)
$(BINS):
go build -ldflags '$(LDFLAGS)' -o bin/$@ ./$@/cmd/$@
# Cross-compile for Docker+Linux
build-docker-bins: $(addsuffix -docker-bin,$(DOCKER_BINS))
%-docker-bin:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o ./$*/rootfs/$* ./$*/cmd/$*
# To use docker-build, you need to have Docker installed and configured. You should also set
# DOCKER_REGISTRY to your own personal registry if you are not pushing to the official upstream.
.PHONY: docker-build
docker-build: build-docker-bins
docker-build: $(addsuffix -image,$(IMAGES))
%-image:
docker build $(DOCKER_BUILD_FLAGS) -t $(DOCKER_REGISTRY)/$*:$(IMAGE_TAG) $*
# You must be logged into DOCKER_REGISTRY before you can push.
.PHONY: docker-push
docker-push: $(addsuffix -push,$(IMAGES))
%-push:
docker push $(DOCKER_REGISTRY)/$*:$(IMAGE_TAG)
.PRECIOUS: build-chart
.PHONY: build-chart
build-chart:
helm package -d docs/ ./charts/brigade
helm package -d docs/ ./charts/brigade-project
helm repo index docs/
# All non-functional tests
.PHONY: test
test: test-style
test: test-unit
test: test-js
# Unit tests. Local only.
.PHONY: test-unit
test-unit:
go test -v ./...
# Functional tests assume access to github.com
# To set this up in your local environment:
# - Make sure kubectl is pointed to the right cluster
# - Create "myvals.yaml" and set to something like this:
# project: "deis/empty-testbed"
# repository: "github.com/deis/empty-testbed"
# secret: "MySecret"
# - Run "helm install ./charts/brigade-project -f myvals.yaml
# - Run "make run" in one terminal
# - Run "make test-functional" in another terminal
#
# This will clone the github.com/deis/empty-testbed repo and run the brigade.js
# file found there.
.PHONY: test-functional
test-functional: test-functional-prepare
test-functional:
go test --tags integration ./tests
# Test Repo is https://github.com/deis/empty-testbed
TEST_REPO_COMMIT = 589e15029e1e44dee48de4800daf1f78e64287c0
KUBECONFIG ?= ${HOME}/.kube/config
.PHONY: test-functional-prepare
test-functional-prepare:
go run ./tests/cmd/generate.go -kubeconfig $(KUBECONFIG) $(TEST_REPO_COMMIT)
# JS test is local only
.PHONY: test-js
test-js:
cd brigade-worker && yarn test
.PHONY: test-style
test-style:
gometalinter \
--disable-all \
--enable deadcode \
--severity deadcode:error \
--enable gofmt \
--enable ineffassign \
--enable misspell \
--enable vet \
--tests \
--vendor \
--deadline 60s \
./...
@echo "Recommended style checks ===>"
gometalinter \
--disable-all \
--enable golint \
--vendor \
--deadline 60s \
./... || :
HAS_NPM := $(shell command -v npm;)
HAS_ESLINT := $(shell command -v eslint;)
HAS_GOMETALINTER := $(shell command -v gometalinter;)
HAS_DEP := $(shell command -v dep;)
HAS_GIT := $(shell command -v git;)
HAS_BINDATA := $(shell command -v go-bindata;)
.PHONY: bootstrap
bootstrap:
ifndef HAS_NPM
$(error You must install npm)
endif
ifndef HAS_GIT
$(error You must install git)
endif
ifndef HAS_ESLINT
npm install -g eslint
endif
ifndef HAS_GOMETALINTER
go get -u github.com/alecthomas/gometalinter
gometalinter --install
endif
ifndef HAS_DEP
go get -u github.com/golang/dep/cmd/dep
endif
ifndef HAS_BINDATA
go get github.com/jteeuwen/go-bindata/...
endif
dep ensure