-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
72 lines (53 loc) · 2.35 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
.PHONY: all format lint tidy test clean
# -----------------------------------------------------------------------------
# CONSTANTS
# -----------------------------------------------------------------------------
version = `cat VERSION`
src_dir := terraform-provider-redash
build_dir = build
coverage_dir = $(build_dir)/coverage
coverage_out = $(coverage_dir)/coverage.out
coverage_html = $(coverage_dir)/coverage.html
output_dir = $(build_dir)/output
linux_dir = $(output_dir)/linux
darwin_dir = $(output_dir)/darwin
windows_dir = $(output_dir)/windows
bin_name = terraform-provider-redash_v$(version)
bin_linux = $(linux_dir)/$(bin_name)
bin_darwin = $(darwin_dir)/$(bin_name)
bin_windows = $(windows_dir)/$(bin_name)
# -----------------------------------------------------------------------------
# BUILDING
# -----------------------------------------------------------------------------
all:
GO111MODULE=on go get -u github.com/mitchellh/gox
GO111MODULE=on go install github.com/mitchellh/gox
GO111MODULE=on gox -osarch=linux/amd64 -output=$(bin_linux) ./$(src_dir)
GO111MODULE=on gox -osarch=darwin/amd64 -output=$(bin_darwin) ./$(src_dir)
GO111MODULE=on gox -osarch=windows/amd64 -output=$(bin_windows) ./$(src_dir)
# -----------------------------------------------------------------------------
# FORMATTING
# -----------------------------------------------------------------------------
format:
GO111MODULE=on go fmt ./$(src_dir)
GO111MODULE=on gofmt -s -w ./$(src_dir)
lint:
GO111MODULE=on go get -u golang.org/x/lint/golint
GO111MODULE=on go install golang.org/x/lint/golint
GO111MODULE=on golint ./$(src_dir)
tidy:
GO111MODULE=on go mod tidy
# -----------------------------------------------------------------------------
# TESTING
# -----------------------------------------------------------------------------
test:
mkdir -p $(coverage_dir)
GO111MODULE=on go get -u golang.org/x/tools/cmd/cover/...
GO111MODULE=on go install golang.org/x/tools/cmd/cover/...
GO111MODULE=on go test ./$(src_dir) -tags test -v -covermode=count -coverprofile=$(coverage_out)
GO111MODULE=on go tool cover -html=$(coverage_out) -o $(coverage_html)
# -----------------------------------------------------------------------------
# CLEANUP
# -----------------------------------------------------------------------------
clean:
rm -rf $(build_dir)