forked from fastly/go-fastly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
123 lines (103 loc) · 2.7 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
# Metadata about this makefile and position
MKFILE_PATH := $(lastword $(MAKEFILE_LIST))
CURRENT_DIR := $(patsubst %/,%,$(dir $(realpath $(MKFILE_PATH))))
# Ensure GOPATH
GOPATH ?= $(HOME)/go
# List all our actual files, excluding vendor
GOFILES ?= $(shell go list $(FILES) | grep -v /vendor/)
# Tags specific for building
GOTAGS ?=
# Number of procs to use
GOMAXPROCS ?= 4
PROJECT := $(CURRENT_DIR:$(GOPATH)/src/%=%)
OWNER := $(notdir $(patsubst %/,%,$(dir $(PROJECT))))
NAME := $(notdir $(PROJECT))
EXTERNAL_TOOLS = \
github.com/golang/dep/cmd/dep
# Current system information
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOCACHE ?= $(shell go env GOCACHE)
# List of tests to run
FILES ?= ./...
# Test Service ID
FASTLY_TEST_SERVICE_ID ?=
# bootstrap installs the necessary go tools for development or build.
bootstrap:
@echo "==> Bootstrapping ${PROJECT}"
@for t in ${EXTERNAL_TOOLS}; do \
echo "--> Installing $$t" ; \
go get -u "$$t"; \
done
.PHONY: bootstrap
clean:
@echo "==> Cleaning ${NAME}"
@rm -rf pkg
.PHONY: clean
# build builds the binary into pkg/
build:
@echo "==> Building ${NAME} for ${GOOS}/${GOARCH}"
@env \
-i \
PATH="${PATH}" \
CGO_ENABLED="0" \
GOOS="${GOOS}" \
GOARCH="${GOARCH}" \
GOCACHE="${GOCACHE}" \
GOPATH="${GOPATH}" \
go build -a -o "pkg/${GOOS}_${GOARCH}/${NAME}" ${GOFILES}
.PHONY: build
# deps updates all dependencies for this project.
deps:
@echo "==> Updating deps for ${PROJECT}"
@dep ensure -update
@dep prune
.PHONY: deps
# dev builds and installs the
dev:
@echo "==> Installing ${NAME} for ${GOOS}/${GOARCH}"
@env \
-i \
PATH="${PATH}" \
CGO_ENABLED="0" \
GOOS="${GOOS}" \
GOARCH="${GOARCH}" \
GOCACHE="${GOCACHE}" \
GOPATH="${GOPATH}" \
go install ${GOFILES}
.PHONY: dev
# linux builds the linux binary
linux:
@env \
GOOS="linux" \
GOARCH="amd64" \
$(MAKE) -f "${MKFILE_PATH}" build
.PHONY: linux
# test runs the test suite.
test:
@echo "==> Testing ${NAME}"
@go test -timeout=30s -parallel=20 -tags="${GOTAGS}" ${GOFILES} ${TESTARGS}
.PHONY: test
# test-race runs the test suite.
test-race:
@echo "==> Testing ${NAME} (race)"
@go test -timeout=60s -race -tags="${GOTAGS}" ${GOFILES} ${TESTARGS}
.PHONY: test-race
# test without VCR
test-full:
@echo "==> Testing ${NAME} with VCR disabled"
@env \
VCR_DISABLE=1 \
go test -timeout=60s -parallel=20 ${GOFILES} ${TESTARGS}
.PHONY: test-full
# update fixtures default service ID
fix-fixtures:
@echo "==> Updating fixtures"
@$(CURRENT_DIR)/scripts/fixFixtures.sh ${FASTLY_TEST_SERVICE_ID}
.PHONY: fix-fixtures
changelog:
@$(CURRENT_DIR)/scripts/changelog.sh
.PHONY: changelog
release-changelog:
@$(CURRENT_DIR)/scripts/release-changelog.sh
.PHONY: release-changelog