Debian Codegraph @

Makefile

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 SHELL = /bin/bash -euo pipefail
2
3 # Go binary to use in non-container targets
4 GO ?= go
5
6 # Variables for container targets
7 GO_VERSION ?= latest
8 CONTAINER ?= golang:$(GO_VERSION)
9 PKG = github.com/lorenzosaino/go-sysctl
10 DOCKER_RUN_FLAGS = --rm -it -v $$(pwd):/go/src/$(PKG) -w /go/src/$(PKG)
11
12 export GO111MODULE=on
13
14 all: fmt-check lint vet nilness staticcheck test ## Run all checks and tests
15
16 .PHONY: mod-upgrade
17 mod-upgrade: ## Upgrade all vendored dependencies
18 $(GO) get -d -u -t ./...
19 $(GO) mod tidy
20 $(GO) mod vendor
21
22 .PHONY: mod-update
23 mod-update: ## Ensure all used dependencies are tracked in go.{mod|sum} and vendored
24 $(GO) mod tidy
25 $(GO) mod vendor
26
27 .PHONY: fmt-check
28 fmt-check: ## Validate that all source files pass "go fmt"
29 exit $(shell $(GO) fmt ./... | wc -l)
30
31 .PHONY: lint
32 lint: ## Run go lint
33 @[ -x "$(shell which golint)" ] || $(GO) install ./vendor/golang.org/x/lint/golint 2>/dev/null || $(GO) install golang.org/x/lint/golint@latest
34 @# We need to explicitly exclude ./vendor because of https://github.com/golang/lint/issues/320
35 golint -set_exit_status $(shell $(GO) list ./... | grep -v '/vendor/')
36
37 .PHONY: vet
38 vet: ## Run go vet
39 $(GO) vet ./...
40
41 .PHONY: staticcheck
42 staticcheck: ## Run staticcheck
43 @[ -x "$(shell which staticcheck)" ] || $(GO) install ./vendor/honnef.co/go/tools/cmd/staticcheck 2>/dev/null || $(GO) install honnef.co/go/tools/cmd/staticcheck@latest
44 staticcheck ./...
45
46 nilness: ## Run nilness
47 $(GO) install ./vendor/golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness 2>/dev/null || [ -x "$(shell which nilness)" ] || $(GO) install golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness@latest
48 nilness ./...
49
50 .PHONY: test
51 test: ## Run all tests
52 $(GO) test -race ./...
53
54 .PHONY: container-shell
55 container-shell: ## Open a shell on a Docker container
56 docker run $(DOCKER_RUN_FLAGS) $(CONTAINER) /bin/bash
57
58 .PHONY: container-%
59 container-%: ## Run any target of this Makefile in a Docker container
60 docker run $(DOCKER_RUN_FLAGS) $(CONTAINER) make $*
61
62 .PHONY: help
63 help: ## Print help
64 @(grep -E '^[a-zA-Z0-9_%-]+:.*?## .*$$' Makefile || true )| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'