-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
98 lines (80 loc) · 3.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
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
SHELL := $(shell which bash)
NO_COLOR := \033[0m
OK_COLOR := \033[32;01m
ERR_COLOR := \033[31;01m
WARN_COLOR := \033[36;01m
ATTN_COLOR := \033[33;01m
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
GOPRIVATE := "github.com/aserto-dev"
EXT_DIR := ./.ext
EXT_BIN_DIR := ${EXT_DIR}/bin
EXT_TMP_DIR := ${EXT_DIR}/tmp
GO_VER := 1.23
GOTESTSUM_VER := 1.11.0
GOLANGCI-LINT_VER := 1.61.0
WIRE_VER := 0.6.0
.DEFAULT_GOAL := test
.PHONY: deps
deps: info install-golangci-lint install-gotestsum install-wire
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@(go env GOVERSION | grep "go${GO_VER}") || (echo "go version check failed expected go${GO_VER} got $$(go env GOVERSION)"; exit 1)
.PHONY: generate
generate:
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@GOBIN=${PWD}/${EXT_BIN_DIR} go generate ./...
.PHONY: lint
lint:
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@${EXT_BIN_DIR}/golangci-lint run --config ${PWD}/.golangci.yaml
# github.com/aserto-dev/topaz/pkg/app/tests/$PKGS
.PHONY: test
test:
@echo -e "$(ATTN_COLOR)==> test github.com/aserto-dev/runtime/... $(NO_COLOR)"
@${EXT_BIN_DIR}/gotestsum --format short-verbose -- -count=1 -parallel=1 -v -coverprofile=cover.out -coverpkg=./... github.com/aserto-dev/runtime/...;
.PHONY: write-version
write-version:
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@git describe --tags > ./VERSION.txt
.PHONY: info
info:
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@echo "GOOS: ${GOOS}"
@echo "GOARCH: ${GOARCH}"
@echo "EXT_DIR: ${EXT_DIR}"
@echo "EXT_BIN_DIR: ${EXT_BIN_DIR}"
@echo "EXT_TMP_DIR: ${EXT_TMP_DIR}"
.PHONY: install-gotestsum
install-gotestsum: ${EXT_TMP_DIR} ${EXT_BIN_DIR}
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@gh release download v${GOTESTSUM_VER} --repo https://github.com/gotestyourself/gotestsum --pattern "gotestsum_${GOTESTSUM_VER}_${GOOS}_${GOARCH}.tar.gz" --output "${EXT_TMP_DIR}/gotestsum.tar.gz" --clobber
@tar -xvf ${EXT_TMP_DIR}/gotestsum.tar.gz --directory ${EXT_BIN_DIR} gotestsum &> /dev/null
@chmod +x ${EXT_BIN_DIR}/gotestsum
@${EXT_BIN_DIR}/gotestsum --version
.PHONY: install-golangci-lint
install-golangci-lint: ${EXT_TMP_DIR} ${EXT_BIN_DIR}
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@gh release download v${GOLANGCI-LINT_VER} --repo https://github.com/golangci/golangci-lint --pattern "golangci-lint-${GOLANGCI-LINT_VER}-${GOOS}-${GOARCH}.tar.gz" --output "${EXT_TMP_DIR}/golangci-lint.tar.gz" --clobber
@tar --strip=1 -xvf ${EXT_TMP_DIR}/golangci-lint.tar.gz --strip-components=1 --directory ${EXT_TMP_DIR} &> /dev/null
@mv ${EXT_TMP_DIR}/golangci-lint ${EXT_BIN_DIR}/golangci-lint
@chmod +x ${EXT_BIN_DIR}/golangci-lint
@${EXT_BIN_DIR}/golangci-lint --version
.PHONY: install-wire
install-wire: ${EXT_TMP_DIR} ${EXT_BIN_DIR}
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@GOBIN=${PWD}/${EXT_BIN_DIR} go install github.com/google/wire/cmd/wire@v${WIRE_VER}
.PHONY: clean
clean:
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@rm -rf ${EXT_DIR}
@rm -rf ${BIN_DIR}
@rm -rf ./dist
${BIN_DIR}:
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@mkdir -p ${BIN_DIR}
${EXT_BIN_DIR}:
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@mkdir -p ${EXT_BIN_DIR}
${EXT_TMP_DIR}:
@echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)"
@mkdir -p ${EXT_TMP_DIR}