File: Makefile

package info (click to toggle)
golang-github-rican7-retry 0.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, experimental, forky, sid, trixie
  • size: 136 kB
  • sloc: makefile: 47
file content (74 lines) | stat: -rw-r--r-- 1,828 bytes parent folder | download
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
# Define directories
ROOT_DIR ?= ${CURDIR}
TOOLS_DIR ?= ${ROOT_DIR}/tools

# Set a local GOBIN, since the default value can't be trusted
# (See https://github.com/golang/go/issues/23439)
export GOBIN ?= ${TOOLS_DIR}/bin

# Set the mode for code-coverage
GO_TEST_COVERAGE_MODE ?= count
GO_TEST_COVERAGE_FILE_NAME ?= coverage.out

# Set flags for `gofmt`
GOFMT_FLAGS ?= -s

# Set a default `min_confidence` value for `golint`
GOLINT_MIN_CONFIDENCE ?= 0.1


all: build

clean:
	go clean -i -x ./...

build:
	go build -v ./...

install-deps:
	go mod download

tools install-deps-dev:
	cd tools && go install \
		golang.org/x/lint/golint \
		golang.org/x/tools/cmd/goimports \
		honnef.co/go/tools/cmd/staticcheck

update-deps:
	go get ./...

test:
	go test -v ./...

test-with-coverage:
	go test -cover -covermode ${GO_TEST_COVERAGE_MODE} ./...

test-with-coverage-formatted:
	go test -cover -covermode ${GO_TEST_COVERAGE_MODE} ./... | column -t | sort -r

test-with-coverage-profile:
	go test -covermode ${GO_TEST_COVERAGE_MODE} -coverprofile ${GO_TEST_COVERAGE_FILE_NAME} ./...

format-lint:
	errors=$$(gofmt -l ${GOFMT_FLAGS} .); if [ "$${errors}" != "" ]; then echo "$${errors}"; exit 1; fi

import-lint: install-deps-dev
	errors=$$(${GOBIN}/goimports -l .); if [ "$${errors}" != "" ]; then echo "$${errors}"; exit 1; fi

style-lint: install-deps-dev
	${GOBIN}/golint -min_confidence=${GOLINT_MIN_CONFIDENCE} -set_exit_status ./...
	${GOBIN}/staticcheck ./...

lint: install-deps-dev format-lint import-lint style-lint

vet:
	go vet ./...

format-fix:
	gofmt -w ${GOFMT_FLAGS} .

import-fix:
	goimports -w .


.PHONY: all clean build install-deps tools install-deps-dev update-deps test test-with-coverage test-with-coverage-formatted test-with-coverage-profile format-lint import-lint style-lint lint vet format-fix import-fix