forked from percona/pmm-update
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (68 loc) · 3.98 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
BASE_PATH = $(shell pwd)
BIN_PATH := $(BASE_PATH)/bin
export PATH := $(BIN_PATH):$(PATH)
help: ## Display this help message.
@echo "Please use \`make <target>\` where <target> is one of:"
@grep '^[a-zA-Z]' $(MAKEFILE_LIST) | \
awk -F ':.*?## ' 'NF==2 {printf " %-26s%s\n", $$1, $$2}'
# `cut` is used to remove first `v` from `git describe` output
PMM_RELEASE_PATH ?= bin
PMM_RELEASE_VERSION ?= $(shell git describe --always --dirty | cut -b2-)
PMM_RELEASE_TIMESTAMP ?= $(shell date '+%s')
PMM_RELEASE_FULLCOMMIT ?= $(shell git rev-parse HEAD)
PMM_RELEASE_BRANCH ?= $(shell git describe --always --contains --all)
LD_FLAGS = -ldflags " \
-X 'github.com/percona/pmm/version.ProjectName=pmm-update' \
-X 'github.com/percona/pmm/version.Version=$(PMM_RELEASE_VERSION)' \
-X 'github.com/percona/pmm/version.PMMVersion=$(PMM_RELEASE_VERSION)' \
-X 'github.com/percona/pmm/version.Timestamp=$(PMM_RELEASE_TIMESTAMP)' \
-X 'github.com/percona/pmm/version.FullCommit=$(PMM_RELEASE_FULLCOMMIT)' \
-X 'github.com/percona/pmm/version.Branch=$(PMM_RELEASE_BRANCH)' \
"
release: ## Build pmm-update release binary.
env CGO_ENABLED=0 go build -v $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-update
init: ## Installs development tools
go build -modfile=tools/go.mod -o $(BIN_PATH)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
go build -modfile=tools/go.mod -o $(BIN_PATH)/goimports golang.org/x/tools/cmd/goimports
go build -modfile=tools/go.mod -o $(BIN_PATH)/reviewdog github.com/reviewdog/reviewdog/cmd/reviewdog
install: ## Install pmm-update binary.
go install $(LD_FLAGS) ./...
install-race: ## Install pmm-update binary with race detector.
go install $(LD_FLAGS) -race ./...
TEST_FLAGS ?= -timeout=60s -count=1 -v -p 1
test: ## Run tests.
go test $(TEST_FLAGS) ./...
test-race: ## Run tests with race detector.
go test $(TEST_FLAGS) -race ./...
test-cover: ## Run tests and collect per-package coverage information.
go test $(TEST_FLAGS) -coverprofile=cover.out -covermode=count ./...
check: ## Run required checkers and linters.
go run .github/check-license.go
ansible-playbook --syntax-check ansible/playbook/tasks/update.yml
ansible-playbook --check ansible/playbook/tasks/update.yml
ansible-lint ansible/playbook/tasks/update.yml
check-all: check ## Run all linters for new code.
$(BIN_PATH)/golangci-lint run -c=.golangci.yml --new-from-rev=PMM-2.0
FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
format: ## Format source code.
gofmt -w -s $(FILES)
$(BIN_PATH)/goimports -local github.com/percona/pmm-update -l -w $(FILES)
RUN_FLAGS ?=
run: install _run ## Run pmm-update.
run-race: install-race _run ## Run pmm-update with race detector.
run-race-cover: install-race ## Run pmm-update with race detector and collect coverage information.
go test -coverpkg="github.com/percona/pmm-update/..." \
-tags maincover \
$(LD_FLAGS) \
-race -c -o pmm-update.test
rm -f *.runcover.out
./pmm-update.test -test.count=1 -test.v -test.coverprofile=$(shell mktemp --tmpdir=. XXX.runcover.out) -test.run=TestMainCover $(RUN_FLAGS)
_run:
pmm-update $(RUN_FLAGS)
env-up: ## Start development environment.
docker-compose up --force-recreate --abort-on-container-exit --renew-anon-volumes --remove-orphans
env-down: ## Stop development environment.
docker-compose down --volumes --remove-orphans
ci-reviewdog: ## Runs reviewdog checks.
$(BIN_PATH)/golangci-lint run -c=.golangci-required.yml --out-format=line-number | $(BIN_PATH)/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check
$(BIN_PATH)/golangci-lint run -c=.golangci.yml --out-format=line-number | $(BIN_PATH)/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review