-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (68 loc) · 2.44 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
######################################################
# config
######################################################
# setting SHELL to bash allows bash commands to be executed by recipes
# options are set to exit when a recipe line exits non-zero or a piped command fails
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
## location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
# golang ci linter binary and version
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.51.2
# tparse binary and version
TPARSE ?= $(LOCALBIN)/tparse
TPARSE_VERSION ?= latest
######################################################
# misc
######################################################
.PHONY: clean
clean:
rm -rf build
rm -rf pkg/version/data/*.txt
.PHONY: localbin
localbin:
mkdir -p $(LOCALBIN)
.PHONY: golangci-lint
golangci-lint: localbin
test -s $(GOLANGCI_LINT)-$(GOLANGCI_LINT_VERSION) || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
test -s $(GOLANGCI_LINT)-$(GOLANGCI_LINT_VERSION) || mv $(GOLANGCI_LINT) $(GOLANGCI_LINT)-$(GOLANGCI_LINT_VERSION)
.PHONY: tparse
tparse: localbin
test -s $(TPARSE) || GOBIN=$(LOCALBIN) go install github.com/mfridman/tparse@$(TPARSE_VERSION)
test -s $(TPARSE)-$(TPARSE_VERSION) || mv $(TPARSE) $(TPARSE)-$(TPARSE_VERSION)
######################################################
# go
######################################################
.PHONY: tidy
tidy: ## clean up go.mod and go.sum
go mod tidy
.PHONY: download
download: ## downloads the dependencies
go mod download -x
.PHONY: build
build: generate ## build kontext binary.
go build -o build/kontext cmd/main.go
.PHONY: run
run: ## run kontext
go run ./cmd/main.go
######################################################
# lint
######################################################
.PHONY: lint
lint: generate golangci-lint ## lint all code with golangci-lint
$(GOLANGCI_LINT)-$(GOLANGCI_LINT_VERSION) run ./... --timeout 15m0s -v
######################################################
# test
######################################################
.PHONY: test
test: generate tparse
set -eu
set -o pipefail
go test ./... -cover -json | $(TPARSE)-$(TPARSE_VERSION) -all
######################################################
# generate
######################################################
.PHONY: generate
generate: clean
go generate github.com/orbatschow/kontext/pkg/cmd/version