This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile.devcontainer
113 lines (83 loc) · 4.84 KB
/
Makefile.devcontainer
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
# Devcontainer Makefile.
include Makefile.include
# used by host Makefile
_bash:
/bin/bash
gen: ## Generate files.
rm -f models/*_reform.go
find . -name mock_*.go -delete
go generate ./...
make format
install: ## Install pmm-managed binaries.
go install -gcflags="all=-N -l" -v $(PMM_LD_FLAGS) ./...
make release
install-race: ## Install pmm-managed binaries with race detector.
go install -race -v $(PMM_LD_FLAGS) ./...
# like make release, but with -race (and cgo is required for -race)
go build -race -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-managed
go build -race -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-managed-init ./cmd/pmm-managed-init
go build -race -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-managed-starlark ./cmd/pmm-managed-starlark
install-debug: ## Install pmm-managed binaries with debug symbols.
go build -gcflags="all=-N -l" -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-managed
go build -gcflags="all=-N -l" -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-managed-init ./cmd/pmm-managed-init
go build -gcflags="all=-N -l" -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-managed-starlark ./cmd/pmm-managed-starlark
PMM_TEST_PACKAGES ?= $(shell go list ./... | grep -v /api-tests)
PMM_TEST_FLAGS ?= -timeout=90s
PMM_TEST_RUN_UPDATE ?= 0
test: ## Run tests.
go test $(PMM_TEST_FLAGS) -p 1 $(PMM_TEST_PACKAGES)
test-race: ## Run tests with race detector.
go test $(PMM_TEST_FLAGS) -p 1 -race $(PMM_TEST_PACKAGES)
test-cover: ## Run tests and collect per-package coverage information.
go test $(PMM_TEST_FLAGS) -p 1 -coverprofile=cover.out -covermode=count $(PMM_TEST_PACKAGES)
test-crosscover: ## Run tests and collect cross-package coverage information.
go test $(PMM_TEST_FLAGS) -p 1 -coverprofile=crosscover.out -covermode=count -coverpkg=./... $(PMM_TEST_PACKAGES)
test-race-crosscover: ## Run tests with race detector and collect cross-package coverage information.
go test $(PMM_TEST_FLAGS) -p 1 -race -coverprofile=race-crosscover.out -covermode=atomic -coverpkg=./... $(PMM_TEST_PACKAGES)
test-all: test-race test-cover test-crosscover
env PMM_TEST_FLAGS='-timeout=180s -v' \
PMM_TEST_PACKAGES=./services/supervisord \
PMM_TEST_RUN_UPDATE=1 \
make test-race-crosscover
fuzz-grafana: ## Run fuzzer for services/grafana package.
# go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
mkdir -p services/grafana/fuzzdata/corpus
cd services/grafana && go-fuzz-build
cd services/grafana && go-fuzz -workdir=fuzzdata
check: ## Run required checkers and linters.
go run .github/check-license.go
go-sumtype ./...
golangci-lint run -c=.golangci-required.yml
go-consistent -pedantic ./...
check-all: check ## Run all linters for new code.
golangci-lint run -c=.golangci.yml --new-from-rev=main
FILES = $(shell find . -type f -name '*.go')
format: ## Format source code.
gofumpt -l -w $(FILES)
goimports -local github.com/percona/pmm-managed -l -w $(FILES)
gci write --Section Standard --Section Default --Section "Prefix(github.com/percona/pmm-managed)" .
_run:
supervisorctl stop pmm-managed
cp $(PMM_RELEASE_PATH)/pmm-managed /usr/sbin/pmm-managed
supervisorctl start pmm-managed &
supervisorctl tail -f pmm-managed
run: install _run ## Run pmm-managed.
run-race: install-race _run ## Run pmm-managed with race detector.
run-debug: install-debug _run ## Run pmm-managed with debug symbols.
# TODO https://jira.percona.com/browse/PMM-3484, see maincover_test.go
# run-race-cover: install-race ## Run pmm-managed with race detector and collect coverage information.
# go test -coverpkg="github.com/percona/pmm-managed/..." \
# -tags maincover \
# $(PMM_LD_FLAGS) \
# -race -c -o bin/pmm-managed.test
# bin/pmm-managed.test -test.coverprofile=cover.out -test.run=TestMainCover $(RUN_FLAGS)
psql: ## Open database for the pmm-managed instance in psql shell.
env PGPASSWORD=pmm-managed psql -U pmm-managed pmm-managed
psql-test: ## Open database used in unit tests in psql shell.
env psql -U postgres pmm-managed-dev
ci-reviewdog:
golangci-lint run -c=.golangci-required.yml --out-format=line-number | reviewdog -f=golangci-lint -level=error -reporter=github-pr-check
golangci-lint run -c=.golangci.yml --out-format=line-number | reviewdog -f=golangci-lint -level=error -reporter=github-pr-review
go-consistent -pedantic -exclude "tests" ./... | reviewdog -f=go-consistent -name='Required go-consistent checks' -reporter=github-pr-check
dlv/attach: ## Attache Delve to `pmm-managed`
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient attach $(shell pgrep pmm-managed)